66 lines
2.0 KiB
YAML
66 lines
2.0 KiB
YAML
# Holiday Package
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Holiday Sensors
|
|
template:
|
|
- binary_sensor:
|
|
# Christmas Season is the day after Thanksgiving through New Years Eve
|
|
- name: Is Christmas Season
|
|
state: >
|
|
{% set xmas_start = as_datetime('%.4d-11-%.2d'|format(now().year, 22 + (3 - as_datetime(now().year|string + '-11-01').weekday()) % 7 + 1))|as_local %}
|
|
{% set xmas_end = as_datetime('%.4d-01-01'|format(now().year + 1))|as_local %}
|
|
{% set today = today_at('00:00') %}
|
|
{{ xmas_start <= today and today < xmas_end }}
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Holiday Automations
|
|
automation:
|
|
- alias: Holiday - Turn On Christmas Lights at Sunset
|
|
trigger:
|
|
- platform: sun
|
|
event: sunset
|
|
condition:
|
|
- "{{ is_state('binary_sensor.is_christmas_season', 'on') }}"
|
|
action:
|
|
- service: switch.turn_on
|
|
target:
|
|
entity_id:
|
|
- switch.christmas_lights_roof
|
|
- switch.christmas_lights_shrubs
|
|
|
|
- alias: Holiday - Turn On Christmas Lights in Morning
|
|
trigger:
|
|
- platform: time
|
|
at: '04:30:00'
|
|
condition:
|
|
- "{{ is_state('binary_sensor.is_christmas_season', 'on') }}"
|
|
action:
|
|
- service: switch.turn_on
|
|
target:
|
|
entity_id:
|
|
- switch.christmas_lights_roof
|
|
- switch.christmas_lights_shrubs
|
|
|
|
- alias: Holiday - Turn Off Christmas Lights at Midnight
|
|
trigger:
|
|
- platform: time
|
|
at: '00:00:00'
|
|
action:
|
|
- service: switch.turn_off
|
|
target:
|
|
entity_id:
|
|
- switch.christmas_lights_roof
|
|
- switch.christmas_lights_shrubs
|
|
|
|
- alias: Holiday - Turn Off Christmas Lights at Sunrise
|
|
trigger:
|
|
- platform: sun
|
|
event: sunrise
|
|
offset: '-00:30:00'
|
|
action:
|
|
- service: switch.turn_off
|
|
target:
|
|
entity_id:
|
|
- switch.christmas_lights_roof
|
|
- switch.christmas_lights_shrubs
|