@Van wrote:
Hi all,
I not sure how to get the trigger to use group similar to how you would list each entity.
for example:
- alias: test trigger: - platform: state entity_id: switch.s1,switch.s2,switch.s3,switch.s4 to: 'on' action: - service: persistent_notification.create data_template: message: "{{ states['switch'] | selectattr('entity_id','in',state_attr('group.mygroup','entity_id')) | selectattr('state','eq','on') | list }}" title: "Group test"
This would get a trigger on every switch state is on. Meaning it if I turn on 3 switches, I would get 3 alerts.
If I change the code to:
- alias: test trigger: - platform: state entity_id: group.mygroup to: 'on' ...
Then I would only get a trigger on the first switch that turns on.
If I turn on the 2nd switch, nothing happens.I tries using
platform: template
as well and it doesn’t seem to work- alias: test trigger: - platform: template value_template: "states['switch'] | selectattr('entity_id','in',state_attr('group.mygroup','entity_id')) | selectattr('state','eq','on') | list | count > 0 }}" ...
Is there a way I can get a notification when a switch is turned on regardless of the state of the other switches using group?
Thanks,
Van
Posts: 2
Participants: 2