I have a bunch of Aqara Sensors that become unavailable from time to time. They are connected with Zigbee2MQTT. Unfortunately these entities don’t have a state “unavailable” which could be checked in an automation. Only in the Zigbee2MQTT list of devices they do show “offline” but only after about a day later after having removed the battery (e.g. provoked unavailability). All other entities keep their last value.
So I had the idea to check the last_seen attribute. If it is longer than a day since the device was last seen, I conclude it must be unavailable.
My questions are now:
- is there an easier way to check the availability of those sensors, especially at an earlier time
- when using the above method could this be formulated in a more efficient manner with a list, because otherwise I need to define separate triggers for each sensor
- I would like to send a notifier to my phone like “Sensor <sensor_name> is unavailable” without having if…then for each sensor. In other words: is the name of the triggering sensor available as a variable? (template.trigger_id doesn’t do the job)