input_text: basement_lights_restore: name: Basement Lights Restore icon: mdi:lightbulb-alert living_room_lights_restore: name: Living Room Lights Restore icon: mdi:lightbulb-alert script: basement_lights_alert: alias: Basement Lights Alert mode: restart icon: mdi:palette fields: type: name: 'Type' description: 'What type of alert you want the lights to run' required: true example: 'red, green, blue, police' selector: text: multiline: false duration: name: 'Duration' description: 'The duration to run the alert for' required: false example: '10' selector: number: min: 1 max: 30 flash: name: 'Flash' description: 'Flash any lights capable of doing so' required: false selector: boolean: sequence: # Setup and processing - variables: lightState: "{{ states('light.basement_studio_lights') }}" adaptive: "{{ states('switch.adaptive_lighting_basement_studio') }}" nightMode: "{{ 'on' if is_state('switch.adaptive_lighting_basement_studio','on') and is_state('switch.adaptive_lighting_sleep_mode_basement_studio','on') else 'off' }}" # If current scene is a defined scene, take note of it - if: - condition: template value_template: "{{ states('input_text.basement_studio_selected_scene') in state_attr('input_select.basement_studio_scenes','options') }}" then: - service: input_text.set_value target: entity_id: input_text.basement_lights_restore data: value: "{{ states('input_text.basement_studio_selected_scene') }}" # If the lights are on, and another alert isn't being interrupted, create a backup scene to restore at the end - if: - condition: template value_template: "{{ lightState == 'on' and states('input_text.basement_studio_selected_scene') != 'Alert' }}" then: - service: scene.create data: scene_id: basement_alert_restore snapshot_entities: - light.basement_led_strip_1 - light.basement_short_lamp - light.basement_tall_lamp - light.basement_stairwell - service: input_text.set_value target: entity_id: input_text.basement_studio_selected_scene data: value: Alert # Define variable for restoration of the current scene if the backup is not needed - variables: restoreScene: "{{ states('input_text.basement_lights_restore') }}" # Actual alert begins - service: switch.turn_off target: entity_id: switch.adaptive_lighting_basement_studio - service: light.turn_on target: entity_id: - light.basement_short_lamp - light.basement_tall_lamp - light.basement_stairwell data: color_name: "{{ 'red' if type == 'police' else type }}" brightness: 255 - if: - condition: template value_template: "{{ flash == true }}" then: - service: light.turn_on target: entity_id: - light.basement_short_lamp - light.basement_tall_lamp - light.basement_stairwell data: flash: long - service: lifx.effect_move target: entity_id: light.basement_led_strip_1 data: speed: 0.5 direction: right power_on: false - service: lifx.set_state target: entity_id: light.basement_led_strip_1 data: zones: - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 color_name: "{{ 'red' if type == 'police' else type }}" brightness: 255 - service: lifx.set_state target: entity_id: light.basement_led_strip_1 data: zones: - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 color_name: "{{ 'blue' if type == 'police' else 'white' }}" brightness: 255 power: true - delay: seconds: "{{ duration|default(10) }}" - choose: # If the lights were off, turn them back off - conditions: "{{ lightState == 'off' }}" sequence: - service: light.turn_off target: entity_id: light.basement_studio_lights - delay: seconds: 3 - service: switch.turn_on target: entity_id: switch.adaptive_lighting_basement_studio - service: input_text.set_value target: entity_id: input_text.basement_studio_selected_scene data: value: Adaptive # If the lights were in night mode, put them back to it - conditions: "{{ nightMode == 'on' }}" sequence: - service: input_select.select_option target: entity_id: input_select.basement_studio_scenes data: option: Adaptive - delay: seconds: 1 - service: switch.turn_on target: entity_id: switch.adaptive_lighting_sleep_mode_basement_studio # If the lights were in adaptive, put them back to it - conditions: "{{ adaptive == 'on' }}" sequence: - service: input_select.select_option target: entity_id: input_select.basement_studio_scenes data: option: Adaptive # If the current scene was a defined scene, activate that scene - conditions: "{{ restoreScene in state_attr('input_select.basement_studio_scenes','options') }}" sequence: - service: input_select.select_option target: entity_id: input_select.basement_studio_scenes data: option: "{{ restoreScene }}" # Otherwise, restore the backup scene from above default: - service: scene.turn_on target: entity_id: scene.basement_alert_restore # Cleanup - delay: seconds: "{{ 3 if adaptive == 'on' or nightMode == 'on' else 1 }}" - service: lifx.effect_stop target: entity_id: light.basement_led_strip_1 living_room_lights_alert: alias: Living Room Lights Alert mode: restart icon: mdi:palette fields: type: name: 'Type' description: 'What type of alert you want the lights to run' required: true example: 'red, green, blue, police' selector: text: multiline: false duration: name: 'Duration' description: 'The duration to run the alert for' required: false example: '10' selector: number: min: 1 max: 30 flash: name: 'Flash' description: 'Flash any lights capable of doing so' required: false selector: boolean: sequence: # Setup and processing - variables: lightState: "{{ states('light.living_room_lights') }}" adaptive: "{{ states('switch.adaptive_lighting_living_room') }}" nightMode: "{{ 'on' if is_state('switch.adaptive_lighting_living_room','on') and is_state('switch.adaptive_lighting_sleep_mode_living_room','on') else 'off' }}" # If current scene is a defined scene, take note of it - if: - condition: template value_template: "{{ states('input_text.living_room_selected_scene') in state_attr('input_select.living_room_scenes','options') }}" then: - service: input_text.set_value target: entity_id: input_text.living_room_lights_restore data: value: "{{ states('input_text.living_room_selected_scene') }}" # If the lights are on, and another alert isn't being interrupted, create a backup scene to restore at the end - if: - condition: template value_template: "{{ lightState == 'on' and states('input_text.living_room_selected_scene') != 'Alert' }}" then: - service: scene.create data: scene_id: living_room_alert_restore snapshot_entities: - light.living_room_led_strip - light.living_room_overhead - service: input_text.set_value target: entity_id: input_text.living_room_studio_selected_scene data: value: Alert # Define variable for restoration of the current scene if the backup is not needed - variables: restoreScene: "{{ states('input_text.living_room_lights_restore') }}" # Actual alert begins - service: switch.turn_off target: entity_id: switch.adaptive_lighting_living_room - service: light.turn_on target: entity_id: - light.living_room_overhead data: color_name: "{{ 'red' if type == 'police' else type }}" brightness: 255 - if: - condition: template value_template: "{{ flash == true }}" then: - service: light.turn_on target: entity_id: - light.living_room_overhead data: flash: long - service: lifx.effect_move target: entity_id: light.living_room_led_strip data: speed: 0.5 direction: right power_on: false - service: lifx.set_state target: entity_id: light.living_room_led_strip data: zones: - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 color_name: "{{ 'red' if type == 'police' else type }}" brightness: 255 - service: lifx.set_state target: entity_id: light.living_room_led_strip data: zones: - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 color_name: "{{ 'blue' if type == 'police' else 'white' }}" brightness: 255 power: true - delay: seconds: "{{ duration|default(10) }}" - choose: # If the lights were off, turn them back off - conditions: "{{ lightState == 'off' }}" sequence: - service: light.turn_off target: entity_id: - light.living_room_overhead - light.living_room_led_strip - delay: seconds: 3 - service: switch.turn_on target: entity_id: switch.adaptive_lighting_living_room - service: input_text.set_value target: entity_id: input_text.living_room_selected_scene data: value: Adaptive # If the lights were in night mode, put them back to it - conditions: "{{ nightMode == 'on' }}" sequence: - service: input_select.select_option target: entity_id: input_select.living_room_scenes data: option: Adaptive - delay: seconds: 1 - service: switch.turn_on target: entity_id: switch.adaptive_lighting_sleep_mode_living_room # If the lights were in adaptive, put them back to it - conditions: "{{ adaptive == 'on' }}" sequence: - service: input_select.select_option target: entity_id: input_select.living_room_scenes data: option: Adaptive # If the current scene was a defined scene, activate that scene - conditions: "{{ restoreScene in state_attr('input_select.living_room_scenes','options') }}" sequence: - service: input_select.select_option target: entity_id: input_select.living_room_scenes data: option: "{{ restoreScene }}" # Otherwise, restore the backup scene from above default: - service: scene.turn_on target: entity_id: scene.living_room_alert_restore # Cleanup - delay: seconds: "{{ 3 if adaptive == 'on' or nightMode == 'on' else 1 }}" - service: lifx.effect_stop target: entity_id: light.living_room_led_strip