diff --git a/packages/holidays.yaml b/packages/holidays.yaml new file mode 100644 index 0000000..25405f2 --- /dev/null +++ b/packages/holidays.yaml @@ -0,0 +1,116 @@ +############################################################################### +# @author : Jeffrey Stone +# @date : 02/19/2019 +# @package : Holidays +# @description : Holiday Specific. +# +# I'm not sure where I got this, but it leverages a python script: https://github.com/thejeffreystone/home-assistant-configuration/blob/master/python_scripts/special_events.py +# +# +# To create a sensor just create an automation to fire around midnight. +# +# automation: +# - id: refresh_holioday_sensors +# alias: Refresh Holiday sensors +# initial_state: true +# trigger: +# - platform: time +# at: '00:00:07' +# - platform: homeassistant +# event: start +# action: +# - service: python_script.special_events +# data: +# name: Christmas +# type: holiday +# date: 25/12/2001 +# +# Where Name equals the name of the event, type is the type of event, and date is the date in DD/MM/YYYY format +# +# Year only matters if your want to take advantage fo the years attribute which will tell you have many years since the event. Useful +# with birthdays and anniversaries. +# +# I use the Following types: +# birthday +# anniversary +# holiday +# trip +# +# The type will be used in the name of the sensor it creates. For example: +# sensor.trip_camping +# sensor.birthday_jeff +# sensor.holiday_christmas +# +# The state of the sensor will be the days until the event. For birthdays and anniversaries it will never be more than 365. +# For example {{ states.sensor.birthday_jeff.state }} will be the number of days until my next birthday. +# And {{ states.sensor.birthday_jeff.attributes.years }} will be my age, or the number of years since my birth (if you put the real year in) +# For events with a year in the future, the state will be number of days to that exact moment in time. +# +############################################################################### +input_boolean: + this_is_halloween: + name: This is Halloween + +automation: + - id: refresh_holioday_sensors + alias: Refresh Holiday sensors + initial_state: true + trigger: + - platform: time + at: '00:00:07' + - platform: homeassistant + event: start + action: + - service: python_script.special_events + data: + name: Christmas + type: holiday + date: 25/12/2001 + - service: python_script.special_events + data: + name: Halloween + type: holiday + date: 31/10/2001 + + - id: this_is_halloween_on + alias: This is Halloween On + initial_state: true + trigger: + - platform: state + entity_id: input_boolean.this_is_halloween + to: 'on' + action: + - service: script.turn_on + entity_id: script.this_is_halloween + + - id: this_is_halloween_off + alias: This is Halloween Off + initial_state: true + trigger: + - platform: state + entity_id: input_boolean.this_is_halloween + to: 'off' + action: + - service: script.turn_on + entity_id: script.kill_this_ride + - service: media_player.media_stop + entity_id: media_player.ha_speaker + - id: this_is_halloween + alias: This is Halloween + initial_state: true + trigger: + - platform: template + value_template: "{{ states('sensor.time') == (state_attr('input_datetime.halloween_show', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}" + condition: + - condition: state + entity_id: calendar.holidays_in_united_states + state: "on" + - condition: template + value_template: > + {%- set event=states.calendar.holidays_in_united_states.attributes.message %} + {%- if event == 'Halloween' %} + true + {%- endif -%} + action: + - service: input_boolean.turn_on + entity_id: input_boolean.this_is_halloween \ No newline at end of file