Trying to figure out how to send a notification to my phone whenever a Zigbee device drops of the network with the device its name.
I have enabled the availability setting in Zigbee2MQTT.
In the automation the trigger would be:
So that any device that goes offline will trigger the automation. Now is there a way to get the friendly name to appear in the notifcation or is node-red a better option for this?
Found this: Automation Trigger Variables - Home Assistant
And using the example was able to make this automation. Gonna refine it a bit to just include the sensors instead of all the Zigbee devices.
Thanks for this! Nice and simple. One thing to note, I do not have “Legacy mode” enabled in my zigbee2mqtt instance. This means that my payloads are in json format, and for me, offline needed to be changed to {“state”:“offline”} to trigger properly. So if you have legacy mode enabled, then the code posted should work as is. If you don’t have legacy mode enabled, then you need to adjust the trigger payload value.
I added the {“state”:“offline”} and it keeps giving me a error of “Message malformed: template value should be a string for dictionary value @ data[‘payload’]”
@IBot07 I ran into a similar issue, thought it was just me doing something stupid. I ended up doing it in the visual editor. Picture attached, after that I switched to the yaml view and the formatting is weird, but it does work. Screenshot of ui attached and then the resulting yaml code. I have a binary switch that turns on when ha is shutdown or rebooted, and then waits 30 seconds after ha is completely back up before turning back off. I check this switch for any automation that might be falsely triggered during a reboot if an integration or device takes a bit to be available for instance. That’s what switch.ha_shutdown_switch is.
this works well people, thanks.
I am wondering if there is a way to prevent spamming these notifications to me?
Be notified when a device goes offline, without hearing it every minute?
I could make a simple wait, but then i would miss if other devices go offline.
yesterday i tried the automation above and got notified every 30s about the same device (power outlet plug of the brand frient). maybe it was being found and went offline again every few seconds, i dont know.
also when manually listening to zigbee2mqtt/+/availability for {“state”:“offline”} i saw that the device was getting spammed there.
It seems i am incorrect that it only triggers once. Using the topic to listen i see multiple online or offline messages form the same devices. Not all tho.
This might be a Z2M setting, in settings i have a 20 minute timeout and for battery devices a 90 minute timeout. So i never get spammed.