From 93e4627a83a00f3edd126c53e76b5145f2b0d508 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 16 Jan 2023 19:44:53 -0500 Subject: [PATCH] Overhaul presentation of general weather information --- packages/custom_weather.yaml | 80 +++++++++++++------ templates/speech/daily_briefing.yaml | 51 +++++------- templates/speech/kallen_morning_briefing.yaml | 52 +----------- templates/speech/morning_briefing.yaml | 5 +- 4 files changed, 80 insertions(+), 108 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 384c352..6da20dd 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -27,6 +27,20 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.hot_day_threshold') | int }}" + - binary_sensor: + - name: Heat Index Threshold + state: > + {% set feelslike = states('sensor.pirateweather_apparent_temperature') | int %} + {% set threshold = states('input_number.heat_index_threshold') | int %} + {% if feelslike >= threshold %} + true + {% else %} + false + {% endif %} + device_class: heat + attributes: + current_temp: "{{ states('sensor.pirateweather_apparent_temperature') | int }}" + threshold: "{{ states('input_number.heat_index_threshold') | int }}" - binary_sensor: - name: Cold Threshold state: > @@ -41,6 +55,20 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.cold_day_threshold') | int }}" + - binary_sensor: + - name: Wind Chill Threshold + state: > + {% set feelslike = states('sensor.pirateweather_apparent_temperature') | int %} + {% set threshold = states('input_number.wind_chill_threshold') | int %} + {% if feelslike <= threshold %} + true + {% else %} + false + {% endif %} + device_class: cold + attributes: + current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" + threshold: "{{ states('input_number.wind_chill_threshold') | int }}" sensor: - platform: weatheralerts @@ -492,8 +520,7 @@ sensor: 'Rainfall accumulations ', 'Total Rainfall amounts ' ] | random }} - near {{ state_attr('sensor.current_forecast','precipitation') }} inches - possible. + near {{ state_attr('sensor.current_forecast','precipitation') }} inches possible. {%- elif states('sensor.current_forecast') == 'snowy' %} {{ [ 'with snow. ', @@ -510,8 +537,7 @@ sensor: 'with mix preciptation possible. ', 'with snow and rain showers. ' ] | random }} - Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches - possible. + Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches possible. {%- elif states('sensor.current_forecast') == 'windy' %} {{ [ 'and windy. ', @@ -561,26 +587,26 @@ sensor: 'Overnight expect a low of ' ] | random }} {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. - {%- else -%} - {{ [ - 'Tonight expect a low of ', - 'Overnight expect a low of ' - ] | random }} - {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. - {% endif %} + {%- else -%} + {{ [ + 'Tonight expect a low of ', + 'Overnight expect a low of ' + ] | random }} + {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. + {% endif %} {%- endmacro -%} {# a macro that removes all newline characters, empty spaces, and returns formatted text #} - {%- macro cleanup(data) -%} - {%- for item in data.split("\n") if item | trim != "" -%} - {{ item | trim }} {% endfor -%} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} {%- endmacro -%} {# a macro to call all macros :) #} - {%- macro mother_of_all_macros() -%} - {{ getReport() }} - {%- endmacro -%} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} - {# Call the macro #} - {{- cleanup(mother_of_all_macros()) -}} + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} outside_pressure: friendly_name: 'Outside Pressure' value_template: '{{ state_attr(''weather.iron_nerd_weather_station'',''pressure'') }}' @@ -690,10 +716,12 @@ sensor: {% else %} It is going to be {{ states('sensor.clothing_forecast') }} today so I suggest wearing shorts. {% endif %} - {% set high = state_attr('sensor.current_forecast','high_temp') %} - {% if high > 85 %} + {% if is_state('input_boolean.hot_day','on') %} Warning, today will be a very sweaty day, so please remember to stay hydrated! {% endif %} + {% if is_state('input_boolean.cold_day','on') %} + Warning, today will be excessively cold, please make sure all exposed skin is covered to avoid frostbite! + {% endif %} {% else %} Based on the current temperature, {% if is_state('sensor.clothing_forecast', 'Freezing') %} @@ -753,13 +781,15 @@ sensor: {% else %} It is {{ states('sensor.clothing_forecast') }} right now so I suggest wearing shorts. {% endif %} - {% set heatindex = states('sensor.pirateweather_apparent_temperature') | float | round %} - {% if heatindex > 90 %} - Warning, the heat index is {{ heatindex }} degrees right now, which is very high. So please make sure to stay hydrated! + {% if is_state('binary_sensor.heat_index_threshold','on') %} + Warning, the heat index is {{ states('sensor.pirateweather_apparent_temperature') | float | round }} degrees right now, which is very high. So please make sure to stay hydrated! + {% endif %} + {% if is_state('binary_sensor.wind_chill_threshold','on') %} + Warning, it currently feels like {{ states('sensor.pirateweather_apparent_temperature') | float | round }} degrees outside, so please make sure all exposed skin is covered to avoid frostbite! {% endif %} {% endif %} {% if states('sensor.thermal_comfort_simmerindex') in ['extremely_warm','danger_of_heatstroke','extreme_danger_of_heatstroke','circulatory_collapse_imminent'] %} - "To reiterate, it is dangerously hot outside! " + "To reiterate, the current weather is dangerously hot! " {% endif %} {% if is_state('sensor.thermal_comfort_perception','somewhat_uncomfortable') %} "The humidity is somewhat uncomfortable outside." diff --git a/templates/speech/daily_briefing.yaml b/templates/speech/daily_briefing.yaml index 7498184..db9a00b 100644 --- a/templates/speech/daily_briefing.yaml +++ b/templates/speech/daily_briefing.yaml @@ -22,38 +22,7 @@ {% endif %}

- The weather in Defiance is {{ state_attr('weather.iron_nerd_weather_station','temperature') | round }} degrees - {% if is_state('weather.iron_nerd_weather_station','rainy') %} - {{ [ - 'with rain.', - 'with showers.' - ] | random }} - {% elif is_state('weather.iron_nerd_weather_station','cloudy') %} - {{ [ - 'with clouds.', - 'with cloudy skies.' - ] | random }} - {% elif is_state('weather.iron_nerd_weather_station','partlycloudy') %} - {{ [ - 'with some clouds.', - 'with partly cloudy skies.', - 'with scattered clouds.' - ] | random }} - {% elif is_state('weather.iron_nerd_weather_station','sunny') %} - {% if is_state('sun.sun','above_horizon') %} - {{ [ - 'and sunny.', - 'with sun.' - ] | random }} - {% else %} - {{ [ - 'and clear.', - 'with clear skies.' - ] | random }} - {% endif %} - {% else %} - and {{ states.weather.iron_nerd_weather_station.state }} - {% endif %} + {{ states('sensor.current_conditions_detail') }} {% if states('sensor.weatheralerts_active_alerts') > '0' %} "Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weatheralerts_active_alerts') }}. They are as follows. " @@ -75,6 +44,24 @@ {% endif %}

+

+ {{ [ + 'The weather for the rest of today should be,', + 'The forecast for the rest of the day is,', + 'Through the rest of your day, the weather is expected to be,' + ] | random }} + {{ states.sensor.current_forecast.state }} +

+ +

+ {{ [ + 'Just in case you were planning on going anywhere,', + 'On the off chance that you planned to go outside,', + 'If you were planning to go out and do something with your life,', + ] | random }} + {{ states('sensor.clothing_forecast_detail') }} +

+

{% if is_state('sun.sun','below_horizon') %} You have diff --git a/templates/speech/kallen_morning_briefing.yaml b/templates/speech/kallen_morning_briefing.yaml index db500de..1825b78 100644 --- a/templates/speech/kallen_morning_briefing.yaml +++ b/templates/speech/kallen_morning_briefing.yaml @@ -20,56 +20,8 @@

- {% if is_state('sensor.clothing_forecast', 'Freezing') %} - It is going to be freezing today. so I suggest wearing long pants and a heavy coat. - {% elif is_state('sensor.clothing_forecast','Cold') %} - It is going to be cold today. so I suggest wearing long pants and a light jacket. - {% elif is_state('sensor.clothing_forecast', 'Chilly') %} - It is going to be chilly today. so I suggest wearing at least long pants. - {% elif is_state('sensor.clothing_forecast', 'Nice') %} - It is going to be - {{ [ 'pretty nice outside. ', - 'a good day to be outside. ', - 'rather enjoyable outside. ', - ] | random }} - So I suggest wearing shorts. - {% elif is_state('sensor.clothing_forecast', 'Toasty') and is_state('sensor.current_forecast','sunny') %} - It is going to be - {{ [ ' rather warm outside. ', - ' almost too hot outside. ', - ' a little warm today. ', - ] | random }} - and very sunny, so I suggest wearing shorts and maybe some sunscreen. - {% elif is_state('sensor.clothing_forecast', 'Hot') and is_state('sensor.current_forecast','sunny') %} - It is going to be - {{ [ 'hotter than the sun today. ', - 'hotter than the sun outside. ', - 'super hot today. ', - 'hotter than the inside of a volcano today. Well not exactly, but you get the point. ' - ] | random }} - and very sunny, so I suggest wearing shorts and maybe some sunscreen. - {% elif is_state('sensor.clothing_forecast', 'Toasty') %} - It is going to be - {{ [ ' rather warm outside. ', - ' almost too hot outside. ', - ' a little warm today. ', - ] | random }} - So I suggest wearing shorts. - {% elif is_state('sensor.clothing_forecast', 'Hot') %} - It is going to be - {{ [ 'hotter than the sun today. ', - 'hotter than the sun outside. ', - 'super hot today. ', - 'hotter than the inside of a volcano today. Well not exactly, but you get the point. ' - ] | random }} - So I suggest wearing shorts. - {% else %} - It is going to be {{ states.sensor.clothing_forecast.state }} today so I suggest wearing shorts. - {% endif %} - {% set hightemp = state_attr('sensor.current_forecast','high_temp') | float %} - {% if hightemp > 84 %} - Warning, today will be a very sweaty day, so you need to remember to stay hydrated. - {% endif %} + Today the high temperature will be {{ state_attr('sensor.current_forecast','high_temp') }} degrees. + {{ states('sensor.clothing_forecast_detail') }}

diff --git a/templates/speech/morning_briefing.yaml b/templates/speech/morning_briefing.yaml index 9109e85..bfcef55 100644 --- a/templates/speech/morning_briefing.yaml +++ b/templates/speech/morning_briefing.yaml @@ -66,7 +66,10 @@ 'The rest of the day should be,', 'Todays forecast should be ,' ]|random }} - {{ states.sensor.current_forecast.state }} + {{ states('sensor.current_forecast') }} +

+

+ {{ states('sensor.clothing_forecast_detail') }}

{% if is_state('sensor.halloween_countdown','0') %}