mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-12-12 10:02:18 +00:00
Update holiday.yaml to change resource URLs to local paths and refactor flag days logic for improved readability and efficiency.
This commit is contained in:
@@ -29,7 +29,7 @@ homeassistant:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
sensor:
|
sensor:
|
||||||
- platform: rest
|
- platform: rest
|
||||||
resource: https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/json_data/holidays.json
|
resource: http://localhost:8123/local/json_data/holidays.json
|
||||||
name: Holiday
|
name: Holiday
|
||||||
scan_interval: 14400
|
scan_interval: 14400
|
||||||
value_template: >
|
value_template: >
|
||||||
@@ -45,28 +45,21 @@ sensor:
|
|||||||
# Sensor Uses Flag data generated by AI
|
# Sensor Uses Flag data generated by AI
|
||||||
################################################################################
|
################################################################################
|
||||||
- platform: rest
|
- platform: rest
|
||||||
resource: https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/json_data/flag_days.json
|
resource: http://localhost:8123/local/json_data/flag_days.json
|
||||||
name: Flag
|
name: Flag
|
||||||
scan_interval: 14400
|
scan_interval: 14400
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{% set now_string = now().strftime('%m/%d') %}
|
{% set now_string = now().month ~ '/' ~ now().day %}
|
||||||
{% set now_full_string = now().strftime('%m/%d/%Y') %}
|
{% set now_full_string = now().strftime('%m/%d/%Y') %}
|
||||||
{% if value_json is defined and value_json.Flag_Days_US is defined %}
|
{% set flag_data = value_json.Flag_Days_US if value_json is defined and value_json.Flag_Days_US is defined else {} %}
|
||||||
{% set static_days = value_json.Flag_Days_US.static %}
|
{% set static_days = flag_data.static if flag_data.static is defined else {} %}
|
||||||
{% set dynamic_days = value_json.Flag_Days_US.dynamic %}
|
{% set dynamic_days = flag_data.dynamic if flag_data.dynamic is defined else {} %}
|
||||||
{% if static_days is defined and now_string in static_days %}
|
{% if now_string in static_days %}
|
||||||
True
|
True
|
||||||
{% elif dynamic_days is defined %}
|
{% elif now_full_string in dynamic_days %}
|
||||||
{% for day_val in dynamic_days %}
|
True
|
||||||
{% if day_val.date == now_full_string %}
|
|
||||||
True
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
False
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
False
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
82
config/www/json_data/flag_days.json
Normal file
82
config/www/json_data/flag_days.json
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"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/11": "Patriot Day",
|
||||||
|
"9/17": "Constitution Day",
|
||||||
|
"10/27": "Navy Day",
|
||||||
|
"11/11": "Veterans 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
116
config/www/json_data/holidays.json
Normal file
116
config/www/json_data/holidays.json
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"MAJOR_US": {
|
||||||
|
"static": {
|
||||||
|
"1/1": "New Years Day",
|
||||||
|
"2/2": "Groundhog Day",
|
||||||
|
"2/3": "Staceys Birthday",
|
||||||
|
"2/14": "Valentines Day",
|
||||||
|
"3/14": "Pi Day",
|
||||||
|
"3/17": "St. Patricks Day",
|
||||||
|
"3/26": "Justins Birthday",
|
||||||
|
"4/1": "April Fools Day",
|
||||||
|
"4/22": "Earth Day",
|
||||||
|
"5/4": "Star Wars Day",
|
||||||
|
"5/5": "Cinco de Mayo",
|
||||||
|
"6/14": "Flag Day",
|
||||||
|
"7/4": "Independence Day",
|
||||||
|
"8/30": "Paiges Birthday",
|
||||||
|
"9/10": "Mom and Dads Wedding Anniversary",
|
||||||
|
"9/11": "Patriot Day",
|
||||||
|
"10/31": "Halloween",
|
||||||
|
"11/11": "Veterans Day",
|
||||||
|
"11/16": "Carlos Birthday",
|
||||||
|
"12/7": "Pearl Harbor Day",
|
||||||
|
"12/24": "Christmas Eve",
|
||||||
|
"12/25": "Christmas Day",
|
||||||
|
"12/31": "New Years Eve"
|
||||||
|
},
|
||||||
|
"dynamic": {
|
||||||
|
"11/23/2023": "Thanksgiving Day",
|
||||||
|
"01/15/2024": "MLK Day",
|
||||||
|
"02/14/2024": "Ash Wednesday",
|
||||||
|
"02/19/2024": "Presidents Day",
|
||||||
|
"03/24/2024": "Palm Sunday",
|
||||||
|
"03/29/2024": "Good Friday",
|
||||||
|
"03/31/2024": "Easter Sunday",
|
||||||
|
"04/22/2024": "Memorial Day",
|
||||||
|
"05/12/2024": "Mothers Day",
|
||||||
|
"06/16/2024": "Fathers Day",
|
||||||
|
"09/02/2024": "Labor Day",
|
||||||
|
"10/14/2024": "Columbus Day",
|
||||||
|
"11/28/2024": "Thanksgiving Day",
|
||||||
|
"01/20/2025": "MLK Day",
|
||||||
|
"02/17/2025": "Presidents Day",
|
||||||
|
"03/05/2025": "Ash Wednesday",
|
||||||
|
"04/13/2025": "Palm Sunday",
|
||||||
|
"04/18/2025": "Good Friday",
|
||||||
|
"04/20/2025": "Easter Sunday",
|
||||||
|
"04/21/2025": "Memorial Day",
|
||||||
|
"05/11/2025": "Mothers Day",
|
||||||
|
"06/15/2025": "Fathers Day",
|
||||||
|
"09/01/2025": "Labor Day",
|
||||||
|
"10/13/2025": "Columbus Day",
|
||||||
|
"11/27/2025": "Thanksgiving Day",
|
||||||
|
"01/19/2026": "MLK Day",
|
||||||
|
"02/16/2026": "Presidents Day",
|
||||||
|
"02/18/2026": "Ash Wednesday",
|
||||||
|
"03/29/2026": "Palm Sunday",
|
||||||
|
"04/03/2026": "Good Friday",
|
||||||
|
"04/05/2026": "Easter Sunday",
|
||||||
|
"04/20/2026": "Memorial Day",
|
||||||
|
"05/10/2026": "Mothers Day",
|
||||||
|
"06/21/2026": "Fathers Day",
|
||||||
|
"09/07/2026": "Labor Day",
|
||||||
|
"10/12/2026": "Columbus Day",
|
||||||
|
"11/26/2026": "Thanksgiving Day",
|
||||||
|
"01/18/2027": "MLK Day",
|
||||||
|
"02/10/2027": "Ash Wednesday",
|
||||||
|
"02/15/2027": "Presidents Day",
|
||||||
|
"03/21/2027": "Palm Sunday",
|
||||||
|
"03/26/2027": "Good Friday",
|
||||||
|
"03/28/2027": "Easter Sunday",
|
||||||
|
"04/19/2027": "Memorial Day",
|
||||||
|
"05/09/2027": "Mothers Day",
|
||||||
|
"06/20/2027": "Fathers Day",
|
||||||
|
"09/06/2027": "Labor Day",
|
||||||
|
"10/11/2027": "Columbus Day",
|
||||||
|
"11/25/2027": "Thanksgiving Day",
|
||||||
|
"01/17/2028": "MLK Day",
|
||||||
|
"02/21/2028": "Presidents Day",
|
||||||
|
"03/01/2028": "Ash Wednesday",
|
||||||
|
"04/09/2028": "Palm Sunday",
|
||||||
|
"04/14/2028": "Good Friday",
|
||||||
|
"04/16/2028": "Easter Sunday",
|
||||||
|
"04/17/2028": "Memorial Day",
|
||||||
|
"05/14/2028": "Mothers Day",
|
||||||
|
"06/18/2028": "Fathers Day",
|
||||||
|
"09/04/2028": "Labor Day",
|
||||||
|
"10/09/2028": "Columbus Day",
|
||||||
|
"11/23/2028": "Thanksgiving Day",
|
||||||
|
"01/15/2029": "MLK Day",
|
||||||
|
"02/14/2029": "Ash Wednesday",
|
||||||
|
"02/19/2029": "Presidents Day",
|
||||||
|
"03/25/2029": "Palm Sunday",
|
||||||
|
"03/30/2029": "Good Friday",
|
||||||
|
"04/01/2029": "Easter Sunday",
|
||||||
|
"04/23/2029": "Memorial Day",
|
||||||
|
"05/13/2029": "Mothers Day",
|
||||||
|
"06/17/2029": "Fathers Day",
|
||||||
|
"09/03/2029": "Labor Day",
|
||||||
|
"10/08/2029": "Columbus Day",
|
||||||
|
"11/22/2029": "Thanksgiving Day",
|
||||||
|
"01/21/2030": "MLK Day",
|
||||||
|
"02/18/2030": "Presidents Day",
|
||||||
|
"03/06/2030": "Ash Wednesday",
|
||||||
|
"04/14/2030": "Palm Sunday",
|
||||||
|
"04/19/2030": "Good Friday",
|
||||||
|
"04/21/2030": "Easter Sunday",
|
||||||
|
"04/22/2030": "Memorial Day",
|
||||||
|
"05/12/2030": "Mothers Day",
|
||||||
|
"06/16/2030": "Fathers Day",
|
||||||
|
"09/02/2030": "Labor Day",
|
||||||
|
"10/14/2030": "Columbus Day",
|
||||||
|
"11/28/2030": "Thanksgiving Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user