Skip to content

Instantly share code, notes, and snippets.

@giggio
Last active July 22, 2024 16:09
Show Gist options
  • Save giggio/117f9b11d2ba5f3fb077f1f30ea2a432 to your computer and use it in GitHub Desktop.
Save giggio/117f9b11d2ba5f3fb077f1f30ea2a432 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint to Turn lights on or off based on another light's state changes
blueprint:
name: Connect lights
description: Turn lights on or off based on another light's state changes
domain: automation
input:
target_lights:
name: Lights
description: The lights to sync
selector:
entity:
multiple: true
filter:
- domain: light
trigger:
- platform: state
entity_id: !input target_lights
to: null
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'unkown' and trigger.to_state.state != 'unavailable' }}"
action:
- repeat:
for_each: !input target_lights
sequence:
- if:
- condition: template
value_template: "{{ trigger.entity_id != repeat.item }}"
alias: Testa se não é o item que gerou o trigger
- condition: template
value_template: "{{ trigger.to_state.state != states(repeat.item) }}"
alias: Testa se o item já não está ligado/desligado
then:
- service: light.turn_{{ trigger.to_state.state }}
target:
entity_id:
- "{{ repeat.item }}"
alias: Liga ou desliga luz
alias: Liga ou desliga luz somente se a outra luz precisar
mode: single
max_exceeded: silent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment