############################################################################### # @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. # ############################################################################### automation: # Holiday Wishes - id: wishes_five_min alias: Wishes Five Minute initial_state: true trigger: - platform: template value_template: "{{ states('sensor.time') == (state_attr('input_datetime.christmas_preshow', '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 == 'Christmas Eve' %} true {%- endif -%} action: - service: script.holiday_wishes_preshow - id: wishes_show_start alias: Wishes Show Start initial_state: true trigger: - platform: template value_template: "{{ states('sensor.time') == (state_attr('input_datetime.christmas_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 == 'Christmas Eve' %} true {%- endif -%} action: - service: input_boolean.turn_on entity_id: input_boolean.holiday_wishes # script: # more_haunted_sounds: # sequence: # - service: script.youtube_audio # data_template: # volume: .5 # media: > # {{- [ # "https://www.youtube.com/watch?v=pVeX4C9B1Lk", # "https://www.youtube.com/watch?v=S_hKvncbL9w", # "https://www.youtube.com/watch?v=zB-Y5OswETY", # "https://www.youtube.com/watch?v=x5tmmRZYq4s", # "https://www.youtube.com/watch?v=rxxC7RJ2b_E", # "https://www.youtube.com/watch?v=Zhd8V9cDUsA", # "https://www.youtube.com/watch?v=jmSI-jf6nLo", # "https://www.youtube.com/watch?v=szxC3E7m9dk", # "https://www.youtube.com/watch?v=TaejWf5NIfI", # "https://www.youtube.com/watch?v=orDBUrmK9vU", # "https://www.youtube.com/watch?v=nKltUaCxZPc", # "https://www.youtube.com/watch?v=_A1yK0YU6U0", # "https://www.youtube.com/watch?v=AQ1SE4tLIC" # ] | random -}} # haunted_sounds: # sequence: # - service: script.local_audio # data_template: # volume: .5 # media: > # {{- [ # "/media/haunted_sounds/haunted_guest_welcome.mp3", # "/media/haunted_sounds/ChainsRattling.mp3", # "/media/haunted_sounds/CreakingDoorSpooky.mp3", # "/media/haunted_sounds/DemonHaunting.mp3", # "/media/haunted_sounds/Evil_Laugh_2.mp3", # "/media/haunted_sounds/Evillaugh.mp3", # "/media/haunted_sounds/audio/Scary.mp3", # "/media/haunted_sounds/audio/raven.mp3", # "/media/haunted_sounds/audio/EvilLaughCackle.mp3", # "/media/haunted_sounds/audio/Haunted-CatScream.mp3", # "/media/haunted_sounds/audio/Haunted-DragonRoaring.mp3", # "/media/haunted_sounds/Haunted-Heart.mp3", # "/media/haunted_sounds/Haunted-ScaryScream.mp3", # "/media/haunted_sounds/Haunted-TRexRoar.mp3", # "/media/haunted_sounds/Haunted-TollingBell.mp3", # "/media/haunted_sounds/Haunted-Vocals.mp3" # ] | random -}} # haunted_house: # sequence: # - delay: '00:05:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds # - delay: '00:0{{ range(2,5) | random | int }}:00' # - service: script.haunted_sounds sensor: - platform: rest name: Halloween Countdown resource: !secret WA_HALLOWEEN value_template: "{{ (value|replace(' days', '')) | int }}" unit_of_measurement: Days scan_interval: 43200 - platform: rest name: Christmas Countdown resource: !secret WA_XMAS value_template: "{{ (value|replace(' days', '')) | int }}" unit_of_measurement: Days scan_interval: 43200