> {# Weather Briefing #} {%- macro getReport() -%}

{% if is_state('input_boolean.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 %}

{{ states('sensor.current_conditions_detail') }}

{{ states('sensor.tomorrow_forecast_detail') }}

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

{% 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 %}

{%- 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 -%} {%- endmacro -%} {# a macro to call all macros :) #} {%- macro mother_of_all_macros() -%} {{ getReport() }} {%- endmacro -%} {# Call the macro #} {{- cleanup(mother_of_all_macros()) -}}