From 0fb170615597eb898abf59a2b75fda1ad27db31d Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 25 Jul 2023 12:54:09 -0400 Subject: [PATCH] This time it's the National Weather Service being unreliable... #89 --- custom_templates/weather.jinja | 6 ++--- packages/custom_weather.yaml | 28 ++++++++++++++++++--- templates/speech/weather_briefing_full.yaml | 2 +- templates/speech/welcome_home.yaml | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/custom_templates/weather.jinja b/custom_templates/weather.jinja index a04fb81..945e9a2 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.kdfi_visibility') | int < 3 %} - Caution: Current outdoor visibility is {{ states('sensor.kdfi_visibility') }} miles. + {% if states('sensor.pirateweather_visibility') | int < 3 %} + Caution: Current outdoor visibility is {{ states('sensor.pirateweather_visibility') }} miles. {% endif %} {% endif %} {% elif method == 'tts' %} @@ -56,7 +56,7 @@ ] | random }} "The nearest lightning strike is {{ ltgdist }} miles away. " {% endif %} - {% if (states('sensor.kdfi_visibility') | int ) < 3 %} + {% if (states('sensor.pirateweather_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/packages/custom_weather.yaml b/packages/custom_weather.yaml index e2172b2..c1fc4de 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -15,12 +15,22 @@ weather: {% else %} {{ state_attr('weather.weatherapi_stratton_ave','forecast') }} {% endif %} - pressure_template: "{{ states('sensor.kdfi_barometric_pressure') | float }}" + pressure_template: > + {% if states('sensor.kdfi_barometric_pressure') %} + {{ states('sensor.kdfi_barometric_pressure') }} + {% else %} + {{ states('sensor.myradar_pressure') | float }} + {% endif %} pressure_unit: inHg wind_speed_template: "{{ states('sensor.pirateweather_wind_speed') | float }}" wind_speed_unit: mph wind_bearing_template: "{{ states('sensor.pirateweather_wind_bearing') | float }}" - visibility_template: "{{ states('sensor.kdfi_visibility') | float }}" + visibility_template: > + {% if states('sensor.kdfi_visibility') %} + {{ states('sensor.kdfi_visibility') | float }} + {% else %} + {{ states('sensor.pirateweather_visibility') }} + {% endif %} visibility_unit: mi attribution_template: "Daily weather data from Iron Nerd's custom weather station template" ozone_template: "{{ states('sensor.pirateweather_ozone') | float }}" @@ -38,12 +48,22 @@ weather: {% else %} {{ state_attr('weather.iron_nerd_studios_hourly','forecast') }} {% endif %} - pressure_template: "{{ states('sensor.kdfi_barometric_pressure') | float }}" + pressure_template: > + {% if states('sensor.kdfi_barometric_pressure') %} + {{ states('sensor.kdfi_barometric_pressure') }} + {% else %} + {{ states('sensor.myradar_pressure') | float }} + {% endif %} pressure_unit: inHg wind_speed_template: "{{ states('sensor.pirateweather_wind_speed') | float }}" wind_speed_unit: mph wind_bearing_template: "{{ states('sensor.pirateweather_wind_bearing') | float }}" - visibility_template: "{{ states('sensor.kdfi_visibility') | float }}" + visibility_template: > + {% if states('sensor.kdfi_visibility') %} + {{ states('sensor.kdfi_visibility') | float }} + {% else %} + {{ states('sensor.pirateweather_visibility') }} + {% endif %} visibility_unit: mi attribution_template: "Hourly weather data from Iron Nerd's custom weather station template" ozone_template: "{{ states('sensor.pirateweather_ozone') | float }}" diff --git a/templates/speech/weather_briefing_full.yaml b/templates/speech/weather_briefing_full.yaml index 56d9de4..01a1c4d 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.kdfi_visibility') | int ) < 3 %} + {% if (states('sensor.pirateweather_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 4461bcb..9cdaa80 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.kdfi_visibility') | int ) < 3 %} + {% if (states('sensor.pirateweather_visibility') | int ) < 3 %} "In case you are planning to go back out, " {{ [ "It is foggy outside, please exercise caution when driving. ",