So, I could use a little help. I have some colored accent lights outside that I set up a script to do some fun stuff outside. Essentially, I have a few helpers that set a blink pattern, number of colors to shift, and color names, and then I animate them overnight as accents on my house.
However, I am having difficulty getting things to shut down. If I manually “turn off” the light group, it can take several “off’s” before it takes. The group will go off, then back on a moment later.
My code is as follows… I’m sure that there is a more efficient way to do things, but this is how I have it now…
Script Call: I tried using multiple turn_offs to solve the problem, but no dice
- id: 'PrettyUplights ON'
alias: Uplights Color Cycle
description: ''
trigger:
- platform: state
from: 'off'
to: 'on'
entity_id: light.outside_uplights
action:
service: script.turn_on
entity_id: script.pretty_lights
mode: single
- id: 'PrettyUplights OFF'
alias: Uplights Color Cycle
description: ''
trigger:
- platform: state
from: 'on'
to: 'off'
entity_id: light.outside_uplights
action:
- service: homeassistant.turn_off
entity_id: script.pretty_lights
- service: homeassistant.turn_off
entity_id: light.outside_uplights
- service: homeassistant.turn_off
entity_id: script.pretty_lights
- service: homeassistant.turn_off
entity_id: light.outside_uplights
- service: homeassistant.turn_off
entity_id: script.pretty_lights
- service: homeassistant.turn_off
entity_id: light.outside_uplights
- service: homeassistant.turn_off
entity_id: script.pretty_lights
- service: homeassistant.turn_off
entity_id: light.outside_uplights
mode: restart
Timer
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- id: 'Sunrise'
alias: Sunrise
trigger:
platform: sun
event: sunrise
action:
- type: turn_off
device_id: 5437sdte17948text50808214295
entity_id: light.outside_uplights
domain: light
mode: parallel
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- id: 'Sunset'
alias: Sunset
trigger:
platform: sun
event: sunset
action:
- type: turn_on
device_id: 5437sdte17948text50808214295
entity_id: light.outside_uplights
domain: light
- type: turn_on
device_id: 5437sdtesdtext50808214295
entity_id: switch.china_cabinet
domain: switch
- type: turn_on
device_id: 5437sdt654654654t50808214295
entity_id: switch.fireplace
domain: switch
- type: turn_on
device_id: 5437sdtth46wefwefwt50808214295
entity_id: switch.balcony_plug
domain: switch
- type: turn_on
device_id: 5437rt6546wefwefwt50808214295
entity_id: switch.porch_plug
domain: switch
Pretty Lights script
pretty_lights:
alias: Color Cylce for Uplights
sequence:
- repeat:
while:
- condition: state
entity_id: light.outside_uplights
state: 'on'
sequence:
#--------------------------------------------------------#
- choose:
- conditions:
- condition: template
value_template: "{{ (states.input_number.number_of_colors.state | int) == 1 }}"
sequence:
- service: light.turn_on
entity_id: light.outdoor_group_a
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_b
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
#--------------------------------------------------------#
- choose:
- conditions:
- condition: template
value_template: "{{ (states.input_number.number_of_colors.state | int) == 2 }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ states('input_select.color_movement') == 'Walk' }}"
sequence:
- service: light.turn_on
entity_id: light.outdoor_group_a
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_b
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outdoor_group_a
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_b
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
default:
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
#--------------------------------------------------------#
- choose:
- conditions:
- condition: template
value_template: "{{ (states.input_number.number_of_colors.state | int) == 3 }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ states('input_select.color_movement') == 'Walk' }}"
sequence:
- service: light.turn_on
entity_id: light.outdoor_group_3a
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3b
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3c
data:
color_name: "{{ states.input_text.color_3.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outdoor_group_3a
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3b
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3c
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outdoor_group_3a
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3b
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.outdoor_group_3c
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
default:
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_3.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
#--------------------------------------------------------#
Trimmed for your sanity, and the max size
#--------------------------------------------------------#
- choose:
- conditions:
- condition: template
value_template: "{{ (states.input_number.number_of_colors.state | int) == 0 }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ states('input_select.color_movement') == 'Walk' }}"
sequence:
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_8.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_3.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_4.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_5.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_7.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_6.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.office_corner
data:
color_name: "{{ states.input_text.color_8.state }}"
- service: light.turn_on
entity_id: light.office_windows
data:
color_name: "{{ states.input_text.color_1.state }}"
- service: light.turn_on
entity_id: light.north_pillar
data:
color_name: "{{ states.input_text.color_2.state }}"
- service: light.turn_on
entity_id: light.south_pillar
data:
color_name: "{{ states.input_text.color_3.state }}"
- service: light.turn_on
entity_id: light.tree_wall
data:
color_name: "{{ states.input_text.color_4.state }}"
- service: light.turn_on
entity_id: light.garage_n
data:
color_name: "{{ states.input_text.color_5.state }}"
- service: light.turn_on
entity_id: light.garage_m
data:
color_name: "{{ states.input_text.color_6.state }}"
- service: light.turn_on
entity_id: light.garage_s
data:
color_name: "{{ states.input_text.color_7.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
default:
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_1.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_2.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_3.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_4.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_5.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_6.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_7.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
- service: light.turn_on
entity_id: light.outside_uplights
data:
color_name: "{{ states.input_text.color_8.state }}"
- delay: "{{ states('input_number.color_delay') | int }}"
mode: single