Expose Zooz ZSE43 vibration sensor as vibration, not tampering (#181003)

This commit is contained in:
AlCalzone
2026-09-02 19:13:56 +02:00
committed by GitHub
parent 573f65a049
commit 34f617da9e
4 changed files with 1455 additions and 4 deletions
@@ -39,6 +39,7 @@ from homeassistant.helpers.issue_registry import (
async_delete_issue,
)
from homeassistant.helpers.start import async_at_started
from homeassistant.helpers.typing import UNDEFINED
from .const import DOMAIN
from .entity import NewZwaveDiscoveryInfo, ZWaveBaseEntity
@@ -684,10 +685,16 @@ class ZWaveNotificationBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
if description:
self.entity_description = description
# Entity class attributes
self._attr_name = self.generate_name(
alternate_value_name=self.info.primary_value.metadata.states[self.state_key]
)
# Notification sensors are named after their notification state. A
# description may set its own name to override that.
if not hasattr(self, "entity_description") or (
self.entity_description.name is UNDEFINED
):
self._attr_name = self.generate_name(
alternate_value_name=self.info.primary_value.metadata.states[
self.state_key
]
)
self._attr_unique_id = f"{self._attr_unique_id}.{self.state_key}"
@property
@@ -870,6 +877,33 @@ OPENING_STATE_NOTIFICATION_SCHEMA = ZWaveValueDiscoverySchema(
DISCOVERY_SCHEMAS: list[NewZWaveDiscoverySchema] = [
# Zooz ZSE43 Tilt/Shock Sensor. Its vibration sensor is reported
# through the Home Security "Cover status" notification, so expose
# that notification as a vibration sensor.
NewZWaveDiscoverySchema(
platform=Platform.BINARY_SENSOR,
manufacturer_id={0x027A},
product_id={0xE003},
product_type={0x7000},
primary_value=ZWaveValueDiscoverySchema(
command_class={CommandClass.NOTIFICATION},
property={"Home Security"},
property_key={"Cover status"},
type={ValueType.NUMBER},
any_available_states_keys={3},
any_available_cc_specific={
(CC_SPECIFIC_NOTIFICATION_TYPE, NotificationType.HOME_SECURITY)
},
),
entity_description=NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id 3 (product cover removed)
key=NOTIFICATION_HOME_SECURITY,
name="Vibration",
states={3},
device_class=BinarySensorDeviceClass.VIBRATION,
),
entity_class=ZWaveNotificationBinarySensor,
),
NewZWaveDiscoverySchema(
platform=Platform.BINARY_SENSOR,
primary_value=ZWaveValueDiscoverySchema(
+14
View File
@@ -517,6 +517,12 @@ def switch_zooz_zen72_state_fixture() -> dict[str, Any]:
return load_json_object_fixture("switch_zooz_zen72_state.json", DOMAIN)
@pytest.fixture(name="zooz_zse43_state", scope="package")
def zooz_zse43_state_fixture() -> dict[str, Any]:
"""Load the Zooz ZSE43 tilt/shock sensor node state fixture data."""
return load_json_object_fixture("zooz_zse43_state.json", DOMAIN)
@pytest.fixture(name="indicator_test_state", scope="package")
def indicator_test_state_fixture() -> dict[str, Any]:
"""Load the indicator CC test node state fixture data."""
@@ -1435,6 +1441,14 @@ def switch_zooz_zen72_fixture(client, switch_zooz_zen72_state) -> Node:
return node
@pytest.fixture(name="zooz_zse43")
def zooz_zse43_fixture(client: MagicMock, zooz_zse43_state: NodeDataType) -> Node:
"""Mock a Zooz ZSE43 tilt/shock sensor node."""
node = Node(client, copy.deepcopy(zooz_zse43_state))
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="indicator_test")
def indicator_test_fixture(client, indicator_test_state) -> Node:
"""Mock a indicator CC test node."""
File diff suppressed because it is too large Load Diff
@@ -18,6 +18,7 @@ from homeassistant.components.zwave_js.const import DOMAIN
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_FRIENDLY_NAME,
STATE_OFF,
STATE_ON,
STATE_UNKNOWN,
@@ -1706,3 +1707,23 @@ async def test_legacy_door_open_state_stale_repair_issue_cleaned_up(
)
is None
)
ZSE43_VIBRATION_SENSOR = "binary_sensor.tilt_shock_xs_sensor_vibration"
@pytest.mark.usefixtures("zooz_zse43", "integration")
async def test_zooz_zse43_vibration_sensor(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
) -> None:
"""Test the ZSE43 cover-removed notification is exposed as a vibration sensor."""
state = hass.states.get(ZSE43_VIBRATION_SENSOR)
assert state
assert state.attributes[ATTR_DEVICE_CLASS] == BinarySensorDeviceClass.VIBRATION
assert state.attributes[ATTR_FRIENDLY_NAME] == "Tilt Shock XS Sensor Vibration"
entity_entry = entity_registry.async_get(ZSE43_VIBRATION_SENSOR)
assert entity_entry
assert entity_entry.original_name == "Vibration"
assert entity_entry.entity_category is None