diff --git a/homeassistant/components/hdfury/icons.json b/homeassistant/components/hdfury/icons.json index 60123cec657..67c854a761d 100644 --- a/homeassistant/components/hdfury/icons.json +++ b/homeassistant/components/hdfury/icons.json @@ -6,6 +6,12 @@ } }, "number": { + "audio_unmute": { + "default": "mdi:volume-high" + }, + "earc_unmute": { + "default": "mdi:volume-high" + }, "oled_fade": { "default": "mdi:cellphone-information" }, diff --git a/homeassistant/components/hdfury/number.py b/homeassistant/components/hdfury/number.py index 3693c5171ba..3f36fbab18a 100644 --- a/homeassistant/components/hdfury/number.py +++ b/homeassistant/components/hdfury/number.py @@ -31,6 +31,32 @@ class HDFuryNumberEntityDescription(NumberEntityDescription): NUMBERS: tuple[HDFuryNumberEntityDescription, ...] = ( + HDFuryNumberEntityDescription( + key="unmutecnt", + translation_key="audio_unmute", + entity_registry_enabled_default=False, + mode=NumberMode.BOX, + native_min_value=50, + native_max_value=1000, + native_step=1, + device_class=NumberDeviceClass.DURATION, + native_unit_of_measurement=UnitOfTime.MILLISECONDS, + entity_category=EntityCategory.CONFIG, + set_value_fn=lambda client, value: client.set_audio_unmute(value), + ), + HDFuryNumberEntityDescription( + key="earcunmutecnt", + translation_key="earc_unmute", + entity_registry_enabled_default=False, + mode=NumberMode.BOX, + native_min_value=0, + native_max_value=1000, + native_step=1, + device_class=NumberDeviceClass.DURATION, + native_unit_of_measurement=UnitOfTime.MILLISECONDS, + entity_category=EntityCategory.CONFIG, + set_value_fn=lambda client, value: client.set_earc_unmute(value), + ), HDFuryNumberEntityDescription( key="oledfade", translation_key="oled_fade", diff --git a/homeassistant/components/hdfury/strings.json b/homeassistant/components/hdfury/strings.json index 54a09bd9485..e7ade56c937 100644 --- a/homeassistant/components/hdfury/strings.json +++ b/homeassistant/components/hdfury/strings.json @@ -41,6 +41,12 @@ } }, "number": { + "audio_unmute": { + "name": "Unmute delay" + }, + "earc_unmute": { + "name": "eARC unmute delay" + }, "oled_fade": { "name": "OLED fade timer" }, diff --git a/tests/components/hdfury/conftest.py b/tests/components/hdfury/conftest.py index b296ed902b8..ac0dc78e5e8 100644 --- a/tests/components/hdfury/conftest.py +++ b/tests/components/hdfury/conftest.py @@ -104,6 +104,8 @@ def mock_hdfury_client() -> Generator[AsyncMock]: "relay": "0", "macaddr": "c7:1c:df:9d:f6:40", "reboottimer": "0", + "unmutecnt": "500", + "earcunmutecnt": "0", "oled": "1", "oledfade": "30", } diff --git a/tests/components/hdfury/snapshots/test_diagnostics.ambr b/tests/components/hdfury/snapshots/test_diagnostics.ambr index 6d4043fb3b1..b73f3563f34 100644 --- a/tests/components/hdfury/snapshots/test_diagnostics.ambr +++ b/tests/components/hdfury/snapshots/test_diagnostics.ambr @@ -15,6 +15,7 @@ 'cec1en': '1', 'cec2en': '1', 'cec3en': '1', + 'earcunmutecnt': '0', 'htpcmode0': '0', 'htpcmode1': '0', 'htpcmode2': '0', @@ -29,6 +30,7 @@ 'relay': '0', 'tx0plus5': '1', 'tx1plus5': '1', + 'unmutecnt': '500', }), 'info': dict({ 'AUD0': 'bitstream 48kHz', diff --git a/tests/components/hdfury/snapshots/test_number.ambr b/tests/components/hdfury/snapshots/test_number.ambr index 20cde1949d6..e7cc28ff4e3 100644 --- a/tests/components/hdfury/snapshots/test_number.ambr +++ b/tests/components/hdfury/snapshots/test_number.ambr @@ -1,4 +1,64 @@ # serializer version: 1 +# name: test_number_entities[number.hdfury_vrroom_02_earc_unmute_delay-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'max': 1000, + 'min': 0, + 'mode': , + 'step': 1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'number', + 'entity_category': , + 'entity_id': 'number.hdfury_vrroom_02_earc_unmute_delay', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'eARC unmute delay', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'eARC unmute delay', + 'platform': 'hdfury', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'earc_unmute', + 'unique_id': '000123456789_earcunmutecnt', + 'unit_of_measurement': , + }) +# --- +# name: test_number_entities[number.hdfury_vrroom_02_earc_unmute_delay-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'duration', + 'friendly_name': 'HDFury VRROOM-02 eARC unmute delay', + 'max': 1000, + 'min': 0, + 'mode': , + 'step': 1, + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'number.hdfury_vrroom_02_earc_unmute_delay', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0.0', + }) +# --- # name: test_number_entities[number.hdfury_vrroom_02_oled_fade_timer-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -119,3 +179,63 @@ 'state': '0.0', }) # --- +# name: test_number_entities[number.hdfury_vrroom_02_unmute_delay-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'max': 1000, + 'min': 50, + 'mode': , + 'step': 1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'number', + 'entity_category': , + 'entity_id': 'number.hdfury_vrroom_02_unmute_delay', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Unmute delay', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Unmute delay', + 'platform': 'hdfury', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'audio_unmute', + 'unique_id': '000123456789_unmutecnt', + 'unit_of_measurement': , + }) +# --- +# name: test_number_entities[number.hdfury_vrroom_02_unmute_delay-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'duration', + 'friendly_name': 'HDFury VRROOM-02 Unmute delay', + 'max': 1000, + 'min': 50, + 'mode': , + 'step': 1, + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'number.hdfury_vrroom_02_unmute_delay', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '500.0', + }) +# --- diff --git a/tests/components/hdfury/test_number.py b/tests/components/hdfury/test_number.py index b39a73d8467..57292827646 100644 --- a/tests/components/hdfury/test_number.py +++ b/tests/components/hdfury/test_number.py @@ -23,6 +23,7 @@ from . import setup_integration from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_number_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, @@ -40,8 +41,11 @@ async def test_number_entities( [ ("number.hdfury_vrroom_02_oled_fade_timer", "set_oled_fade"), ("number.hdfury_vrroom_02_restart_timer", "set_reboot_timer"), + ("number.hdfury_vrroom_02_unmute_delay", "set_audio_unmute"), + ("number.hdfury_vrroom_02_earc_unmute_delay", "set_earc_unmute"), ], ) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_number_set_value( hass: HomeAssistant, mock_hdfury_client: AsyncMock, @@ -68,8 +72,11 @@ async def test_number_set_value( [ ("number.hdfury_vrroom_02_oled_fade_timer", "set_oled_fade"), ("number.hdfury_vrroom_02_restart_timer", "set_reboot_timer"), + ("number.hdfury_vrroom_02_unmute_delay", "set_audio_unmute"), + ("number.hdfury_vrroom_02_earc_unmute_delay", "set_earc_unmute"), ], ) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_number_error( hass: HomeAssistant, mock_hdfury_client: AsyncMock, @@ -100,8 +107,11 @@ async def test_number_error( [ ("number.hdfury_vrroom_02_oled_fade_timer"), ("number.hdfury_vrroom_02_restart_timer"), + ("number.hdfury_vrroom_02_unmute_delay"), + ("number.hdfury_vrroom_02_earc_unmute_delay"), ], ) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_number_entities_unavailable_on_error( hass: HomeAssistant, mock_hdfury_client: AsyncMock,