I am using zigbee2mqtt on my HA to control my zigbee network that my SLZB-06P7 broadcasts. I see there is a map option which shows all your zigbee devices as connected and shows those that are offline. Is there a way to monitor them automatically? I mean, since I see that you can detect which devices are offline and which are not, is there a way for HA to send us a notification when there is an offline device?
I leave an image of my map where we can see 2 offline devices:
Hmm you can work with the last seen entity (it‘s deactivated). If the time not changing last x hours, send a notification. This is how I would try it out.
But keep in mind the map is only a snapshot. The Sensors are not online all the time and they are only send the state when it changes. Unless, of course, the batteries are really empty.
Both Zigbee integrations have configurable timeout settings in the UI to report a device as unavailable.
Router and end devices have different timeouts for both, so eg. a router device will be reported as unavailable after a couple of hours, but an end device will only report as such after a day or 2 (depending on the integration defaults).
Be extremely careful not to set the threshold too low, especially for end devices, since that might lead to false alarms when the device is just sleeping.
Either way, if you wanted to implement an automation for unavailable devices, it should be pretty straightforward. Here’s on I use for a misbehaving integration:
trigger:
- platform: state
entity_id:
- your.entity.ids #(add more entities as separate list items)
to: unavailable
for:
hours: 0
minutes: 15
seconds: 0
condition: []
action:
- service: whatever
mode: single
I already had found those possibilities in the Z2M docs.
I’m also aware of those differences.
I have an Ikea rotary remote that has stopped functioning and I’m trying to find out what has happened.
The battery level has been reported as 47%.
I wonder if, and where, it’s showing that a device is offline/disconnected because I haven’t found this in Z2M.
Thanks for the example for an automation, unfortunately this remote doesn’t seem to have the option to detect it’s current state but I’m giving this example a try with a door contact.
That’s not a guarantee. Zigbee devices sometimes fall off for personal reasons of their own. If operation of a device is critical (eg we use zigbee devices to monitor and power a medical chiller) then double monitoring by devices belonging to two brands and a daily power-on is programmed with before and after monitoring to ensure the power on resulted in a temperature drop etc and notification of result.
Otherwise yes I agree making sure your network is as healthy as possible alleviates most problems.
It should also publish an MQTT message on zigbee2mqtt//availability when it’s offline (after the defined timeout has passed), so you should also be able to use that
So I found the reason why I couldn’t tell whether my devices are on-/offline: the settings in the UI for availability was not checked at all.
The default Availability (simple) was showing in the pull-down menu and I assumed that this setting was active.
For the fact that the column Availability was populated with Disabled didn’t ring a bell…
So now by checking Availability (simple) things are looking better and apparently now the default settings that I have read about in the Z2M docs are at work, so some devices still are showing offline since they have not been polled (or whatever you call that)
Note that if you enable Availability (advanced) you’ll be able to configure timeout settings for battery & powered devices instead of relying on the defaults
I use z2m, where do I find the value of the hours that an end device must be without reporting data to be marked as inactive? Here? what values do you recommend?
I have activated the availability in advanced mode with the default values and indeed, I have added a column that informs me about the status of the devices. I have 5 devices and only one of them without battery. The information is correct:
It’s in the picture you posted, right under “Opciones para dispositivos pasivos”, but I guess you figured it out already judging by the post you made an hour later.
I can’t recommend anything except for the following:
For any type of device, don’t set the Timeout too low or you’ll risk flooding your zigbee network with “heartbeat” messages
For battery devices, it is important that you set your timeout to a higher value, maybe once (1440 minutes) or twice (720 minutes) a day to minimise battery drain.
No, the fact that you’re looking at the Z2m settings and not the device settings should make that quite obvious.
Probably not, since this is general config which only distinguishes between routers & end devices. Most of the device pages in Z2M will say the following for Linkquality, which is the only common entity exposed:
" It’s not possible to read (/get ) or write (/set ) this value."
But I still have a concern. Is there a way to know how many restarts the watchman makes throughout the day or something like that… I’m worried that the service becomes unstable, and restarts several times a day and I don’t know about it… if it restarts once a month is not worrying, but if it does it once every hour, how could I know about it?
First things first. Please hit the Reply button underneath the post itself (not the blue one) when you’re replying to someone, otherwise they won’t get notified of your reply.
To answer your question - do you actually think your zigbee instance is restarting frequently? A look at the logs should tell you. If you have Samba installed, it’s quite easy to see how many times Zigbee restarted in a particular period, since each restart creates a new log (all those entries from 2024-05-08 with the same timestamp are from when I had an issue with Z2M and the watchdog kept restarting it, for example):
If you really want to be fancy, you could set up a counter helper, then an automation to increment the counter every time Z2M isn’t running. Check out the entities you have for Z2M - I have binary_sensor.zigbee2mqtt_running which I use for a similar purpose. If it’s off, then Z2M is restarting.
EDIT: With that binary sensor, you don’t even need uptime kuma. You can check its history just like any other sensor and you’ll know how long Z2m has been running for.
Thank you very much for your advice, I didn’t know about samba but it forces me to look at that folder continuously. Normally my zigbee is very stable and it goes days without restarting z2m but the moment it becomes unstable I will not know because I will not enter every day to the samba log.
I think it would be better if the HA itself would be the one to warn… for example every time z2m starts sending a notification or something like that… if suddenly one day I see 25 emails warning of the reboots I know that something is failing. how do you see it?
maybe putting a linked automatism in the Zigbee2MQTT Bridge Connection state entity that every time it goes to the disconnected state, it will warn… or to check that it is always in the connected state…
I have tested this automatism and it works fine! If the z2m restarts, please let me know.
I believe that for the zigbee network to work, z2m and mosquitto broker must work. Now if z2m restarts it already warns me but I see no way to get a similar warning with mosquitto broker. I don’t see that it has entities for its status monitoring. any idea or advice?