Notifications on any light switch

Hi,

I am trying to get noticifations if any light is switched. ( i.e. on any state-change in the group ‘lights’)
Currently, I get notifications to work if I define a specific light , like entity : light.overloop …
However, I would like to use something like ‘light’ or ‘light.any’ so I can get a notification about any light being switched.

Can someone provide an example or hint for this?

Thanks,

Alex.

You’d need to use multiple triggers, one for each light. This is because once one member of the group is on, the group is on.

One trigger, on state platform, that monitors each light through the entity_id list.

automation:
  trigger:
    platform: state
    entity_id: light.one, light.two, light.three
    from: 'off'
    to: 'on'

Ok,

Thanks both for your reply !

Solved it now by indeed creating a list of all lights like Treno suggests ( to keep the automations a bit organised; creating one per light will get a bit chaotic I think).

One follow-up question: Could I somehow then use the parameter as to what light was switched on in my message somehow?

Thanks.

Sure.
See the documentation here:

Ok, thanks again !
I got it to work by editing the automation.yaml file ( up to now I used the front-end automation editor fir automations).

What works:

- action:
    service: telegram_bot.send_message
    data_template:
      message: 'State of {{ trigger.entity_id }}  changed from  {{ trigger.from_state.state }} to {{ trigger.to_state.state }}  '
  alias: Send_message_on_statechange
  condition: []
  id: '1507996878399'
  trigger:
  - entity_id: light.overloop , light.ledstrip_kast , light.schemerlampjes , light.tradfri_kleur  ,  light.tradfri_bulb_e27_opal_1000lm
    platform: state

Am I correct that I could not have set this up using the ‘automation’ under configuarations in the frontend, and that this can only be done in the automations.yaml itself? ( since there is no option for this under ‘automation’ under ‘settings’ ?
I was at first trying to use the templating-format in the datafield under automation without succes… ).

Best,
Alex

1 Like