From 9c12f6458633b0089161ce21bcbc2cdf8d118305 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sat, 29 Jul 2023 14:26:19 -0400 Subject: [PATCH] Make weather more resilient to failures #89 --- custom_templates/weather.jinja | 6 +++--- node-red/projects/NerdFlows | 2 +- packages/emmalynn.yaml | 9 +++------ templates/speech/kallen_morning_briefing.yaml | 8 +++++++- templates/speech/weather_briefing_full.yaml | 2 +- templates/speech/welcome_home.yaml | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/custom_templates/weather.jinja b/custom_templates/weather.jinja index 945e9a2..91ca843 100644 --- a/custom_templates/weather.jinja +++ b/custom_templates/weather.jinja @@ -26,8 +26,8 @@ {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} There is lightning in the area. Nearest strike is {{ ltgdist }} miles away. {% endif %} - {% if states('sensor.pirateweather_visibility') | int < 3 %} - Caution: Current outdoor visibility is {{ states('sensor.pirateweather_visibility') }} miles. + {% if state_attr('weather.iron_nerd_weather_station','visibility') | int < 3 %} + Caution: Current outdoor visibility is {{ state_attr('weather.iron_nerd_weather_station','visibility') }} miles. {% endif %} {% endif %} {% elif method == 'tts' %} @@ -56,7 +56,7 @@ ] | random }} "The nearest lightning strike is {{ ltgdist }} miles away. " {% endif %} - {% if (states('sensor.pirateweather_visibility') | int ) < 3 %} + {% if (state_attr('weather.iron_nerd_weather_station','visibility') | int ) < 3 %} {{ [ "It is foggy outside, please exercise caution when driving. ", "The visibility outside is quite low. If you will be driving soon, please be cautious. ", diff --git a/node-red/projects/NerdFlows b/node-red/projects/NerdFlows index 06da714..07da66c 160000 --- a/node-red/projects/NerdFlows +++ b/node-red/projects/NerdFlows @@ -1 +1 @@ -Subproject commit 06da714a3bc81df5a6f37ba2cad85c3a69262d12 +Subproject commit 07da66c78655b0ffbaa6c6c89bacd51c9b73a199 diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 4ddd3e6..abf3124 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -201,11 +201,8 @@ automation: description: Sets the climate mode for when Emma goes down for nap mode: restart trigger: - - platform: state - entity_id: sensor.pirateweather_temperature - not_to: - - 'unavailable' - - 'unknown' + - platform: time_pattern + minutes: "/5" - platform: state entity_id: input_number.emma_naptime_aircon_threshold - platform: state @@ -223,7 +220,7 @@ automation: entity_id: input_select.naptime_climate_mode_emma_aircon data: option: > - {% set temp = states('sensor.pirateweather_temperature') | int %} + {% set temp = state_attr('weather.iron_nerd_weather_station','temperature') | int %} {% set threshold = states('input_number.emma_naptime_aircon_threshold') | int %} {% if (temp >= threshold) or is_state('input_boolean.hot_day','on') %} AC diff --git a/templates/speech/kallen_morning_briefing.yaml b/templates/speech/kallen_morning_briefing.yaml index 637d05d..f0f5b07 100644 --- a/templates/speech/kallen_morning_briefing.yaml +++ b/templates/speech/kallen_morning_briefing.yaml @@ -5,6 +5,12 @@ {% from 'time.jinja' import current_time, current_date_readout, input_datetime_read %} {% from 'speech.jinja' import dadjoke, inspirational_quote %} {% from 'easy_time.jinja' import count_the_days, custom_time %} + {% set precipTypes = [ + states.sensor.pirateweather_precip, + states.sensor.openweathermap_precipitation_kind, + states.sensor.tomorrow_io_stratton_ave_precipitation_type + ] %} + {% set snowing = precipTypes | selectattr('state','eq','snow') | map(attribute='state') | list | count | int %}

Good morning, Collin. @@ -164,7 +170,7 @@ {%- endif %} {% endif %} - {% if is_state ('input_boolean.kallen_school_today', 'off') and is_state('sensor.pirateweather_icon', 'snow') %} + {% if is_state ('input_boolean.kallen_school_today', 'off') and snowing > 0 %} Do you wanna build a snowman? It is snowing! {% endif %} diff --git a/templates/speech/weather_briefing_full.yaml b/templates/speech/weather_briefing_full.yaml index 01a1c4d..beea4a0 100644 --- a/templates/speech/weather_briefing_full.yaml +++ b/templates/speech/weather_briefing_full.yaml @@ -41,7 +41,7 @@ "Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weather_alerts_active_corrected') }}. They are as follows. " {{ states('sensor.weather_alert_string') }}. {% endif %} - {% if (states('sensor.pirateweather_visibility') | int ) < 3 %} + {% if (state_attr('weather.iron_nerd_weather_station','visibility') | int ) < 3 %} {{ [ "It is foggy outside, please exercise caution when driving. ", "The visibility outside is quite low. If you will be driving soon, please be cautious. ", diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 9cdaa80..1f86c2a 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -86,7 +86,7 @@ "Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weather_alerts_active_corrected') }}. They are as follows. " {{ states('sensor.weather_alert_string') }}. {% endif %} - {% if (states('sensor.pirateweather_visibility') | int ) < 3 %} + {% if (state_attr('weather.iron_nerd_weather_station','visibility') | int ) < 3 %} "In case you are planning to go back out, " {{ [ "It is foggy outside, please exercise caution when driving. ",