question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper way to implement other ZHA `IasZone.ZoneStatus` than alarm?

See original GitHub issue

The problem

There are several Zigbee devices that provide the tamper and battery status for the IasZone cluster. I have work in some quirks that have the attribute, but I’m not sure which way would be the proper one to expose that info in HA.

One way would be to quirk a IasZone cluster for every attribute. This would require expanding the CLASS_MAPPING with new classes (tamper, battery…): https://github.com/home-assistant/core/blob/4c7837a5762a741100b07d89803340f53b1d04b1/homeassistant/components/zha/binary_sensor.py#L29-L36 But also the IasZone.ZoneType beyond the standar: https://github.com/zigpy/zigpy/blob/b94cfe12903b21ed146e556c1e514e2abc16611f/zigpy/zcl/clusters/security.py#L22-L39 Doesn’t seem to me the way to go…

Other approach could be to add support in HA for other IasZone.ZoneStatus than Alarm_1 and Alarm_2: https://github.com/home-assistant/core/blob/4c7837a5762a741100b07d89803340f53b1d04b1/homeassistant/components/zha/binary_sensor.py#L168-L173 But this would require a full refactor of the IasZone sensor. In fact, it should stop being a binary_sensor to support multiple ‘states’, which may also involve modification at the HA frontend level (this part is not clear to me). In my opinion, this would be the solution that best fits the nature of the IasZone cluster, but I am not sure if it is the way to go either.

Any suggestion or comment about it?

What version of Home Assistant Core has the issue?

core-2022.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
puddlycommented, Jul 1, 2022

I think I only seen Centralite motion sensor reporting the tamper and have no idea what triggers it or how to reset it.

I had a Bosch sensor that flipped the “tamper” bit when you slid it off its battery cover/mounting plate. I agree though, globally enabling these entities when 95% of deployed motion sensors don’t support them will just create clutter and unnecessary issues.

If we use multi match and add the models?

Having to update both ZHA and quirks in parallel will make contributing new quirks even more difficult than it currently is.

Perhaps we should start extending existing quirks with information about what capabilities a device supports? Or even draft a more general system that separates allowed device actions and state from the restrictive ZCL cluster/endpoint framework?

1reaction
arnemauercommented, Jul 1, 2022

@Adminiuga it is possible but not as easy as a binary sensor. Another problem with attributes is that you can’t see the history in the core history graph as easy as a standard sensor.

Is it possible to use multiple classes with one channel, e.g. IASZoneTamperSensor? Then every “extra” sensor can be activated by adding the model name.

@MULTI_MATCH(channel_names=CHANNEL_ZONE)
class IASZone(BinarySensor):
    """ZHA IAS BinarySensor."""

    SENSOR_ATTR = "zone_status_alarm1"

    @property
    def device_class(self) -> str:
        """Return device class from component DEVICE_CLASSES."""
        return CLASS_MAPPING.get(self._channel.cluster.get("zone_type"))

    async def async_update(self):
        """Attempt to retrieve on off state from the binary sensor."""
        await super().async_update()
        value = await self._channel.get_attribute_value("zone_status")
        if value is not None:
            self._state = value & 3


@MULTI_MATCH(
    channel_names=CHANNEL_ZONE,
    manufacturers={
        "_TZ1800_ejwkn2h2",
    },
)
class IASZoneTamperSensor(BinarySensor):
    """ZHA IAS BinarySensor."""

    SENSOR_ATTR = "zone_status_tamper"

    @property
    def device_class(self) -> str:
        """Return device class from component DEVICE_CLASSES."""
        return CLASS_MAPPING.get(self._channel.cluster.get("zone_type"))

    async def async_update(self):
        """Attempt to retrieve on off state from the binary sensor."""
        await super().async_update()
        value = await self._channel.get_attribute_value("zone_status")
        if value is not None:
            self._state = value & 4
Read more comments on GitHub >

github_iconTop Results From Across the Web

Zha.core.channels.base, async_initialize: all attempts have ...
I've identified one zigbee plug that has stopped being recognized (16 other zigbee devices seem OK). Tried multiple restarts, didn't help. 2021- ...
Read more >
IAS Zone: Zone Status Change Notification the Zone ... - TI E2E
What's meaning?Now I don't know how to implement.If I implemented this status change.How can I do to implement that Press one key can...
Read more >
ZigBee Cluster Library Specification
IN NO EVENT WILL ZIGBEE BE LIABLE FOR ANY LOSS OF. PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS,...
Read more >
Set Up ZHA in Home Assistant - TUTORIAL - YouTube
The other videos are about how to set up Zigbee integration using ... See the list of Smart Home devices that I use...
Read more >
IAS Zone device enroll steps - zigbee - Stack Overflow
You can then confirm that end device in enrolled by issuing Read Request on cluster 0x0500 , attribute 0x0000 (ZoneState).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found