I would like to have a notification if any of my shelly devices gets an over temperature and/or over power warning, what is the best way to do that? Having to write an automation for each individual device is a bit annoying since I have 39 already and plan to add quite a few more.
It has an issue that my be important to you. It will not trigger again until none of these sensors are on and one (or more) then turns on. So for example if you already have one over_temp or over_power on and another turns on, it will not trigger this second (or subsequent) time(s). Iâm still trying to think of a way around this. You might have to make a template sensor and use a state trigger with no above or below option and a template condition that checks if the trigger_to state is greater than the trigger_from state. Like this:
configuration.yaml:
template:
- sensor:
- name: Number of Over Temp or Over Power Alarms
state: >
{{ states.binary_sensor
|selectattr("entity_id", "search", "(_over_power|_over_temp)")
|selectattr('state','eq', 'on')
|list|count }}
You would then use it in an automation like this:
trigger:
platform: state
entity_id: sensor.number_of_over_temp_or_over_power_alarms
to:
condition:
- "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"
- "{{ trigger.to_state.state not in ['unknown', 'unavailable'] }}"
- "{{ trigger.to_state.state |int > trigger_from_state.state |int }}"
action:
- service: notify.notify
data:
message: >
Over Temp/Power detected from
{{ states.binary_sensor
|selectattr("entity_id", "search", "(_over_power|_over_temp)")
|selectattr('state','eq', 'on')
|list|join(', ' }}
There might be a way to do this just with the trigger. Iâm still thinking about it and will post a reply if I think of anything.
Typo in the third condition: trigger.from_state.state not trigger_from_state.state. This is why itâs important to understand and re-type rather than simply copy & paste â the error was in Tomâs original above, but the code that we suggest is hand-typed and often untested, as our systemsâ config doesnât match yours.
In the message, add |map(attribute='friendly_name') before the |list.