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.