124 lines
3.6 KiB
YAML
124 lines
3.6 KiB
YAML
- alias: Office Light Weekday Schedule
|
||
description: Turn on office light at 9am if home; turn off at 5pm if on.
|
||
triggers:
|
||
- at: 09:00:00
|
||
platform: time
|
||
- at: '17:00:00'
|
||
platform: time
|
||
conditions: []
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: time
|
||
weekday:
|
||
- mon
|
||
- tue
|
||
- wed
|
||
- thu
|
||
- fri
|
||
- condition: template
|
||
value_template: '{{ now().hour == 9 and now().minute == 0 }}'
|
||
- condition: state
|
||
entity_id: person.jason
|
||
state: home
|
||
sequence:
|
||
- service: switch.turn_on
|
||
target:
|
||
entity_id: switch.office_light
|
||
- conditions:
|
||
- condition: time
|
||
weekday:
|
||
- mon
|
||
- tue
|
||
- wed
|
||
- thu
|
||
- fri
|
||
- condition: template
|
||
value_template: '{{ now().hour == 17 and now().minute == 0 }}'
|
||
- condition: state
|
||
entity_id: switch.office_light
|
||
state: 'on'
|
||
sequence:
|
||
- service: switch.turn_off
|
||
target:
|
||
entity_id: switch.office_light
|
||
mode: single
|
||
- alias: Patriotic Holiday Lights (Auto)
|
||
description: Sets red, white, and blue lights for Memorial Day, July 4th (July 1–5),
|
||
Labor Day, and Veterans Day
|
||
triggers:
|
||
- platform: sun
|
||
event: sunset
|
||
offset: +00:15:00
|
||
- platform: state
|
||
entity_id:
|
||
- light.coach_light_1
|
||
- light.coach_light_2
|
||
- light.coach_light_3
|
||
from:
|
||
- 'off'
|
||
- unavailable
|
||
to: 'on'
|
||
conditions: []
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ should_set_colors }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.coach_light_1
|
||
data:
|
||
rgb_color:
|
||
- 255
|
||
- 0
|
||
- 0
|
||
action: light.turn_on
|
||
- target:
|
||
entity_id: light.coach_light_2
|
||
data:
|
||
rgb_color:
|
||
- 255
|
||
- 255
|
||
- 255
|
||
action: light.turn_on
|
||
- target:
|
||
entity_id: light.coach_light_3
|
||
data:
|
||
rgb_color:
|
||
- 0
|
||
- 0
|
||
- 255
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ should_reset }}'
|
||
sequence:
|
||
- target:
|
||
entity_id:
|
||
- light.coach_light_1
|
||
- light.coach_light_2
|
||
- light.coach_light_3
|
||
data:
|
||
color_temp: 300
|
||
action: light.turn_on
|
||
variables:
|
||
today: '{{ now().date() }}'
|
||
year: '{{ now().year }}'
|
||
july_start: '{{ strptime(year ~ ''-07-01'', ''%Y-%m-%d'').date() }}'
|
||
july_end: '{{ strptime(year ~ ''-07-05'', ''%Y-%m-%d'').date() }}'
|
||
veterans_day: '{{ strptime(year ~ ''-11-11'', ''%Y-%m-%d'').date() }}'
|
||
memorial_day: "{% set last_day = namespace(date=none) %} {% for day in range(25,\
|
||
\ 32) %}\n {% set dt = strptime(year ~ '-05-' ~ day|string, '%Y-%m-%d') %}\n\
|
||
\ {% if dt.weekday() == 0 %}\n {% set last_day.date = dt.date() %}\n {%\
|
||
\ endif %}\n{% endfor %} {{ last_day.date }}\n"
|
||
labor_day: "{% for day in range(1, 8) %}\n {% set dt = strptime(year ~ '-09-'\
|
||
\ ~ day|string, '%Y-%m-%d') %}\n {% if dt.weekday() == 0 %}\n {{ dt.date()\
|
||
\ }}\n {% endif %}\n{% endfor %}\n"
|
||
should_set_colors: "{{ today >= july_start and today <= july_end\n or today\
|
||
\ == memorial_day\n or today == labor_day\n or today == veterans_day }}\n"
|
||
should_reset: "{{ today == july_end + timedelta(days=1)\n or today == memorial_day\
|
||
\ + timedelta(days=1)\n or today == labor_day + timedelta(days=1)\n or today\
|
||
\ == veterans_day + timedelta(days=1) }}\n"
|
||
mode: single
|