1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-26 10:15:33 +01:00

Add child lock entity for Eve Matter devices (#169391)

This commit is contained in:
Ludovic BOUÉ
2026-04-28 19:55:37 +02:00
committed by GitHub
parent 86e8b9df9b
commit d62f136c58
3 changed files with 262 additions and 0 deletions
+10
View File
@@ -316,4 +316,14 @@ DISCOVERY_SCHEMAS = [
value_contains=clusters.EnergyEvse.Commands.EnableCharging.command_id,
allow_multi=True,
),
MatterDiscoverySchema(
platform=Platform.SWITCH,
entity_description=MatterNumericSwitchEntityDescription(
key="EveChildLock",
entity_category=EntityCategory.CONFIG,
translation_key="child_lock",
),
entity_class=MatterNumericSwitch,
required_attributes=(clusters.EveCluster.Attributes.ChildLock,),
),
]
@@ -1,4 +1,54 @@
# serializer version: 1
# name: test_switches[eve_energy_20ecn4101][switch.eve_energy_20ecn4101_child_lock_top-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'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.eve_energy_20ecn4101_child_lock_top',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Child lock (top)',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock (top)',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '00000000000004D2-00000000000000C7-MatterNodeDevice-1-EveChildLock-319486977-319422481',
'unit_of_measurement': None,
})
# ---
# name: test_switches[eve_energy_20ecn4101][switch.eve_energy_20ecn4101_child_lock_top-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Eve Energy 20ECN4101 Child lock (top)',
}),
'context': <ANY>,
'entity_id': 'switch.eve_energy_20ecn4101_child_lock_top',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switches[eve_energy_20ecn4101][switch.eve_energy_20ecn4101_switch_bottom-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
@@ -152,6 +202,56 @@
'state': 'off',
})
# ---
# name: test_switches[eve_energy_plug][switch.eve_energy_plug_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'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.eve_energy_plug_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Child lock',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '00000000000004D2-000000000000003D-MatterNodeDevice-1-EveChildLock-319486977-319422481',
'unit_of_measurement': None,
})
# ---
# name: test_switches[eve_energy_plug][switch.eve_energy_plug_child_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Eve Energy Plug Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.eve_energy_plug_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switches[eve_energy_plug_patched][switch.eve_energy_plug_patched-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
@@ -203,6 +303,106 @@
'state': 'off',
})
# ---
# name: test_switches[eve_energy_plug_patched][switch.eve_energy_plug_patched_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'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.eve_energy_plug_patched_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Child lock',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '00000000000004D2-00000000000000B7-MatterNodeDevice-1-EveChildLock-319486977-319422481',
'unit_of_measurement': None,
})
# ---
# name: test_switches[eve_energy_plug_patched][switch.eve_energy_plug_patched_child_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Eve Energy Plug Patched Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.eve_energy_plug_patched_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switches[eve_shutter][switch.eve_shutter_switch_20eci1701_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'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.eve_shutter_switch_20eci1701_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Child lock',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '00000000000004D2-0000000000000094-MatterNodeDevice-1-EveChildLock-319486977-319422481',
'unit_of_measurement': None,
})
# ---
# name: test_switches[eve_shutter][switch.eve_shutter_switch_20eci1701_child_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Eve Shutter Switch 20ECI1701 Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.eve_shutter_switch_20eci1701_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switches[eve_thermo_v4][switch.eve_thermo_20ebp1701_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
+52
View File
@@ -285,3 +285,55 @@ async def test_speaker_mute_uses_onoff_commands(
state = hass.states.get("switch.mock_speaker_mute")
assert state
assert state.state == "off"
@pytest.mark.parametrize("node_fixture", ["eve_energy_plug"])
async def test_eve_child_lock(
hass: HomeAssistant,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test the Eve child lock switch entity."""
state = hass.states.get("switch.eve_energy_plug_child_lock")
assert state
assert state.state == "off"
# test attribute changes
set_node_attribute(matter_node, 1, 319486977, 319422481, True)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("switch.eve_energy_plug_child_lock")
assert state.state == "on"
set_node_attribute(matter_node, 1, 319486977, 319422481, False)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("switch.eve_energy_plug_child_lock")
assert state.state == "off"
# test switch service
await hass.services.async_call(
"switch",
"turn_on",
{"entity_id": "switch.eve_energy_plug_child_lock"},
blocking=True,
)
assert matter_client.write_attribute.call_count == 1
assert matter_client.write_attribute.call_args_list[0] == call(
node_id=matter_node.node_id,
attribute_path=create_attribute_path_from_attribute(
endpoint_id=1,
attribute=clusters.EveCluster.Attributes.ChildLock,
),
value=True,
)
await hass.services.async_call(
"switch",
"turn_off",
{"entity_id": "switch.eve_energy_plug_child_lock"},
blocking=True,
)
assert matter_client.write_attribute.call_count == 2
assert matter_client.write_attribute.call_args_list[1] == call(
node_id=matter_node.node_id,
attribute_path=create_attribute_path_from_attribute(
endpoint_id=1,
attribute=clusters.EveCluster.Attributes.ChildLock,
),
value=False,
)