fixes #1141 with AI generated Flag data til 2030.

This commit is contained in:
CCOSTAN 2024-09-18 17:43:14 +00:00
parent 2c0bffa221
commit 374bbcf312
3 changed files with 96 additions and 13 deletions

80
config/json_data/flag_days.json Executable file
View File

@ -0,0 +1,80 @@
{
"Flag_Days_US": {
"static": {
"2/12": "Lincoln's Birthday",
"5/15": "Peace Officers Memorial Day",
"6/14": "Flag Day",
"7/4": "Independence Day",
"7/27": "National Korean War Veterans Armistice Day",
"9/17": "Constitution Day",
"10/27": "Navy Day",
"12/7": "Pearl Harbor Remembrance Day"
},
"dynamic": {
"01/20/2025": "Inauguration Day",
"01/16/2023": "Martin Luther King Jr. Day",
"01/15/2024": "Martin Luther King Jr. Day",
"01/19/2026": "Martin Luther King Jr. Day",
"01/18/2027": "Martin Luther King Jr. Day",
"01/17/2028": "Martin Luther King Jr. Day",
"01/15/2029": "Martin Luther King Jr. Day",
"01/21/2030": "Martin Luther King Jr. Day",
"02/20/2023": "Washington's Birthday (Presidents Day)",
"02/19/2024": "Washington's Birthday (Presidents Day)",
"02/17/2025": "Washington's Birthday (Presidents Day)",
"02/16/2026": "Washington's Birthday (Presidents Day)",
"02/15/2027": "Washington's Birthday (Presidents Day)",
"02/21/2028": "Washington's Birthday (Presidents Day)",
"02/19/2029": "Washington's Birthday (Presidents Day)",
"02/18/2030": "Washington's Birthday (Presidents Day)",
"05/20/2023": "Armed Forces Day",
"05/18/2024": "Armed Forces Day",
"05/17/2025": "Armed Forces Day",
"05/16/2026": "Armed Forces Day",
"05/15/2027": "Armed Forces Day",
"05/20/2028": "Armed Forces Day",
"05/19/2029": "Armed Forces Day",
"05/18/2030": "Armed Forces Day",
"05/29/2023": "Memorial Day",
"05/27/2024": "Memorial Day",
"05/26/2025": "Memorial Day",
"05/25/2026": "Memorial Day",
"05/31/2027": "Memorial Day",
"05/29/2028": "Memorial Day",
"05/28/2029": "Memorial Day",
"05/27/2030": "Memorial Day",
"09/04/2023": "Labor Day",
"09/02/2024": "Labor Day",
"09/01/2025": "Labor Day",
"09/07/2026": "Labor Day",
"09/06/2027": "Labor Day",
"09/04/2028": "Labor Day",
"09/03/2029": "Labor Day",
"09/02/2030": "Labor Day",
"09/15/2023": "National POW/MIA Recognition Day",
"09/20/2024": "National POW/MIA Recognition Day",
"09/19/2025": "National POW/MIA Recognition Day",
"09/18/2026": "National POW/MIA Recognition Day",
"09/17/2027": "National POW/MIA Recognition Day",
"09/15/2028": "National POW/MIA Recognition Day",
"09/21/2029": "National POW/MIA Recognition Day",
"09/20/2030": "National POW/MIA Recognition Day",
"10/09/2023": "Columbus Day",
"10/14/2024": "Columbus Day",
"10/13/2025": "Columbus Day",
"10/12/2026": "Columbus Day",
"10/11/2027": "Columbus Day",
"10/09/2028": "Columbus Day",
"10/08/2029": "Columbus Day",
"10/14/2030": "Columbus Day",
"11/07/2023": "Election Day",
"11/05/2024": "Election Day",
"11/04/2025": "Election Day",
"11/03/2026": "Election Day",
"11/02/2027": "Election Day",
"11/07/2028": "Election Day",
"11/06/2029": "Election Day",
"11/05/2030": "Election Day"
}
}
}

View File

@ -32,10 +32,10 @@ sensor:
scan_interval: 14400 scan_interval: 14400
value_template: > value_template: >
{% set today = now().month ~ '/' ~ now().day %} {% set today = now().month ~ '/' ~ now().day %}
{% set holiday = value_json.MAJOR_US.static[ today ] %} {% set holiday = value_json.MAJOR_US.static[today] if today in value_json.MAJOR_US.static else "" %}
{% if holiday | trim == "" %} {% if holiday | trim == "" %}
{% set today = now().month ~ '/' ~ now().day ~ '/' ~ now().year %} {% set today = now().month ~ '/' ~ now().day ~ '/' ~ now().year %}
{% set holiday = value_json.MAJOR_US.dynamic[ today ] %} {% set holiday = value_json.MAJOR_US.dynamic[today] if today in value_json.MAJOR_US.dynamic else "" %}
{% endif %} {% endif %}
{{ holiday }} {{ holiday }}
@ -43,16 +43,24 @@ sensor:
# Sensor Uses Flag data from this calendar - http://www.webcal.fi/en-US/flag_days.php # Sensor Uses Flag data from this calendar - http://www.webcal.fi/en-US/flag_days.php
################################################################################ ################################################################################
- platform: rest - platform: rest
resource: https://www.webcal.fi/cal.php?id=335&format=json&start_year=current_year&end_year=current_year&tz=America%2FNew_York resource: https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/json_data/flag_days.json
name: Flag name: Flag
scan_interval: 14400 scan_interval: 14400
value_template: >- value_template: >-
{%- set now_string = now().strftime('%Y-%m-%d') %} {%- set now_string = now().strftime('%m/%d') %}
{% for day_val in value_json if day_val.date == now_string %} {% 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 True
{% else %} {% elif dynamic_days is defined %}
{% for day_val in dynamic_days %}
{% if day_val.date == now_string %}
True
{% endif %}
{% endfor %}
{% else %}
False False
{% endfor -%} {% endif %}
################################################################################ ################################################################################
# Countdown Sensor using WolfRam Alpha Natural language queries # Countdown Sensor using WolfRam Alpha Natural language queries

View File

@ -3,12 +3,7 @@
# @CCOSTAN # @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig # Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
#------------------------------------------- #-------------------------------------------
#------ISS----------------------------------
#-------------------------------------------
# binary_sensor:
# - platform: iss
# show_on_map: true
#-------------------------------------------
sensor: sensor: