Compare commits

...

21 Commits

Author SHA1 Message Date
Ludovic BOUÉ
1ff807cc18 Clean up test_binary_sensor.ambr by removing comments
Removed commented-out test cases for binary sensor entities.
2025-11-19 14:52:19 +01:00
Ludovic BOUÉ
f81cf51f74 Update mock_lock.json values for keys 1/257/4 and 1/257/5 2025-11-19 14:40:39 +01:00
Ludovic BOUÉ
d3c6bc41d4 Update test_sensor.ambr 2025-11-19 14:39:44 +01:00
Ludovic BOUÉ
7c46c36860 Update test_sensor.py 2025-11-19 14:39:11 +01:00
Ludovic BOUÉ
0815cc05ec Merge branch 'dev' into door_open_events 2025-11-19 12:53:08 +01:00
Ludovic BOUÉ
ffe5cc978c Rename 'door_opened_events' to 'door_open_events' 2025-11-17 19:28:34 +01:00
Ludovic BOUÉ
5156a7fe6d Update door_lock.json to remove unnecessary fields
Removed redundant values for door lock settings.
2025-11-17 19:09:02 +01:00
Ludovic BOUÉ
427f3692fd Add tests for optional door event sensors 2025-11-17 19:07:47 +01:00
Ludovic BOUÉ
3e5bf7bfd8 Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-17 16:57:34 +01:00
Ludovic BOUÉ
0b8afb8d7e Disable entity registry for door lock events 2025-11-17 16:57:18 +01:00
Ludovic BOUÉ
86df75bb51 Update snapshot 2025-11-14 08:35:15 +00:00
Ludovic BOUÉ
0d94bae6ea Update snapshot 2025-11-14 08:23:32 +00:00
Ludovic BOUÉ
36f54b2e5b Change value of '1/257/65532' in door_lock.json
Updated the value for key '1/257/65532' from 0 to 32.
2025-11-14 09:22:18 +01:00
Ludovic BOUÉ
fcc7e58671 Merge remote-tracking branch 'refs/remotes/origin/door_open_events' into door_open_events 2025-11-14 08:15:51 +00:00
Ludovic BOUÉ
94ce966e1e Refactor door lock event translation keys for consistency 2025-11-14 08:14:09 +00:00
Ludovic BOUÉ
6a7ea639ce Update sensor.py 2025-11-14 08:32:03 +01:00
Ludovic BOUÉ
483e8a1497 Total increasing 2025-11-14 08:31:05 +01:00
Ludovic BOUÉ
5a0b0c2f8f Merge branch 'dev' into door_open_events 2025-11-13 21:07:01 +01:00
Ludovic BOUÉ
d472b079cb Add additional attributes for door lock configuration 2025-11-04 20:14:16 +00:00
Ludovic BOUÉ
2dc4d9e8ec Add icons for door lock open and closed events 2025-11-04 20:07:03 +00:00
Ludovic BOUÉ
1dc902c413 Add Matter sensor support for door lock open and closed events 2025-11-04 19:51:03 +00:00
6 changed files with 177 additions and 2 deletions

View File

@@ -86,6 +86,12 @@
"current_phase": {
"default": "mdi:state-machine"
},
"door_lock_door_closed_events": {
"default": "mdi:door-closed"
},
"door_lock_door_opened_events": {
"default": "mdi:door-open"
},
"esa_opt_out_state": {
"default": "mdi:home-lightning-bolt"
},

View File

@@ -1488,4 +1488,30 @@ DISCOVERY_SCHEMAS = [
entity_class=MatterSensor,
required_attributes=(clusters.ServiceArea.Attributes.EstimatedEndTime,),
),
MatterDiscoverySchema(
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="DoorLockDoorOpenEvents",
translation_key="door_open_events",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
state_class=SensorStateClass.TOTAL_INCREASING,
),
entity_class=MatterSensor,
required_attributes=(clusters.DoorLock.Attributes.DoorOpenEvents,),
featuremap_contains=clusters.DoorLock.Bitmaps.Feature.kDoorPositionSensor,
),
MatterDiscoverySchema(
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="DoorLockDoorClosedEvents",
translation_key="door_closed_events",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
state_class=SensorStateClass.TOTAL_INCREASING,
),
entity_class=MatterSensor,
required_attributes=(clusters.DoorLock.Attributes.DoorClosedEvents,),
featuremap_contains=clusters.DoorLock.Bitmaps.Feature.kDoorPositionSensor,
),
]

View File

@@ -365,6 +365,12 @@
"current_phase": {
"name": "Current phase"
},
"door_closed_events": {
"name": "Door closed events"
},
"door_open_events": {
"name": "Door open events"
},
"energy_exported": {
"name": "Energy exported"
},

View File

@@ -421,8 +421,8 @@
"1/257/1": 0,
"1/257/2": true,
"1/257/3": 1,
"1/257/4": 10,
"1/257/5": 10,
"1/257/4": 5,
"1/257/5": 3,
"1/257/17": 10,
"1/257/18": 10,
"1/257/19": 10,

View File

@@ -7259,6 +7259,108 @@
'state': 'stopped',
})
# ---
# name: test_sensors[mock_lock][sensor.mock_lock_door_closed_events-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.mock_lock_door_closed_events',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Door closed events',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'door_closed_events',
'unique_id': '00000000000004D2-0000000000000097-MatterNodeDevice-1-DoorLockDoorClosedEvents-257-5',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[mock_lock][sensor.mock_lock_door_closed_events-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mock Lock Door closed events',
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'context': <ANY>,
'entity_id': 'sensor.mock_lock_door_closed_events',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '3',
})
# ---
# name: test_sensors[mock_lock][sensor.mock_lock_door_open_events-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.mock_lock_door_open_events',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Door open events',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'door_open_events',
'unique_id': '00000000000004D2-0000000000000097-MatterNodeDevice-1-DoorLockDoorOpenEvents-257-4',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[mock_lock][sensor.mock_lock_door_open_events-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mock Lock Door open events',
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'context': <ANY>,
'entity_id': 'sensor.mock_lock_door_open_events',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '5',
})
# ---
# name: test_sensors[multi_endpoint_light][sensor.inovelli_current_switch_position_config-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -697,3 +697,38 @@ async def test_vacuum_operational_error_sensor(
state = hass.states.get("sensor.mock_vacuum_operational_error")
assert state
assert state.state == "unknown"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize("node_fixture", ["mock_lock"])
async def test_optional_door_event_sensors_from_featuremap(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test discovery of optional door event sensors in doorlock featuremap."""
entity_id_open = "sensor.mock_lock_door_open_events"
entity_id_closed = "sensor.mock_lock_door_closed_events"
# Check that the entities are created
state = hass.states.get(entity_id_open)
assert state
assert state.state == "5"
state = hass.states.get(entity_id_closed)
assert state
assert state.state == "3"
# Test updating the sensor values
set_node_attribute(matter_node, 1, 257, 4, 10)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id_open)
assert state
assert state.state == "10"
set_node_attribute(matter_node, 1, 257, 5, 8)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id_closed)
assert state
assert state.state == "8"