Skip to content

Instantly share code, notes, and snippets.

@briodan
Created September 18, 2023 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briodan/81ea3c92d3145b414e5a6b494733020e to your computer and use it in GitHub Desktop.
Save briodan/81ea3c92d3145b414e5a6b494733020e to your computer and use it in GitHub Desktop.
WLED Preset Management
alias: Outdoor Lights
description: ""
trigger:
- platform: sun
event: sunset
id: Turn on 1
- platform: time
at: input_datetime.time_morning
id: Turn on 2
- platform: sun
event: sunrise
id: Turn off 1
- platform: time
at: input_datetime.time_evening
id: Turn off 2
- platform: state
entity_id:
- light.house_ae_led_master
- light.house_eth_led_master
- light.front_door_led
- light.garage_right_led
- light.garage_left_led
- light.house_numbers_led
to: "on"
for:
hours: 0
minutes: 30
seconds: 0
id: Turn off 3
- platform: state
entity_id:
- device_tracker.andrei_iphone
to: home
id: Andrei
- platform: state
entity_id:
- device_tracker.iphone_morgan
to: home
id: Morgan
- platform: state
entity_id:
- sun.sun
to: above_horizon
for:
hours: 1
minutes: 30
seconds: 0
id: Turn Off 4
- platform: state
entity_id:
- light.front_door_led
- light.garage_right_led
- light.garage_left_led
from: unavailable
id: Online
condition: []
action:
- choose:
- conditions:
- alias: Check for Turn on trigger
condition: or
conditions:
- condition: trigger
id: Turn on 1
- condition: trigger
id: Turn on 2
- condition: trigger
id: Online
- alias: Check for Night Light Time
condition: or
conditions:
- alias: Check for sunset to lights out
condition: and
conditions:
- condition: sun
after: sunset
- condition: time
before: input_datetime.time_evening
after: "00:00:00"
- alias: Check for lights on to sunrise
condition: and
conditions:
- condition: sun
before: sunrise
- condition: time
after: input_datetime.time_morning
before: "00:00:00"
sequence:
- service: script.holiday_decor_on
data: {}
- service: script.house_led_lights_on
data: {}
- conditions:
- alias: Check for Return Home Trigger
condition: or
conditions:
- condition: trigger
id: Andrei
- condition: trigger
id: Morgan
- alias: Check for Night Dark Time
condition: or
conditions:
- condition: time
before: "00:00:00"
after: input_datetime.time_evening
- condition: time
before: input_datetime.time_morning
after: "00:00:00"
sequence:
- service: scene.create
data:
scene_id: return_save_state
snapshot_entities:
- input_text.led_preset
- service: input_text.set_value
data:
value: All Lights
target:
entity_id: input_text.led_preset
- service: script.house_led_lights_on
data: {}
enabled: true
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
enabled: true
- service: scene.turn_on
data: {}
target:
entity_id: scene.return_save_state
enabled: true
- service: script.house_led_lights_on
data: {}
enabled: true
- conditions:
- alias: Check for Turn off trigger
condition: or
conditions:
- condition: trigger
id: Turn Off 3
- alias: Check for Night Dark Time and Day Time
condition: or
conditions:
- condition: time
before: "00:00:00"
after: input_datetime.time_evening
- condition: time
before: input_datetime.time_morning
after: "00:00:00"
- condition: sun
before: sunset
after: sunrise
sequence:
- service: script.house_led_lights_off
data: {}
- conditions:
- alias: Check for Turn off trigger
condition: or
conditions:
- condition: trigger
id: Turn off 1
- condition: trigger
id: Turn off 2
sequence:
- service: script.holiday_decor_off
data: {}
- service: script.house_led_lights_off
data: {}
- service: switch.turn_off
data: {}
target:
entity_id: switch.back_porch_lights
mode: single
trace:
stored_traces: 50
alias: Outdoor Lights Preset
description: ""
trigger:
- platform: time
at: "01:00:00"
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 10 or ( n.month == 11 and ( 1 <= n.day <= 5 )) }}
alias: Halloween
sequence:
- service: input_text.set_value
data:
value: Halloween
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 11 and ( 10 < n.day < 12 ) }}
alias: Rememberance Day
sequence:
- service: input_text.set_value
data:
value: Canada
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ (( n.month == 11 and ( 20 <= n.day <= 30 )) or ( n.month == 12 and ( 2 <= n.day <= 31 )) or ( n.month == 1 and ( 1 <= n.day <= 10 ))) }}
alias: Christmas
sequence:
- service: input_text.set_value
data:
value: >-
{{ state_attr('select.house_eth_led_preset', 'options') |
select("match", ".*Xmas*.") | list | random }}
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 2 and ( 13 < n.day < 15 ) }}
alias: Valentine
sequence:
- service: input_text.set_value
data:
value: Valentine
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 7 and n.day == 1 }}
alias: Canada Day
sequence:
- service: input_text.set_value
data:
value: Canada
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 7 and n.day == 4 }}
alias: US Day
sequence:
- service: input_text.set_value
data:
value: >-
{{ state_attr('select.house_eth_led_preset', 'options') |
select("match", ".*US*.") | list | random }}
target:
entity_id: input_text.led_preset
- conditions:
- condition: template
value_template: |-
{% set n = now() %}
{{ n.month == 12 and n.day == 1 }}
alias: Romania Day
sequence:
- service: input_text.set_value
data:
value: Romania
target:
entity_id: input_text.led_preset
default:
- service: input_text.set_value
data:
value: >-
{{ state_attr('select.house_eth_led_preset', 'options') |
select("match", ".*All Lights*.") | list | random }}
target:
entity_id: input_text.led_preset
mode: single
alias: House LED - Lights On
sequence:
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.power_plug_led
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: light.turn_on
data: {}
target:
entity_id:
- light.house_ae_led
- light.house_eth_led
- light.front_door_led
- light.garage_left_led
- light.garage_right_led
- light.andrei_office_led
- light.house_numbers_led
- service: select.select_option
data:
option: "{{states(\"input_text.led_preset\")}}"
target:
entity_id:
- select.house_ae_led_preset
- select.house_eth_led_preset
- select.front_door_led_preset
- select.garage_left_led_preset
- select.garage_right_led_preset
- select.andrei_office_led_preset
- select.house_numbers_led_preset
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment