is it easily possible to trigger something when a device / sensor (any sensor) is unavailable? I found examples that require to check specific sensors but I’d like to keep it dynamic, without having to add / change something anytime I add something new.
You could use it in a template trigger. Not sure what your end goal is, but here is a whole topic discussing the difficulties around trying to do too much dynamically.
Basically, I just want to get a notification when something is unavailable, so I can fix it soonish to not loose too much data in the graphs and so forth. I have already setup some telegram notifications but I wasn’t able to properly do something like that by now
Hm, that returns 6 here in my case. Need to figure out how to get the names of those 6, or is it a ID?
I want something like “Sensor/Device xyz is unavailable”.
I actually slightly over-complicated the template, by including that map, to give you a hint. Play around with the template in the template editor in Developer Tools a bit and see what you can pull out.
A couple tips:
count is good for triggers. 0 evaluates to false, while any other number will evaluate to true.
Remove count and you should see a list of IDs. Replace entity_id with attributes.friendly_name to get a more readable name.
If trying to build a list of names, you can use the join filter. You can supply a separator, like join(', ').
Try it out for yourself, and feel free to post your attempt here if it doesn’t work out and I can give you a hand.
Hello, I know this thread has been silent for a long time. But I’ve used these examples to catch missing devices.
Once a day I publish a notification to my phone with this template:
service: notify.mobile_app_cph2449
data:
message: >-
There are {{ states.sensor | selectattr("state", "in", ["unavailable",
"unknown", "none"]) | map(attribute="entity_id") | list | count }} errors
with the following devices{{
states.sensor
| selectattr("state", "in", ["unavailable", "unknown", "none"])
| map(attribute="attributes.friendly_name")
| list
}}
It has helped me catch a few problems already. But it doesn’t catch one of my better-thermostat integration devices regularly becoming unavailable, thus failing to control my radiator. How can I catch that one too? Here’s the entity being unavailable: