Hi there,
just wondered how I could be noticed on errors in zigbee2mqtt? I have messages qualified as “error” in the zigbee2mqtt logs, but I haven’t been able to find a way to get notified on such errors. The zigbee related devices only offer more general triggers on “update availability”, “permit join turned on” and so on.
How could I trigger an automation for notifying me when a zigbee error is logged? There might be issues with too many triggers occuring, but this could be handled somehow within the automation. Currently, I have to manually open the logs and see if anything happend
Take a look at what Z2M is publishing to the zigbee2mqtt/bridge/# topic. If the kinds of messages you care about are going there, you can use an MQTT trigger to build an HA automation.
Zigbee2MQTT is a separate thing from Home Assistant. Zigbee2MQTT interfaces with Zigbee devices via your Zigbee adapter and then passes along the messages they send on the Zigbee network via MQTT, which is a messaging protocol. Home Assistant listens to these MQTT messages and that’s how it knows what devices are connected and what they’re doing.
So there is no direct way to trigger a Home Assistant automation based on what Z2M is putting in its logs, because Zigbee2MQTT isn’t “part of” Home Assistant the way integrations are.
But Z2M sends along a lot of status and error messages via MQTT on the topic I mentioned, zigbee2mqtt/bridge/#, and HA gives you an MQTT trigger. So if the kinds of Z2M updates you’re interested it appear on that topic, then you can use the MQTT trigger (correctly set up to trigger on the kinds of messages you care about). Otherwise if you’re really committed to this you’re going to have to set up some way to monitor the logs and get that information into HA, which hardly seems worth it.
You can listen to MQTT messages using an MQTT client like mosquitto_sub. You should also be able to listen to them via Home Assistant’s front-end; go to the MQTT integration, click the gear icon next to the host IP (probably 127.0.0.1, but not necessarily), under “Listen to a topic” put in the topic, and then hit “Start listening”:
EDIT: All of the above is probably going to be necessary for you to know, but having taken a closer look at the way the logs and messages are structured, you might be able to use this trigger as a starting point:
With all due respect, what you’re describing sounds to me like an XY problem.
Rather than being spammed with notifications whenever this happens, wouldn’t you rather fix the error?
You don’t provide much details like what specific device is causing this or how long this error has been triggering. However, based on the error you posted, the fix might be as simple as unbinding the polling cluster from your device. Just make sure to wake it up by pressing the button immediately before pressing unbind.
Read here for more details Tuya TS0203 Handling of poll check-in failed · Issue #24938 · Koenkk/zigbee2mqtt · GitHub
@d921, thank you very much for your patience and the time you took to answer my noob question in such a comprehensive way Everything is so well integrated with HA that I didn’t realize how z2m is an addon and maybe not as integrated as it looks by appearing as a tab in the HA web interface…
Listening via frontend works well, and from what I saw there I understand your trigger will do just what I want - it would have taken me hours to figure that one out (I didn’t find the MQTT trigger with my first automation experiments on that issue…). Thank you!!
@ShadowFist, you’re right pointing this out. In my case, however, it is really about “getting notified that something doesn’t work as expected”.
Of course I tackled and (hopefully) fixed the error when I saw it (by deleting and re-adding the devices to the network). But for the next time, I want to be warned before my family complains that the heating behaved strange for the last couple of days