Hello everyone,
I am trying to create an automation for my Shelly devices that notifies me if any of the Shellies have an overpowering or overheating problem.
The most elegent method would be to use the built in type:problem
alias: New Automation
description: ''
mode: single
trigger:
- type: problem
platform: device
device_id: de5d500475bd278835fa262242edbfc2
entity_id: binary_sensor.ambient_light_r_dr_overpowering
domain: binary_sensor
condition: []
action:
- service: notify.mobile_app_sm
data:
message: shelly
title: shelly
However, I absolutely do not want to use device_id because that is lost if I want to restore my config. I tried using device instead of device_id but that is not allowed.
Is there a different, elegant way of doing this?
I would like to use a long if statement because then I could implement all entities in one go, but I am not sure which type would allow this.
{% if not binary_sensor.ambient_light_dr_overheating == "OK" or binary_sensor.ambient_light_dr_overpowering == "OK" or binary_sensor.ambient_light_l_dr_overpowering == "OK" or binary_sensor.ambient_light_lr_overpowering == "OK" or binary_sensor.ambient_light_r_dr_overpowering == "OK" or binary_sensor.boiler_1_overheating == "OK" or binary_sensor.boiler_1_overpowering == "OK" or binary_sensor.boiler_2_overheating == "OK" or binary_sensor.boiler_2_overpowering == "OK" or binary_sensor.boiler_3_overheating == "OK" or binary_sensor.boiler_3_overpowering == "OK" or binary_sensor.lightswitch_dr_overheating == "OK" or binary_sensor.lightswitch_lr_overheating == "OK" or binary_sensor.main_light_dr_overpowering == "OK" or binary_sensor.main_light_lr_overpowering %}
But can I use the state trigger with a batch of entities rather than creating a long list of triggers?
And I agree, device triggers are ugly. Not sure though why there are not entity triggers? That would seem to be the easiest approach.
P.S.: If I leave to: empty, will it trigger on any state change, not matter what the new state is?
Instead of a long if statement, you rather put all entities inside a group and trigger when the group changes to âonâ.
The group will only be âonâ, if at least one of the entities is in the state âonâ, otherwise it will be off.
The state of the entity for a binary sensor is either on or off, the states you see in the frontend are translated based on the device type and your language settings. Foe autonations you need to use the ârealâ state, which can be found under Developer Tools â States
trigger:
platform: state
entity_id: group.binary_sensor_group
to: 'on'
action:
action:
- service: notify.mobile_app_sm
data:
message: >
There's a problem with the following shellies:
{{ expand('group.windows_doors_outside')|selectattr('state','eq','on')|map(attribute='name')|list|join(',') }}
title: shelly problem
I was wondering if it is possible to use regular expressions like for the configuration of Recorder or Logger or InfluxDB?
There you can batch exclude entities using regular expressions.
But I tried
trigger:
platform: state
entity_id:
- binary_sensor.*_overpowering
- binary_sensor.*_overheating
from: 'OK'
condition: []
action:
- service: notify.mobile_app_sm
data:
message: Shelly Overpowering or Overheating
title: Shelly Overpowering or Overheating
mode: single
One way to answer your own question is to review the documentation for the State Trigger. if you see no mention or example of it then the odds are very high that itâs not possible.
⌠and no you canât specify an entity like that.
FWIW, a group isnât ideal for this application. The automationâs State Trigger will trigger when the groupâs state changes from off to on which means all of the groupâs members were off and now one of them is on.
The second group member that changes to on wonât influence the groupâs state because itâs already on. That means it wonât trigger the automation again.
As Taras stated, thatâs not possible. And as I stated, you need to use the state from Developer Tools â States. A binary sensor is never âOKâ, thatâs only the state shown in the frontend.
Yes, sorry, I did not check the state before. And you are of course right, it has to be âoffâ to âonâ.
It is not really a big issue listing the sensors. I just use python to output them for me and then copy & paste them. But it would have been much nicer if I did not have to check everytime I added a device.
Is there a backdoor somewhere that you can think of?
Some integration that allows regular expressions which I can then piggy back off to get that list into the automation?
I was creating an automation to notify me if a battery is running low. The current state is âGOODâ (as per Developer Tools). And I am pretty sure the alternative state is âLOWâ.
And even though it was all setup, I did not get any notifications with
payload: value_json.battery == "LOW"
But if I run the automation manually, it sends the notifications. So the problem is not the notify part.
And if I try to force it to run by setting it to the known current state (âGOODâ) it does nothing.