From 374bbcf31222f89cfc4bbbf75e3f353bd6b4da1a Mon Sep 17 00:00:00 2001 From: CCOSTAN Date: Wed, 18 Sep 2024 17:43:14 +0000 Subject: [PATCH] fixes #1141 with AI generated Flag data til 2030. --- config/json_data/flag_days.json | 80 +++++++++++++++++++++++++++++++++ config/packages/holiday.yaml | 22 ++++++--- config/packages/space.yaml | 7 +-- 3 files changed, 96 insertions(+), 13 deletions(-) create mode 100755 config/json_data/flag_days.json diff --git a/config/json_data/flag_days.json b/config/json_data/flag_days.json new file mode 100755 index 00000000..d086a511 --- /dev/null +++ b/config/json_data/flag_days.json @@ -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" + } + } +} diff --git a/config/packages/holiday.yaml b/config/packages/holiday.yaml index 6dddccc8..5729585f 100755 --- a/config/packages/holiday.yaml +++ b/config/packages/holiday.yaml @@ -32,10 +32,10 @@ sensor: scan_interval: 14400 value_template: > {% 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 == "" %} {% 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 %} {{ holiday }} @@ -43,16 +43,24 @@ sensor: # Sensor Uses Flag data from this calendar - http://www.webcal.fi/en-US/flag_days.php ################################################################################ - 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 scan_interval: 14400 value_template: >- - {%- set now_string = now().strftime('%Y-%m-%d') %} - {% for day_val in value_json if day_val.date == now_string %} + {%- set now_string = now().strftime('%m/%d') %} + {% 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 - {% else %} + {% elif dynamic_days is defined %} + {% for day_val in dynamic_days %} + {% if day_val.date == now_string %} + True + {% endif %} + {% endfor %} + {% else %} False - {% endfor -%} + {% endif %} ################################################################################ # Countdown Sensor using WolfRam Alpha Natural language queries diff --git a/config/packages/space.yaml b/config/packages/space.yaml index a78bcf9c..7148d61e 100755 --- a/config/packages/space.yaml +++ b/config/packages/space.yaml @@ -3,12 +3,7 @@ # @CCOSTAN # Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig #------------------------------------------- -#------ISS---------------------------------- -#------------------------------------------- -# binary_sensor: -# - platform: iss -# show_on_map: true -#------------------------------------------- + sensor: