I’m after some advice on what may be wrong with the below script and/or automation, stopping it from triggering. I can’t see what it could be but if anyone could please advise where it is going wrong.
The script works fine when triggering with a toggle in lovelace but the automation doesn’t seem to do anything at all. In the automation I’ve tried both script.turn_on
and homeassistant.turn_on
:
script:
rainbow_light:
alias: Rainbow Light
mode: single
fields:
entity:
description: light.guest_room_lamp
example: light.guest_room_lamp
variables:
colors: "{{ [[0.217,0.077], [0.157,0.05], [0.136,0.04], [0.137,0.065],\n [0.141,0.137],\
\ [0.146,0.238], [0.151,0.343], [0.157,0.457],\n [0.164,0.591], [0.17,0.703],\
\ [0.172,0.747], [0.199,0.724],\n [0.269,0.665], [0.36,0.588], [0.444,0.517],\
\ [0.527,0.447],\n [0.612,0.374], [0.677,0.319], [0.701,0.299], [0.667,0.284],\n\
\ [0.581,0.245], [0.477,0.196], [0.385,0.155], [0.301,0.116], \n [0.217,0.077]]\
\ }}"
sequence:
- service: light.turn_on
data_template:
xy_color: '{{ colors[(now().second/2.5)|round(0)] }}'
transition: 4
brightness: 250
entity_id: '{{ entity }}'
icon: mdi:looks
automation:
- alias: Sunset Guest Bedroom
trigger:
- platform: sun
event: sunset
offset: '+00:40:00'
action:
- service: script.rainbow_light
- delay: '05:00:00'
- service: script.turn_off
entity_id: script.rainbow_light