Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 103101

Hourly Weather Forecast

$
0
0

Hello. I have a template which checks the next 8 hour weather condition and writes down if it is going to rain or not. What I wonder is can we include other rainy situations like lightning rain to the code ? I would like it to check all conditions and inform me.

{%- set ns = namespace (z=[]) %}
{%- for i in state_attr('weather.home_hourly', 'forecast') %}
  {%- if i.condition == 'rainy' %} {% set ns.z = ns.z + [ (as_timestamp(i.datetime) | timestamp_custom('%-I%p')) ] %} {% endif %}
{%- endfor%}
{%- if ns.z|length > 0 %}
It is going to rain at {% for x in ns.z %}
  {%- if ns.z|length > 1 %}
    {%- if loop.last %} and {% endif -%}
  {% endif -%}
  {{ x }}
  {%- if ns.z|length > 2 %}
    {%- if loop.index+1 < (ns.z|length) %}, {% endif -%}
  {% endif -%}
{% endfor %}
{% else -%}
There is no rain forecast.
{% endif -%}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 103101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>