mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Add HDFury CEC and 5v switches (#162988)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_cec',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_cec',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_tx0_force_5v',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_tx0_force_5v',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_tx1_force_5v',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'switch.hdfury_vrroom_02_tx1_force_5v',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user