Huge improvements to weather briefings

This commit is contained in:
2023-05-30 16:54:52 -04:00
parent adc25928d2
commit 1c4b414915
5 changed files with 90 additions and 156 deletions

View File

@ -1,29 +1,82 @@
{% macro weatherReport(time,method) %} {% macro weatherReport(type,method,time) %}
{% from 'time.jinja' import ct %} {% from 'time.jinja' import ct %}
{% set ct = ct() | int %} {% set ct = ct() | int %}
{% if time in ['current','full'] %} {% set time = time|default('day') %}
The current weather is {{ states('sensor.pirateweather_summary') | lower }}. It is {{ state_attr('weather.iron_nerd_weather_station','temperature') | round }} degrees outside and feels like {{ states('sensor.pirateweather_apparent_temperature') | round }} degrees. {% if method == 'text' %}
{% if method == 'tts' %} {% if type in ['current','full'] %}
{% if is_state('binary_sensor.heat_threshold','on') %} The current weather is {{ states('weather.iron_nerd_weather_station') | lower }}. It is {{ state_attr('weather.iron_nerd_weather_station','temperature') | round }} degrees outside and feels like {{ states('sensor.pirateweather_apparent_temperature') | round }} degrees.
It is very hot outside, so be careful if you have to venture out. {% endif %}
{% elif is_state('binary_sensor.cold_threshold','on') %} {% if type in ['forecast','full'] %}
It is very cold outside, so be careful if you have to venture out. {% if 14400 <= ct <= 61200 %}
The forecast high is {{ states('sensor.todays_high_temp') }}.
{% else %}
Overnight you can expect a low of {{ states('sensor.overnight_lowest_temperature') }}.
{% endif %}
{% if is_state('binary_sensor.early_night_mode','on') %}For tonight{% else %}For the rest of the day{% endif %}, the conditions are expected to be {{ state_attr('sensor.current_forecast','friendly') }}.
{% endif %}
{% if type in ['alerts','full'] %}
{% if is_state('input_boolean.tornado_alarm','on') %}
We are under a tornado warning. If you are not already in shelter, you should be. Get on it!
{% elif states('sensor.weatheralerts_active_alerts') > '0' %}
Current weather alerts: {{ states('sensor.weather_alert_string') }}.
{% endif %}
{% if is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
There is lightning in the area. Nearest strike is {{ ltgdist }} away.
{% endif %}
{% if states('sensor.kdfi_visibility') | int < 3 %}
Caution: Current outdoor visibility is {{ states('sensor.kdfi_visibility') }} miles.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% elif method == 'tts' %}
{% if time in ['forecast','full'] %} {% if type in ['alerts','full'] %}
{% if 14400 <= ct <= 61200 %} {% if states('sensor.weatheralerts_active_alerts') > '0' %}
The forecast high is {{ states('sensor.todays_high_temp') }}. "Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weather_alerts_active_corrected') }}. They are as follows. "
{% if method == 'tts' %} {{ states('sensor.weather_alert_string') }}.
{% if is_state('input_boolean.hot_day','on') %} {% endif %}
It is going to be a very hot day, so be careful if you are going outside! {% if is_state('input_boolean.tornado_alarm','on') %}
{% elif is_state('input_boolean.cold_day','on') %} "We are under a tornado warning. If you are not already in shelter, you should be. Get on it! "
It is going to be a very cold day, so be careful if you are going outside! {% elif is_state('input_boolean.tornado_watch','on') %}
{% endif %} {{ [
"There is currently a tornado watch active. Please keep an eye on the sky and your local weather reports. ",
"We are currently under a tornado watch. This means the possibility exists for a tornado to form. Be prepared, and be safe! ",
"The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }}
{% endif %}
{% if is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [
"There are reports of lightning in the area, please stay safe. ",
"My sensors detect the presence of lightning nearby, so you should prepare to take shelter if needed. ",
"A little birdy told me there is lightning nearby. His feathers were all sticking up, I have no idea why. ",
"Please exercise caution, as there is lightning in the area. ",
"That flashing in the sky is not interstellar warfare, it is simply lightning. But you should still be careful outside. ",
] | random }}
"The nearest lightning strike is {{ ltgdist }} miles away. "
{% endif %}
{% if (states('sensor.kdfi_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. ",
"It is pea soup outside right now, and that is just as awful to drive in as it is to eat. Be careful! ",
"Look out the window. Do you notice that you cannot see anything? Bear that in mind if you intend to drive any time soon. ",
"Be advised, it is very difficult to see outside right now. Drive safely. "
] | random }}
{% endif %} {% endif %}
{% else %}
Overnight you can expect a low of {{ states('sensor.overnight_lowest_temperature') }}.
{% endif %} {% endif %}
Later {% if is_state('binary_sensor.early_night_mode','on') %}tonight{% else %}today{% endif %}, the conditions are expected to be {{ states('sensor.current_forecast') }}.
{% if type in ['current','full'] %}
{{ states('sensor.current_conditions_detail') }}
{% elif type == 'forecast' %}
{{ states('sensor.current_forecast_detail') }}
{% endif %}
{% if time in ['morning','day'] and type != 'alerts' %}
{{ [
'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') }}
{% endif %}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}

View File

@ -171,6 +171,9 @@ sensor:
precipitation: >- precipitation: >-
{% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %}
{{ forecast.precipitation }} {{ forecast.precipitation }}
friendly: >-
{% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %}
{{ forecast.condition | replace("partlycloudy","partly cloudy") }}
current_forecast_detail: current_forecast_detail:
friendly_name: Current Forecast Detail friendly_name: Current Forecast Detail
unique_id: e5ae9864-70b5-402c-9d2f-c4d6a10085df unique_id: e5ae9864-70b5-402c-9d2f-c4d6a10085df
@ -522,7 +525,7 @@ sensor:
{% else %} {% else %}
and {{ states.weather.iron_nerd_weather_station.state }} and {{ states.weather.iron_nerd_weather_station.state }}
{% endif %} {% endif %}
{%- if is_state('binary_sensor.night','off')%} {%- if is_state('binary_sensor.early_night_mode','off')%}
{{ [ {{ [
'Later Today ', 'Later Today ',
'For the rest of the day ' 'For the rest of the day '
@ -826,7 +829,7 @@ sensor:
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if states('sensor.thermal_comfort_simmerindex') in ['extremely_warm','danger_of_heatstroke','extreme_danger_of_heatstroke','circulatory_collapse_imminent'] %} {% if states('sensor.thermal_comfort_simmerindex') in ['extremely_warm','danger_of_heatstroke','extreme_danger_of_heatstroke','circulatory_collapse_imminent'] %}
"To reiterate, the current weather is dangerously hot! " "I cannot stress this enough, the current weather is dangerously hot! "
{% endif %} {% endif %}
{% if is_state('sensor.thermal_comfort_perception','somewhat_uncomfortable') %} {% if is_state('sensor.thermal_comfort_perception','somewhat_uncomfortable') %}
"The humidity is somewhat uncomfortable outside." "The humidity is somewhat uncomfortable outside."

View File

@ -5,63 +5,13 @@
{% from 'time.jinja' import input_datetime_12hr %} {% from 'time.jinja' import input_datetime_12hr %}
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
{% from 'easy_time.jinja' import count_the_days %} {% from 'easy_time.jinja' import count_the_days %}
{% from 'weather.jinja' import weatherReport %}
<p> <p>
{{ greeting() }} {{ greeting() }}
</p> </p>
<p> <p>
{% if is_state('input_boolean.tornado_alarm','on') %} {{ weatherReport('full','tts','day') }}
"We are under a tornado warning. If you are not already in shelter, you should be. Get on it! "
{% elif is_state('input_boolean.tornado_watch','on') %}
{{ [
"There is currently a tornado watch active. Please keep an eye on the sky and your local weather reports. ",
"We are currently under a tornado watch. This means the possibility exists for a tornado to form. Be prepared, and be safe! ",
"The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }}
{% endif %}
{% if is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [
"There are reports of lightning in the area, please stay safe. ",
"My sensors detect the presence of lightning nearby, so you should prepare to take shelter if needed. ",
"A little birdy told me there is lightning nearby. His feathers were all sticking up, I have no idea why. ",
"Please exercise caution, as there is lightning in the area. ",
"That flashing in the sky is not interstellar warfare, it is simply lightning. But you should still be careful outside. ",
] | random }}
"The nearest lightning strike is {{ ltgdist }} miles away. "
{% endif %}
{% if states('sensor.weatheralerts_active_alerts') > '0' %}
"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 %}
{{ [
"It is foggy outside, please exercise caution when driving. ",
"The visibility outside is quite low. If you will be driving soon, please be cautious. ",
"It is pea soup outside right now, and that is just as awful to drive in as it is to eat. Be careful! ",
"Look out the window. Do you notice that you cannot see anything? Bear that in mind if you intend to drive any time soon. ",
"Be advised, it is very difficult to see outside right now. Drive safely. "
] | random }}
{% endif %}
{{ states('sensor.current_conditions_detail') }}
</p>
<p>
{{ [
'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 }}
</p>
<p>
{{ [
'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') }}
</p> </p>
<p> <p>

View File

@ -5,6 +5,7 @@
{% from 'time.jinja' import input_datetime_12hr %} {% from 'time.jinja' import input_datetime_12hr %}
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
{% from 'easy_time.jinja' import count_the_days %} {% from 'easy_time.jinja' import count_the_days %}
{% from 'weather.jinja' import weatherReport %}
<p> <p>
{{ greeting_nodate() }} {{ greeting_nodate() }}
</p> </p>
@ -17,54 +18,11 @@
]|random }} ]|random }}
{{states.sensor.today_is.state }}. {{states.sensor.today_is.state }}.
</p> </p>
<p> <p>
It is currently {{states.weather.iron_nerd_weather_station.state}} and {{states.sensor.pirateweather_temperature.state|round}} degrees in Defiance. {{ weatherReport('full','tts','morning') }}
</p>
<p>
{% if is_state('input_boolean.tornado_alarm','on') %}
"We are under a tornado warning. If you are not already in shelter, you should be. Get on it! "
{% elif is_state('input_boolean.tornado_watch','on') %}
{{ [
"There is currently a tornado watch active. Please keep an eye on the sky and your local weather reports. ",
"We are currently under a tornado watch. This means the possibility exists for a tornado to form. Be prepared, and be safe! ",
"The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }}
{% endif %}
{% if is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [
"There are reports of lightning in the area, please stay safe. ",
"My sensors detect the presence of lightning nearby, so you should prepare to take shelter if needed. ",
"A little birdy told me there is lightning nearby. His feathers were all sticking up, I have no idea why. ",
"Please exercise caution, as there is lightning in the area. ",
"That flashing in the sky is not interstellar warfare, it is simply lightning. But you should still be careful outside. ",
] | random }}
"The nearest lightning strike is {{ ltgdist }} miles away. "
{% endif %}
{% if states('sensor.weatheralerts_active_alerts') > '0' %}
"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 %}
{{ [
"It is foggy outside, please exercise caution when driving. ",
"The visibility outside is quite low. If you will be driving soon, please be cautious. ",
"It is pea soup outside right now, and that is just as awful to drive in as it is to eat. Be careful! ",
"Look out the window. Do you notice that you cannot see anything? Bear that in mind if you intend to drive any time soon. ",
"Be advised, it is very difficult to see outside right now. Drive safely. "
] | random }}
{% endif %}
</p>
<p>
{{ [
'The rest of the day should be,',
'Todays forecast should be ,'
]|random }}
{{ states('sensor.current_forecast') }}
</p>
<p>
{{ states('sensor.clothing_forecast_detail') }}
</p> </p>
<p> <p>
{% if is_state('sensor.halloween_countdown','0') %} {% if is_state('sensor.halloween_countdown','0') %}
Happy Halloween! Happy Halloween!

View File

@ -5,6 +5,7 @@
{% from 'time.jinja' import input_datetime_12hr, read_time_from_calendar, next_twitch_stream %} {% from 'time.jinja' import input_datetime_12hr, read_time_from_calendar, next_twitch_stream %}
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
{% from 'easy_time.jinja' import count_the_days %} {% from 'easy_time.jinja' import count_the_days %}
{% from 'weather.jinja' import weatherReport %}
<p> <p>
{{ greeting() }} {{ greeting() }}
</p> </p>
@ -16,42 +17,11 @@
"My programmer decided that I should say something interesting here, and then he realized that he is not interesting. ", "My programmer decided that I should say something interesting here, and then he realized that he is not interesting. ",
] | random }} ] | random }}
</p> </p>
<p> <p>
{% if is_state('input_boolean.tornado_alarm','on') %} {{ weatherReport('full','tts','night') }}
"We are under a tornado warning. If you are not already in shelter, you should be. Get on it! "
{% elif is_state('input_boolean.tornado_watch','on') %}
{{ [
"There is currently a tornado watch active. Please keep an eye on the sky and your local weather reports. ",
"We are currently under a tornado watch. This means the possibility exists for a tornado to form. Be prepared, and be safe! ",
"The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }}
{% endif %}
{% if states('sensor.weatheralerts_active_alerts') > '0' %}
"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 is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [
"There are reports of lightning in the area, please stay safe. ",
"My sensors detect the presence of lightning nearby, so you should prepare to take shelter if needed. ",
"A little birdy told me there is lightning nearby. His feathers were all sticking up, I have no idea why. ",
"Please exercise caution, as there is lightning in the area. ",
"That flashing in the sky is not interstellar warfare, it is simply lightning. But you should still be careful outside. ",
] | random }}
"The nearest lightning strike is {{ ltgdist }} miles away. "
{% endif %}
{% if (states('sensor.kdfi_visibility') | int ) < 3 %}
"I know it is night time, but just in case, "
{{ [
"It is foggy outside, please exercise caution when driving. ",
"The visibility outside is quite low. If you will be driving soon, please be cautious. ",
"It is pea soup outside right now, and that is just as awful to drive in as it is to eat. Be careful! ",
"Look out the window. Do you notice that you cannot see anything? Bear that in mind if you intend to drive any time soon. ",
"Be advised, it is very difficult to see outside right now. Drive safely. "
] | random }}
{% endif %}
</p> </p>
<p> <p>
{{ tonyStatusReport('stream','tts') }} {{ tonyStatusReport('stream','tts') }}
{% if is_state('binary_sensor.kallen_school_tomorrow','on') %} {% if is_state('binary_sensor.kallen_school_tomorrow','on') %}