Can anyone comment on if labels could now be used to tag specific entities as “critical” and then have an automation to notify me if any critical sensor goes offline for more than 15 minutes?
Then when I get a new device I can just label one of the entities as “critical” to include it…
This is my automation so far but I’d like to make it more dynamic.
platform: state
entity_id:
- sensor.ibs_th2_p01b_09a6_temperature
- sensor.ibs_th2_p01b_06c1_temperature
- sensor.ibs_th2_p01b_15b8_temperature
- sensor.ibs_th2_p01b_17f6_temperature
- switch.athom_plug_v2_04
- sensor.esphome_07_temperature
to:
- unknown
- unavailable
for:
hours: 0
minutes: 30
seconds: 0
id: not available
You can use a template trigger, but that will only work for the first sensor to go offline for 15 minutes. It won’t alert you again if a second sensor goes offline.
If you want to have it trigger on every sensor, you need to create a template sensor with a count of the sensors which are unavailable, and then use that template sensor in a state trigger.
{{
trigger.event.data.old_state.state not in [‘unavailable’, ‘unknown’, ‘none’, ‘off’]
and
trigger.event.data.new_state.state in [‘unavailable’, ‘unknown’, ‘none’, ‘off’]
}}
Add your wanted actions
The BIG down size to this, is that the automation listens on all state_changed events. Feels like a lot of computation that is not really required.
The workaround mentioned above by TheFes is still the way to do this. Create a template sensor whose state is driven by those labeled entities, then in your automation use a state trigger based off that template sensor.