Use glass break device class in Z-Wave JS (#182243)

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Jonas Petersson
2026-09-19 09:50:22 +02:00
committed by GitHub
co-authored by Codex
parent 54daa0f907
commit 76920130f8
2 changed files with 47 additions and 1 deletions
@@ -300,7 +300,7 @@ NOTIFICATION_SENSOR_MAPPINGS: tuple[NotificationZWaveJSEntityDescription, ...] =
# NotificationType 7: Home Security - State Id's 5, 6 (glass breakage)
key=NOTIFICATION_HOME_SECURITY,
states={5, 6},
device_class=BinarySensorDeviceClass.SAFETY,
device_class=BinarySensorDeviceClass.GLASS_BREAK,
),
NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id's 7, 8 (motion)
@@ -152,6 +152,25 @@ def _add_lock_state_notification_states(node_state: dict[str, Any]) -> dict[str,
return updated_state
def _add_glass_break_notification_states(
node_state: dict[str, Any],
) -> dict[str, Any]:
"""Return a node state with Home Security glass break notification states."""
updated_state = copy.deepcopy(node_state)
for value_data in updated_state["values"]:
if (
value_data.get("commandClass") == 113
and value_data.get("property") == "Home Security"
):
value_data["metadata"]["states"] = {
"0": "idle",
"5": "Glass breakage detected (location provided)",
"6": "Glass breakage detected",
}
break
return updated_state
def _set_opening_state_metadata_states(
node_state: dict[str, Any], states: dict[str, str]
) -> dict[str, Any]:
@@ -330,6 +349,33 @@ async def test_notification_sensor(
assert entity_entry.entity_category is EntityCategory.DIAGNOSTIC
async def test_glass_break_notification_sensor(
hass: HomeAssistant,
client: MagicMock,
lock_schlage_be469_state: NodeDataType,
) -> None:
"""Test the glass break notification sensor device class."""
node = Node(
client,
_add_glass_break_notification_states(lock_schlage_be469_state),
)
client.driver.controller.nodes[node.node_id] = node
entry = MockConfigEntry(domain=DOMAIN, data={"url": "ws://test.org"})
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
glass_break_states = [
state
for state in hass.states.async_all(BINARY_SENSOR_DOMAIN)
if state.attributes.get(ATTR_DEVICE_CLASS)
== BinarySensorDeviceClass.GLASS_BREAK
]
assert len(glass_break_states) == 2
assert all(state.state == STATE_OFF for state in glass_break_states)
@pytest.mark.parametrize(
("entity_id", "device_class"),
[