#Script to switch of all lights

1 messages · Page 1 of 1 (latest)

empty quarry
#

Hi everyone,
I would need your help. What I would like to archive is that on a push of a button which is located at the entrance/exit of the house that all light switches are turned off.

I know I can do that via the website like when button is pushed then device light1 turn off, light2 turn off and so on.

I am wondering if there is a better way to archive this especailly everytime I change or add a light switch then I would need to adjust the automation.

Thank you for your help

heavy dagger
#

It would be possible to make an automation that does that. Action like:

  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: |-
        {{ states.light |map(attribute='entity_id')|list }}

Downside is, now it is hard to exclude a light. So I would label every light I want to turn of generally with a label and use that in my action.

  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      label_id: all_off

Might be able to do the opposite (leave on the ones that are labeled) but I don't know a template for that...

hoary tree
#

reject('in', label_entities('leave on'))

sly adder
#

Use "TAGS". I have all my interior lights tagged with "Interior Lights", bedroom lights with "Bed Room" lights and my automations say to turn off lights with the tag "Interior Lights" for example.

viral latch
#

“Tags” is labels.

prime forum
#

Hi @empty quarry,

  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: all

Title says turn off all lights, this will work.