script: light_cycle: sequence: - action: homeassistant.turn_on entity_id: light.front_room_hue data_template: brightness: 250 color_name: > {% set colors = ['red', 'yellow' , 'blue', 'green' , 'purple'] %} {{ colors|random }} transition: 1 # Wait until the loop_lights script has finished running - delay: "00:00:02" - wait_template: "{{ is_state('script.loop_lights', 'off') }}" - action: script.loop_lights loop_lights: sequence: - delay: "00:00:02" # Wait until the light_cycle script has finished running - wait_template: "{{ is_state('script.light_cycle', 'off') }}" - action: script.light_cycle automation: - alias: Light Cycle Start id: automation_light_cycle_start trigger: - platform: state entity_id: input_boolean.front_room_light_cycle to: "on" action: - action: input_text.set_value # Again, note the use of 'data_template:' rather than the normal 'data:' if you weren't using an input variable. data_template: entity_id: input_text.front_room_mode value: "{{ states('input_select.front_room_mode') }}" - action: input_select.select_option data: entity_id: input_select.front_room_mode option: "Off" - action: script.light_cycle - alias: Light Cycle Stop id: automation_light_cycle_stop trigger: - platform: state entity_id: input_boolean.front_room_light_cycle to: "off" action: - action: homeassistant.turn_off entity_id: - script.light_cycle - script.loop_lights - action: input_select.select_option data_template: entity_id: input_select.front_room_mode option: "{{ states('input_text.front_room_mode') }}" - action: input_boolean.toggle data: entity_id: input_boolean.front_room_occupied - delay: "00:00:01" - action: input_boolean.toggle data: entity_id: input_boolean.front_room_occupied