I would like to be able to send a notification when I encounter certain errors under zigbee2mqtt.
The error logs do not contain a payload, so I don’t see how to trap the right logs.
ex: I would like to trap all messages with “Failed to ping” in the message.
I would hope there would be a cleaner way to monitor the Zigbee2MQTT log, hope someone has a smarter answer…
Two ideas come to mind. A bit hill billy tech… however if you change Zigbee2MQTT’s default log file naming to something simpler, for example “zigbee2mqtt-data/log/log.txt”, then you could launch the following command from some type of systemd or tmux on the host of your zigbee2mqtt service:
or if you want to do it a bit cleaner, you could set Zigbee2MQTT to additionally send it’s log entries to a syslog server (in 1st link above) and then modify this small python routine (link below) to receive the log entries and send them to MQTT.
In either path, you could do some filtering prior to publishing to MQTT.
Then you can do a Home Assistant automation on received MQTT message in the topic you are publishing log entries to.
warn 20231103-092220: Failed to ping '0x00124b001ccc6801' (attempt 1/1, Read 0x00124b001ccc6801/1 genBasic(["zclVersion"], {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":true,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Data request failed with error: 'No network route' (205)))
debug 20231103-092223: Active device '0x00124b001ccc6801' was last seen '17116.68' minutes ago.