Files
Home-AssistantConfig/config/packages/holiday.yaml
Carlo Costanzo c464073a0d Standardizing on Headers for all YAML files.
- Updated comments in various YAML configuration files to provide clearer descriptions of functionalities and integrations.
- Improved documentation for alarm, alexa_media_player, backups, blink, cbyge, climate, finance, fridge, garadget, glances, hass_agent_homepc, holiday, ios, landscape_lighting, lightning, logger, medicine, nfc_tags, noonhome, office_motion, phynplus, powerwall, printer, processmonitor, proxmox, rachio, rheem_econet, roku, sleepiq, space, speedtest, stats, superbowl, vacuum, wireless, and youtube packages.
- Added relevant links and issue references where applicable to enhance user guidance and support.
2025-11-29 13:17:07 -05:00

138 lines
4.9 KiB
YAML
Executable File

#-------------------------------------------
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Holiday Package - Flag/holiday sensors and lighting triggers.
#-------------------------------------------
######################################################################
## Holiday routines, notifications, and lighting tweaks.
######################################################################
# Video breakdown: https://www.vcloudinfo.com/2019/02/breaking-down-the-flag-sensor-in-home-assistant.html
# Modified for my own fun stuff!
homeassistant:
customize:
sensor.holiday:
icon: mdi:beach
friendly_name: US Holiday
sensor.flag:
icon: mdi:flag
friendly_name: Flag Day
###############################################################################
# Sensor updates once every 4 hours (14400 seconds) & runs 6 times in 24 hours
#
# First it checks for holiday in static section, if that doesn't exist,
# it checks in the dynamic section. If neither exists, the value will be empty
###############################################################################
sensor:
- platform: rest
resource: https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/json_data/holidays.json
name: Holiday
scan_interval: 14400
value_template: >
{% set today = now().month ~ '/' ~ now().day %}
{% set holiday = value_json.MAJOR_US.static[today] if today in value_json.MAJOR_US.static else "" %}
{% if holiday | trim == "" %}
{% set today = now().month ~ '/' ~ now().day ~ '/' ~ now().year %}
{% set holiday = value_json.MAJOR_US.dynamic[today] if today in value_json.MAJOR_US.dynamic else "" %}
{% endif %}
{{ holiday }}
################################################################################
# Sensor Uses Flag data generated by AI
################################################################################
- platform: rest
resource: https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/json_data/flag_days.json
name: Flag
scan_interval: 14400
value_template: >-
{% set now_string = now().strftime('%m/%d') %}
{% set now_full_string = now().strftime('%m/%d/%Y') %}
{% if value_json is defined and value_json.Flag_Days_US is defined %}
{% set static_days = value_json.Flag_Days_US.static %}
{% set dynamic_days = value_json.Flag_Days_US.dynamic %}
{% if static_days is defined and now_string in static_days %}
True
{% elif dynamic_days is defined %}
{% for day_val in dynamic_days %}
{% if day_val.date == now_full_string %}
True
{% endif %}
{% endfor %}
{% else %}
False
{% endif %}
{% else %}
{% endif %}
################################################################################
# Countdown Sensor using WolfRam Alpha Natural language queries
################################################################################
- platform: rest
name: Halloween Countdown
resource: !secret wolframalpha_halloween_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Christmas Countdown
resource: !secret wolframalpha_xmas_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Easter Countdown
resource: !secret wolframalpha_easter_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Mothers Countdown
resource: !secret wolframalpha_mothersday_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Fathers Countdown
resource: !secret wolframalpha_fathersday_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Chanukkah Countdown
resource: !secret wolframalpha_chanukkah_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Labor Day Countdown
resource: !secret wolframalpha_labor_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Memorial Day Countdown
resource: !secret wolframalpha_memorial_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200
- platform: rest
name: Thanksgiving Day Countdown
resource: !secret wolframalpha_thanksgiving_api
value_template: "{{ (value|replace(' days', '')) | int }}"
unit_of_measurement: Days
scan_interval: 43200