Detect when Zigbee bulb goes unavailable

Hi,

I have e Zigbee bulb that is behind a lightswitch. I had the idea for an automation: when I switch off the light, the state change to “unavailable” would trigger an automation to turn off some other bulbs, that are not behind a lightswitch.

However, it turns out that state change actually happens long after I switch off the light. Is there a way to make ZHA detect this faster?

No. By definition, when a zigbee device lose power, it cannot report anything.
The only setting here, is the time before ZHA consider a device unavailable

image

Would be cool that some manufacturer include a big enough capacitor so that a “last will” message could be sent, though, if that makes sense electrically.

Thanks, that’s very helpful! I understand a device cannot send a message once power is cut off. (Although your capacitor/last will idea is really cool!) But I figured the way a device is marked unavailable should be based on some timeout. Glad that you pointed me right to that. I’ve changed mine from 7200 to 5 seconds. Let’s see how that works out.

Been there, done that :smiley:

A zigbee device doesn’t report every 5sec mind you. Your devices will be continuously unavailable.
That’s the reason for the conservative 1800.

Ah, didn’t know that. Do you happen to know what the report frequency is?

I had a similar scenario as yours.
I’ve set it to 60 seconds, and so far so good, as long as I accept the delay of up to a minute.
My use case was similar. Next to my bed I have an electrical switch to turn off one light in my bedroom, but I have a second one, which is only managed from a switch next to the door. So I would set up an automation so that when HA detects as unavailble the ‘bed light’, the ‘door light’ would turn off.

Mind that sometimes (it has gotten better) detecting turning on might have some delay as well, depending on how complete you want your use-case.

I use uptime kuma to monitor zigbee devices avability using mqtt payload. If a device is offline ha sends me a message on my telegram account.
I use this for a quit some time and this is working flavesly.

What does that mean, practically?
To what do you send what MQTT message to assess a zigbee device availability?

Maybe my bed not payload.

It monitors mqtt avability topic. If devices is unavailable for 60 seconds it sends message. For some I had to put longer period to avoid false reports.

That’s probably useful for you, but this is about reducing the time before the device becomes unavailable :wink:
You’re just adding 60 seconds to that period through kuma…

Well this works for me as I want it to work. Whenever I check this device is really offline. Sometimes it does send me report that device is offline but it isn’t. That’s why for some I extended this period.
What I found out while monitoring this is that even battery powered devices can became available on its own. Didn’t know that.
Usually light switches became unavailable and then available probably due rerouting.

Could you share your uptime kuma monitor settings? Thanks up front!

This is question for me?
There isnt much to it. Just set up mqtt monitor settings, fill in username password and use topic accordingly ie. zigbee2mqtt/Android TV led strip/availability.
And set up notification as you wish. I set up notification using telegram. And that is it.

Tnx Daniel, yes it was q to you :grinning:
It helped me in the end. My problem was setting in kuma monitor:
MQTT Success Message
{“state”:“online”}

I just put online and it works.

  • Active devices (routers or mains powered end devices): by default they have to check-in every 10 minutes. If they don’t, they will be pinged, if that fails the device will be marked as offline.
  • Passive devices (everything that is not an active device, mostly battery powered devices): these devices need to check-in every 25 hours, they cannot be pinged so if they don’t they will be marked as offline.