From 348ea3905605f043ce940f486a4bc00734ce133d Mon Sep 17 00:00:00 2001 From: CCOSTAN Date: Wed, 18 Sep 2024 18:05:53 +0000 Subject: [PATCH] Lots of little bug fixes! #1141 --- config/packages/alexa_media_player.yaml | 2 +- config/packages/holiday.yaml | 32 ++++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/config/packages/alexa_media_player.yaml b/config/packages/alexa_media_player.yaml index 80a1b4dc..3c5f7dbf 100755 --- a/config/packages/alexa_media_player.yaml +++ b/config/packages/alexa_media_player.yaml @@ -9,7 +9,7 @@ sensor: sensors: last_alexa: value_template: > - {{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }} + {{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first | default('none') }} #------------------------------------------- diff --git a/config/packages/holiday.yaml b/config/packages/holiday.yaml index 4060fdf0..2261ddc2 100755 --- a/config/packages/holiday.yaml +++ b/config/packages/holiday.yaml @@ -40,27 +40,31 @@ sensor: {{ holiday }} ################################################################################ -# Sensor Uses Flag data from this calendar - http://www.webcal.fi/en-US/flag_days.php +# 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') %} - {% 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 %} + {% 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 %} - False + {% endif %} ################################################################################