Skip to content

Instantly share code, notes, and snippets.

@gabfv
Created January 4, 2022 03:37
Show Gist options
  • Save gabfv/2993bbf7ae5cbfe97e293cb324fcc7a0 to your computer and use it in GitHub Desktop.
Save gabfv/2993bbf7ae5cbfe97e293cb324fcc7a0 to your computer and use it in GitHub Desktop.
YAML for Home Assistant automation that sets a light transition from any lights.
alias: 'TEST: Tell which light bulbs turned on'
description: ''
trigger:
- platform: event
event_type: state_changed
condition:
- condition: and
conditions:
- condition: template
value_template: '{{ trigger.event.data.entity_id.split(''.'')[0] == ''light'' }}'
- condition: template
value_template: '{{ trigger.event.data.old_state.state == ''off'' }}'
- condition: template
value_template: '{{ trigger.event.data.new_state.state == ''on'' }}'
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- service: light.turn_on
target:
entity_id: '{{trigger.event.data.entity_id}}'
data:
brightness_pct: 1
kelvin: 3600
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: light.turn_on
target:
entity_id: '{{trigger.event.data.entity_id}}'
data:
transition: 10
brightness_pct: 50
- service: notify.notify
data:
message: 'This light was turned on: {{trigger.event.data.entity_id}}'
mode: parallel
max: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment