diff --git a/homeassistant/components/hdfury/icons.json b/homeassistant/components/hdfury/icons.json index 0ffa8d42a84..91d1c3c6784 100644 --- a/homeassistant/components/hdfury/icons.json +++ b/homeassistant/components/hdfury/icons.json @@ -64,6 +64,9 @@ "autosw": { "default": "mdi:import" }, + "cec": { + "default": "mdi:remote-tv" + }, "cec0en": { "default": "mdi:remote-tv" }, @@ -102,6 +105,12 @@ }, "relay": { "default": "mdi:electric-switch" + }, + "tx0plus5": { + "default": "mdi:lightning-bolt" + }, + "tx1plus5": { + "default": "mdi:lightning-bolt" } } } diff --git a/homeassistant/components/hdfury/strings.json b/homeassistant/components/hdfury/strings.json index 336a1418d47..982c0d69ed5 100644 --- a/homeassistant/components/hdfury/strings.json +++ b/homeassistant/components/hdfury/strings.json @@ -121,6 +121,9 @@ "autosw": { "name": "Auto switch inputs" }, + "cec": { + "name": "CEC" + }, "cec0en": { "name": "CEC RX0" }, @@ -159,6 +162,12 @@ }, "relay": { "name": "Relay" + }, + "tx0plus5": { + "name": "TX0 force +5v" + }, + "tx1plus5": { + "name": "TX1 force +5v" } } }, diff --git a/homeassistant/components/hdfury/switch.py b/homeassistant/components/hdfury/switch.py index d28b51a23e8..30554cacb27 100644 --- a/homeassistant/components/hdfury/switch.py +++ b/homeassistant/components/hdfury/switch.py @@ -33,6 +33,12 @@ SWITCHES: tuple[HDFurySwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, set_value_fn=lambda client, value: client.set_auto_switch_inputs(value), ), + HDFurySwitchEntityDescription( + key="cec", + translation_key="cec", + entity_category=EntityCategory.CONFIG, + set_value_fn=lambda client, value: client.set_cec(value), + ), HDFurySwitchEntityDescription( key="cec0en", translation_key="cec0en", @@ -111,6 +117,20 @@ SWITCHES: tuple[HDFurySwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, set_value_fn=lambda client, value: client.set_relay(value), ), + HDFurySwitchEntityDescription( + key="tx0plus5", + translation_key="tx0plus5", + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + set_value_fn=lambda client, value: client.set_tx0_force_5v(value), + ), + HDFurySwitchEntityDescription( + key="tx1plus5", + translation_key="tx1plus5", + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + set_value_fn=lambda client, value: client.set_tx1_force_5v(value), + ), ) diff --git a/tests/components/hdfury/conftest.py b/tests/components/hdfury/conftest.py index 33ce4077db0..cf8c1b5308b 100644 --- a/tests/components/hdfury/conftest.py +++ b/tests/components/hdfury/conftest.py @@ -86,12 +86,15 @@ def mock_hdfury_client() -> Generator[AsyncMock]: ) coord_client.get_config = AsyncMock( return_value={ + "cec": "1", "cec0en": "1", "cec1en": "1", "cec2en": "1", "cec3en": "1", "autosw": "1", "iractive": "1", + "tx0plus5": "1", + "tx1plus5": "1", "htpcmode0": "0", "htpcmode1": "0", "htpcmode2": "0", diff --git a/tests/components/hdfury/snapshots/test_diagnostics.ambr b/tests/components/hdfury/snapshots/test_diagnostics.ambr index 4e62bbed9f9..d77ab9eccb5 100644 --- a/tests/components/hdfury/snapshots/test_diagnostics.ambr +++ b/tests/components/hdfury/snapshots/test_diagnostics.ambr @@ -10,6 +10,7 @@ }), 'config': dict({ 'autosw': '1', + 'cec': '1', 'cec0en': '1', 'cec1en': '1', 'cec2en': '1', @@ -24,6 +25,8 @@ 'mutetx1': '1', 'oled': '1', 'relay': '0', + 'tx0plus5': '1', + 'tx1plus5': '1', }), 'info': dict({ 'AUD0': 'bitstream 48kHz', diff --git a/tests/components/hdfury/snapshots/test_switch.ambr b/tests/components/hdfury/snapshots/test_switch.ambr index cf2899d1b4e..0000a844857 100644 --- a/tests/components/hdfury/snapshots/test_switch.ambr +++ b/tests/components/hdfury/snapshots/test_switch.ambr @@ -48,6 +48,55 @@ 'state': 'on', }) # --- +# name: test_switch_entities[switch.hdfury_vrroom_02_cec-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.hdfury_vrroom_02_cec', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'CEC', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'CEC', + 'platform': 'hdfury', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'cec', + 'unique_id': '000123456789_cec', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[switch.hdfury_vrroom_02_cec-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'HDFury VRROOM-02 CEC', + }), + 'context': , + 'entity_id': 'switch.hdfury_vrroom_02_cec', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_switch_entities[switch.hdfury_vrroom_02_cec_rx0-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -685,3 +734,101 @@ 'state': 'off', }) # --- +# name: test_switch_entities[switch.hdfury_vrroom_02_tx0_force_5v-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.hdfury_vrroom_02_tx0_force_5v', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'TX0 force +5v', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'TX0 force +5v', + 'platform': 'hdfury', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'tx0plus5', + 'unique_id': '000123456789_tx0plus5', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[switch.hdfury_vrroom_02_tx0_force_5v-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'HDFury VRROOM-02 TX0 force +5v', + }), + 'context': , + 'entity_id': 'switch.hdfury_vrroom_02_tx0_force_5v', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_switch_entities[switch.hdfury_vrroom_02_tx1_force_5v-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.hdfury_vrroom_02_tx1_force_5v', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'TX1 force +5v', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'TX1 force +5v', + 'platform': 'hdfury', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'tx1plus5', + 'unique_id': '000123456789_tx1plus5', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[switch.hdfury_vrroom_02_tx1_force_5v-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'HDFury VRROOM-02 TX1 force +5v', + }), + 'context': , + 'entity_id': 'switch.hdfury_vrroom_02_tx1_force_5v', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- diff --git a/tests/components/hdfury/test_switch.py b/tests/components/hdfury/test_switch.py index 96579d635b9..dad66cff54e 100644 --- a/tests/components/hdfury/test_switch.py +++ b/tests/components/hdfury/test_switch.py @@ -25,6 +25,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_switch_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, @@ -40,6 +41,8 @@ async def test_switch_entities( @pytest.mark.parametrize( ("entity_id", "method", "service"), [ + ("switch.hdfury_vrroom_02_cec", "set_cec", SERVICE_TURN_ON), + ("switch.hdfury_vrroom_02_cec", "set_cec", SERVICE_TURN_OFF), ( "switch.hdfury_vrroom_02_auto_switch_inputs", "set_auto_switch_inputs", @@ -52,8 +55,13 @@ async def test_switch_entities( ), ("switch.hdfury_vrroom_02_oled_display", "set_oled", SERVICE_TURN_ON), ("switch.hdfury_vrroom_02_oled_display", "set_oled", SERVICE_TURN_OFF), + ("switch.hdfury_vrroom_02_tx0_force_5v", "set_tx0_force_5v", SERVICE_TURN_ON), + ("switch.hdfury_vrroom_02_tx0_force_5v", "set_tx0_force_5v", SERVICE_TURN_OFF), + ("switch.hdfury_vrroom_02_tx1_force_5v", "set_tx1_force_5v", SERVICE_TURN_ON), + ("switch.hdfury_vrroom_02_tx1_force_5v", "set_tx1_force_5v", SERVICE_TURN_OFF), ], ) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_switch_turn_on_off( hass: HomeAssistant, mock_hdfury_client: AsyncMock,