HAuser1234 / homeassistant-local-weather-forecast

Homeassistant local weather forecast. ~90% accurate*
GNU Affero General Public License v3.0
21 stars 7 forks source link

Error while processing template #7

Open derjoerg opened 6 months ago

derjoerg commented 6 months ago

Hi,

I receive several errors in home-assistant.log when using these sensors. Nevertheless, when I check the different parts in the developer-tools everything is working.

Am I do something wrong?

2024-01-02 14:33:08.006 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({# -----> pressure sensor (needed) <----- #} {% set pressure = states.sensor.water_01_pressure.state|float(0)%}
{# -----> pressure at sealevel: set to 1 else set to 0 (needed) <-----#} {% set pressure_sea = 0%}
{# -----> set height above sealevel in meters (only when pressure_sea = 0) <-----#} {% set height = 160%}
{# Calc pressure at sealevel -> p0 (if necessary)#} {% set temp = states.sensor.local_forecast.attributes.temperature|float(1)%} {% set p0 = pressure*pressure_sea-(pressure_sea-1)*pressure*(1-((0.0065*height)/(temp+(0.0065*height)+273.15)))**(-5.257)%} {{p0|round(1)}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 4, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1926, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'
2024-01-02 14:33:08.011 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({# Calc current condtions#} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set conditions = [('stürmisch','stormy','θυελλώδης'),('regnerisch','rainy','Βροχερός'),('wechselhaft','mixed','Μεταβλητός'),('sonnig','sunny','Ηλιόλουστος'),('sehr trocken','extra dry','Πολύ ξηρός')]%} {%set pressure_system = [('Tiefdruckgebiet','low pressure system','σύστημα χαμηλής πίεσης'),('Normal','normal','φυσιολογικός'),('Hochdruckgebiet','high pressure system','σύστημα υψηλής πίεσης')]%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {% if p0<980 %} {% set current_condtion = [conditions[0][language],pressure_system[0][language]]%} {% elif p0>=980 and p0<1000 %} {% set current_condtion = [conditions[1][language],pressure_system[0][language]]%} {% elif p0>=1000 and p0<1020 %} {% set current_condtion = [conditions[2][language],pressure_system[1][language]]%} {% elif p0>=1020 and p0<1040 %} {% set current_condtion = [conditions[3][language],pressure_system[2][language]]%} {% elif p0>=1040 %} {% set current_condtion = [conditions[4][language],pressure_system[2][language]]%} {%endif%} {{current_condtion}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'
2024-01-02 14:33:08.015 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({#get specific forecast num based on pressure trend#} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set windfak = states.sensor.local_forecast.attributes.wind_direction[0]|int(0)%} {%set windfak_speed = states.sensor.local_forecast.attributes.wind_direction[3]|int(0)%} {%if p0change<=(-1.0) %}{%set trend = '-1'%}{%elif p0change>=(1.0) %}{%set trend = '1'%}{%else%}{%set trend = '0'%}{%endif%} {# Calc forecast#} {%if trend == '-1' %} {# falling pressure#} {%set z = (127-0.12*p0)|round(0)|int(0)%} {%elif trend == '0'%} {# steady pressure#} {%set z = (144-0.13*p0)|round(0)|int(0)%} {#winter and summer adjustment#} {%if 2 < now().month < 11%} {%set z = z%}{#summer#}{%else%} {%set z = z-1%} {#winter#}{%endif%} {%elif trend == '1'%} {# rising pressure#} {%set z = (185-0.16*p0)|round(0)|int(0)%} {%if 2 < now().month < 11%} {%set z = z+1%}{#summer#}{%else%} {%set z = z%} {#winter#}{%endif%} {%endif%} {# wind factor #} {%set z = (z + windfak*windfak_speed) %}  {# generate report #} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set t_lang = [('Beständiges Schönwetter!','Settled Fine','Σταθερός καλός καιρός!'),('Schönes Wetter!','fine','Ωραίος καιρός!'),('Es wird schöner.','Becoming Fine','Θα καλυτερεύσει.'),('Schön, wird wechselhaft.','Fine Becoming Less Settled','Μεταβλητός.'),('Schön, Regenschauer möglich.','Fine, Possibly showers','Πιθανή βροχή.'),('Heiter bis wolkig, Besserung zu erwarten.','Fairly Fine, Improving','Αίθριος έως νεφελώδης, αναμένεται βελτίωση.'),('Heiter bis wolkig, anfangs evtl. Schauer.','Fairly Fine, Possibly showers, early','Αίθριος έως συννεφιασμένος, πιθανώς βροχές στην αρχή.'),('Heiter bis wolkig, später Regen.','Fairly Fine Showery Later','Αίθριος έως συννεφιασμένος, αργότερα βροχή.'),('Anfangs noch Schauer, dann Besserung.','Showery Early, Improving','Βροχόπτωση στην αρχή και μετά βελτίωση.'),('Wechselhaft mit Schauern','Changeable Mending','Εναλλαγή με βροχόπτωση.'),('Heiter bis wolkig, vereinzelt Regen.','Fairly Fine , Showers likely','Αίθριος έως συννεφιασμένος, κατά διαστήματα βροχή.'),('Unbeständig, später Aufklarung.','Rather Unsettled Clearing Later','Ασταθής, αργότερα καθάρος.'),('Unbeständig, evtl. Besserung.','Unsettled, Probably Improving','Ασταθής, πιθανώς βελτίωση.'),('Regnerisch mit heiteren Phasen.','Showery Bright Intervals','Καθαρός με διαστήματα βροχής.'),('Regnerisch, wird unbeständiger.','Showery Becoming more unsettled','Βροχερό, όλο και πιο ασταθές.'),('Wechselhaft mit etwas Regen.','Changeable some rain','Αλλάζει με λίγη βροχή.'),('Unbeständig mit heiteren Phasen.','Unsettled, short fine Intervals','Άστατα, μικρά καθαρά διαστήματα'),('Unbeständig, später Regen.','Unsettled, Rain later','Άστατη, αργότερα βροχή.'),('Unbeständig mit etwas Regen.','Unsettled, rain at times','Άστατος με λίγη βροχή.'),('Wechselhaft und regnerisch','Very Unsettled, Finer at times','Μεταβλητός και βροχερός.'),('Gelegentlich Regen, Verschlechterung.','Rain at times, worse later','Περιστασιακές βροχές, επιδείνωση.'),('Zuweilen Regen, sehr unbeständig.','Rain at times, becoming very unsettled','Βροχή κατά περιόδους, πολύ ασταθής.'),('Häufiger Regen.','Rain at Frequent Intervals','Συχνή βροχή.'),('Regen, sehr unbeständig.','Very Unsettled, Rain','Βροχή, πολύ ασταθής.'),('Stürmisch, evtl. Besserung.','Stormy, possibly improving','Θυελλώδης, πιθανώς βελτίωση.'),('Stürmisch mit viel Regen.','Stormy, much rain','Καταιγίδα με πολλές βροχές.')]%} {%if z==0 %}{%set type = "none"%} {%elif z in [1,10,20] %}{%set type = 0%} {%elif z in [2,11,21] %}{%set type = 1%} {%elif z in [11] %}{%set type = 2%} {%elif z in [3] %}{%set type = 3%} {%elif z in [12] %}{%set type = 4%} {%elif z in [23] %}{%set type = 5%} {%elif z in [24] %}{%set type = 6%} {%elif z in [4] %}{%set type = 7%} {%elif z in [25] %}{%set type = 8%} {%elif z in [26] %}{%set type = 9%} {%elif z in [13] %}{%set type = 10%} {%elif z in [27] %}{%set type = 11%} {%elif z in [28] %}{%set type = 12%} {%elif z in [14] %}{%set type = 13%} {%elif z in [5] %}{%set type = 14%} {%elif z in [15] %}{%set type = 15%} {%elif z in [29] %}{%set type = 16%} {%elif z in [6] %}{%set type = 17%} {%elif z in [16] %}{%set type = 18%} {%elif z in [30] %}{%set type = 19%} {%elif z in [7] %}{%set type = 20%} {%elif z in [8] %}{%set type = 21%} {%elif z in [17] %}{%set type = 22%} {%elif z in [9,18] %}{%set type = 23%} {%elif z in [31] %}{%set type = 24%} {%elif z in [19,32] %}{%set type = 25%} {%endif%} {%if z==0 %}{%set type_l = "none"%} {%elif z in [1,10,20] %}{%set type_l = "A"%} {%elif z in [2,11,21] %}{%set type_l = "B"%} {%elif z in [11] %}{%set type_l = "C"%} {%elif z in [3] %}{%set type_l = "D"%} {%elif z in [12] %}{%set type_l = "E"%} {%elif z in [23] %}{%set type_l = "F"%} {%elif z in [24] %}{%set type_l = "G"%} {%elif z in [4] %}{%set type_l = "H"%} {%elif z in [25] %}{%set type_l = "I"%} {%elif z in [26] %}{%set type_l = "J"%} {%elif z in [13] %}{%set type_l = "K"%} {%elif z in [27] %}{%set type_l = "L"%} {%elif z in [28] %}{%set type_l = "M"%} {%elif z in [14] %}{%set type_l = "N"%} {%elif z in [5] %}{%set type_l = "O"%} {%elif z in [15] %}{%set type_l = "P"%} {%elif z in [29] %}{%set type_l = "Q"%} {%elif z in [6] %}{%set type_l = "R"%} {%elif z in [16] %}{%set type_l = "S"%} {%elif z in [30] %}{%set type_l = "T"%} {%elif z in [7] %}{%set type_l = "U"%} {%elif z in [8] %}{%set type_l = "V"%} {%elif z in [17] %}{%set type_l = "W"%} {%elif z in [9,18] %}{%set type_l = "X"%} {%elif z in [31] %}{%set type_l = "Y"%} {%elif z in [19,32] %}{%set type_l = "Z"%} {%endif%} {{[t_lang[type|int(9)][language],type,type_l]}}{#text,0-25 the higher the worse#}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1926, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'
2024-01-02 14:33:08.017 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({##} {# Negretti and Zambras 'slide rule' algorythm #} {##} {# local vars #} {%set hem = 1%} {#Northern = 1 Southern = 0#} {%set bar_top = 1050%} {%set bar_bottom = 950%} {%set rise_opt = [25,25,25,24,24,19,16,12,11,9,8,6,5,2,1,1,0,0,0,0,0,0]%} {%set steady_opt = [25,25,25,25,25,25,23,23,22,18,15,13,10,4,1,1,0,0,0,0,0,0]%} {%set fall_opt = [25,25,25,25,25,25,25,25,23,23,21,20,17,14,7,3,1,1,1,0,0,0]%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set dir = states.sensor.local_forecast.attributes.wind_direction[1]|int(0) %} {%set windfak_speed = states.sensor.local_forecast.attributes.wind_direction[3]|int(0)%} {%set t_lang = [('Beständiges Schönwetter!','Settled Fine','Σταθερός καλός καιρός!'),('Schönes Wetter!','fine','Ωραίος καιρός!'),('Es wird schöner.','Becoming Fine','Θα καλυτερεύσει.'),('Schön, wird wechselhaft.','Fine Becoming Less Settled','Μεταβλητός.'),('Schön, Regenschauer möglich.','Fine, Possibly showers','Πιθανή βροχή.'),('Heiter bis wolkig, Besserung zu erwarten.','Fairly Fine, Improving','Αίθριος έως νεφελώδης, αναμένεται βελτίωση.'),('Heiter bis wolkig, anfangs evtl. Schauer.','Fairly Fine, Possibly showers, early','Αίθριος έως συννεφιασμένος, πιθανώς βροχές στην αρχή.'),('Heiter bis wolkig, später Regen.','Fairly Fine Showery Later','Αίθριος έως συννεφιασμένος, αργότερα βροχή.'),('Anfangs noch Schauer, dann Besserung.','Showery Early, Improving','Βροχόπτωση στην αρχή και μετά βελτίωση.'),('Wechselhaft mit Schauern','Changeable Mending','Εναλλαγή με βροχόπτωση.'),('Heiter bis wolkig, vereinzelt Regen.','Fairly Fine , Showers likely','Αίθριος έως συννεφιασμένος, κατά διαστήματα βροχή.'),('Unbeständig, später Aufklarung.','Rather Unsettled Clearing Later','Ασταθής, αργότερα καθάρος.'),('Unbeständig, evtl. Besserung.','Unsettled, Probably Improving','Ασταθής, πιθανώς βελτίωση.'),('Regnerisch mit heiteren Phasen.','Showery Bright Intervals','Καθαρός με διαστήματα βροχής.'),('Regnerisch, wird unbeständiger.','Showery Becoming more unsettled','Βροχερό, όλο και πιο ασταθές.'),('Wechselhaft mit etwas Regen.','Changeable some rain','Αλλάζει με λίγη βροχή.'),('Unbeständig mit heiteren Phasen.','Unsettled, short fine Intervals','Άστατα, μικρά καθαρά διαστήματα'),('Unbeständig, später Regen.','Unsettled, Rain later','Άστατη, αργότερα βροχή.'),('Unbeständig mit etwas Regen.','Unsettled, rain at times','Άστατος με λίγη βροχή.'),('Wechselhaft und regnerisch','Very Unsettled, Finer at times','Μεταβλητός και βροχερός.'),('Gelegentlich Regen, Verschlechterung.','Rain at times, worse later','Περιστασιακές βροχές, επιδείνωση.'),('Zuweilen Regen, sehr unbeständig.','Rain at times, becoming very unsettled','Βροχή κατά περιόδους, πολύ ασταθής.'),('Häufiger Regen.','Rain at Frequent Intervals','Συχνή βροχή.'),('Regen, sehr unbeständig.','Very Unsettled, Rain','Βροχή, πολύ ασταθής.'),('Stürmisch, evtl. Besserung.','Stormy, possibly improving','Θυελλώδης, πιθανώς βελτίωση.'),('Stürmisch mit viel Regen.','Stormy, much rain','Καταιγίδα με πολλές βροχές.')]%} {%set t_lang_exceptional = ['außergewöhnliches Wetter, ','Exceptional Weather, ']%} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {##} {# calculations #} {##} {%set bar_range = bar_top-bar_bottom%} {%set constant = (bar_range/22)|round(3)%} {# calc range of pressure to options#} {%if 2 < now().month < 11%}{%set season = 1%}{#summer#}{%else%}{%set season = 0%}{#winter#}{%endif%} {%if p0change<=(-1.6) %}{%set trend = '-1'%}{%elif p0change>=(1.6) %}{%set trend = '1'%}{%else%}{%set trend = '0'%}{%endif%} {#northern hemisphere#} {%set z_hp = p0%} {%if hem == 1 %}
  {% if 11.25 < dir <= 33.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+5/100*bar_range%} {# NNE #}
  {% elif 33.75 < dir <= 56.25 and windfak_speed|int == 1%}{%set z_hp = z_hp+4+6/100*bar_range%} {# NE #}
  {% elif 56.25 < dir <= 78.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+2/100*bar_range%} {# ENE #} 
  {% elif 78.75 < dir <= 101.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-0.5/100*bar_range%} {# E #}
  {% elif 101.25 < dir <= 123.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-3-2/100*bar_range%} {# ESE #}
  {% elif 123.75 < dir <= 146.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-5/100*bar_range%} {# SE #}
  {% elif 146.25 < dir <= 168.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-8.5/100*bar_range%} {# SSE #}
  {% elif 168.75 < dir <= 191.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-11-12/100*bar_range%} {# S #}
  {% elif 191.25 < dir <= 213.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-10/100*bar_range%} {# SSW #}
  {% elif 213.75 < dir <= 236.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-6/100*bar_range%} {# SW #}
  {% elif 236.25 < dir <= 258.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-4.5/100*bar_range%} {# WSW #}
  {% elif 258.75 < dir <= 281.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-3/100*bar_range%} {# W #}
  {% elif 281.25 < dir <= 303.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-0.5/100*bar_range%} {# WNW #}
  {% elif 303.75 < dir <= 326.25 and windfak_speed|int == 1%}{%set z_hp = z_hp+1.5/100*bar_range%} {# NW #}
  {% elif 326.25 < dir <= 348.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+3/100*bar_range%} {# NNW #}
  {% elif dir > 348.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+6/100*bar_range%} {# N #}
  {%endif%}
  {%if season|int == 1%}
    {%if trend|int == 1%}{%set z_hp = z_hp+7/100*bar_range%}
    {%elif trend|int == -1%}{%set z_hp = z_hp-7/100*bar_range%}
    {%endif%}
  {%endif%}
  {# for southern hemisphere all directions inverted #}
{%endif%} {%if z_hp|float == bar_top|float%}
  {%set z_hp = bar_top-1 %}
{%endif%}
{# calculate options for weather #} {%set z_option = ((z_hp-bar_bottom)/constant)|round(0,'floor')%} {%set z_out = ""%}
{%if z_option < 0%}
  {%set z_option = 0%}
  {%set z_out = t_lang_exceptional[language]%}
{%elif z_option > 21%}
  {%set z_option = 21%}
  {%set z_out = t_lang_exceptional[language]%}
{%endif%}
{# look at pressure and generate results #} {%if trend|int == 1%}{#rising pressure#}
  {%set z_out = z_out + t_lang[rise_opt[z_option]][language]%}
  {%set z_num = rise_opt[z_option]%}
{%elif trend|int == -1%}{#rising pressure#}
  {%set z_out = z_out + t_lang[fall_opt[z_option]][language]%}
  {%set z_num = fall_opt[z_option]%}
{%else%}
  {%set z_out = z_out + t_lang[steady_opt[z_option]][language]%}
  {%set z_num = steady_opt[z_option]%}
{%endif%} {%set z = z_num%} {%if z==0 %}{%set type_l = "none"%} {%elif z in [1,10,20] %}{%set type_l = "A"%} {%elif z in [2,11,21] %}{%set type_l = "B"%} {%elif z in [11] %}{%set type_l = "C"%} {%elif z in [3] %}{%set type_l = "D"%} {%elif z in [12] %}{%set type_l = "E"%} {%elif z in [23] %}{%set type_l = "F"%} {%elif z in [24] %}{%set type_l = "G"%} {%elif z in [4] %}{%set type_l = "H"%} {%elif z in [25] %}{%set type_l = "I"%} {%elif z in [26] %}{%set type_l = "J"%} {%elif z in [13] %}{%set type_l = "K"%} {%elif z in [27] %}{%set type_l = "L"%} {%elif z in [28] %}{%set type_l = "M"%} {%elif z in [14] %}{%set type_l = "N"%} {%elif z in [5] %}{%set type_l = "O"%} {%elif z in [15] %}{%set type_l = "P"%} {%elif z in [29] %}{%set type_l = "Q"%} {%elif z in [6] %}{%set type_l = "R"%} {%elif z in [16] %}{%set type_l = "S"%} {%elif z in [30] %}{%set type_l = "T"%} {%elif z in [7] %}{%set type_l = "U"%} {%elif z in [8] %}{%set type_l = "V"%} {%elif z in [17] %}{%set type_l = "W"%} {%elif z in [9,18] %}{%set type_l = "X"%} {%elif z in [31] %}{%set type_l = "Y"%} {%elif z in [19,32] %}{%set type_l = "Z"%} {%endif%} {{z_out,z_num,type_l}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1926, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'
2024-01-02 14:33:08.018 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set trend_lang=[('fallend','falling','πέφτοντας'),('steigend','rising','αυξανόμενη'),('stabil','steady','σταθερή')]%} {%if p0change<=(-1.6) %}{%set trend = '0'%}{%elif p0change>=(1.6) %}{%set trend = '1'%}{%else%}{%set trend = '2'%}{%endif%} {{[trend_lang[trend|int][language],trend]}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'
2024-01-02 14:33:08.021 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({#ultra short term temperature prognosis#} {% set temp = states.sensor.local_forecast.attributes.temperature|float(0)%} {%set temp_change = states.sensor.local_forecast_temperaturechange.state|float(0)%} {%set first_time = states.sensor.local_forecast_zambretti_detail.attributes.first_time[1]|float(0)%} {%set second_time = states.sensor.local_forecast_zambretti_detail.attributes.second_time[1]|float(0)%} {%if first_time>0%}{%set t_forecast = ((temp_change/60*first_time)+temp)|round(1)%}{%set intervall = 0%} {%elif second_time>0%}{%set t_forecast = ((temp_change/60*second_time)+temp)|round(1)%}{%set intervall = 1%} {%else%}{%set t_forecast = "unavailable"%}{%set intervall = -1%}{%endif%} {{[t_forecast,intervall]}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1926, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'
2024-01-02 14:33:08.023 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'') while processing template 'Template<template=({# -----> pressure sensor (needed) <----- #} {% set pressure = states.sensor.water_01_pressure.state|float(0)%}
{# -----> pressure at sealevel: set to 1 else set to 0 (needed) <-----#} {% set pressure_sea = 0%}
{# -----> set height above sealevel in meters (only when pressure_sea = 0) <-----#} {% set height = 160%}
{# Calc pressure at sealevel -> p0 (if necessary)#} {% set temp = states.sensor.local_forecast.attributes.temperature|float(1)%} {% set p0 = pressure*pressure_sea-(pressure_sea-1)*pressure*(1-((0.0065*height)/(temp+(0.0065*height)+273.15)))**(-5.257)%} {{p0|round(1)}}) renders=4>' for attribute 'p0' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'') while processing template 'Template<template=({# Calc current condtions#} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set conditions = [('stürmisch','stormy','θυελλώδης'),('regnerisch','rainy','Βροχερός'),('wechselhaft','mixed','Μεταβλητός'),('sonnig','sunny','Ηλιόλουστος'),('sehr trocken','extra dry','Πολύ ξηρός')]%} {%set pressure_system = [('Tiefdruckgebiet','low pressure system','σύστημα χαμηλής πίεσης'),('Normal','normal','φυσιολογικός'),('Hochdruckgebiet','high pressure system','σύστημα υψηλής πίεσης')]%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {% if p0<980 %} {% set current_condtion = [conditions[0][language],pressure_system[0][language]]%} {% elif p0>=980 and p0<1000 %} {% set current_condtion = [conditions[1][language],pressure_system[0][language]]%} {% elif p0>=1000 and p0<1020 %} {% set current_condtion = [conditions[2][language],pressure_system[1][language]]%} {% elif p0>=1020 and p0<1040 %} {% set current_condtion = [conditions[3][language],pressure_system[2][language]]%} {% elif p0>=1040 %} {% set current_condtion = [conditions[4][language],pressure_system[2][language]]%} {%endif%} {{current_condtion}}) renders=4>' for attribute 'forecast_short_term' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'') while processing template 'Template<template=({#get specific forecast num based on pressure trend#} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set windfak = states.sensor.local_forecast.attributes.wind_direction[0]|int(0)%} {%set windfak_speed = states.sensor.local_forecast.attributes.wind_direction[3]|int(0)%} {%if p0change<=(-1.0) %}{%set trend = '-1'%}{%elif p0change>=(1.0) %}{%set trend = '1'%}{%else%}{%set trend = '0'%}{%endif%} {# Calc forecast#} {%if trend == '-1' %} {# falling pressure#} {%set z = (127-0.12*p0)|round(0)|int(0)%} {%elif trend == '0'%} {# steady pressure#} {%set z = (144-0.13*p0)|round(0)|int(0)%} {#winter and summer adjustment#} {%if 2 < now().month < 11%} {%set z = z%}{#summer#}{%else%} {%set z = z-1%} {#winter#}{%endif%} {%elif trend == '1'%} {# rising pressure#} {%set z = (185-0.16*p0)|round(0)|int(0)%} {%if 2 < now().month < 11%} {%set z = z+1%}{#summer#}{%else%} {%set z = z%} {#winter#}{%endif%} {%endif%} {# wind factor #} {%set z = (z + windfak*windfak_speed) %}  {# generate report #} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set t_lang = [('Beständiges Schönwetter!','Settled Fine','Σταθερός καλός καιρός!'),('Schönes Wetter!','fine','Ωραίος καιρός!'),('Es wird schöner.','Becoming Fine','Θα καλυτερεύσει.'),('Schön, wird wechselhaft.','Fine Becoming Less Settled','Μεταβλητός.'),('Schön, Regenschauer möglich.','Fine, Possibly showers','Πιθανή βροχή.'),('Heiter bis wolkig, Besserung zu erwarten.','Fairly Fine, Improving','Αίθριος έως νεφελώδης, αναμένεται βελτίωση.'),('Heiter bis wolkig, anfangs evtl. Schauer.','Fairly Fine, Possibly showers, early','Αίθριος έως συννεφιασμένος, πιθανώς βροχές στην αρχή.'),('Heiter bis wolkig, später Regen.','Fairly Fine Showery Later','Αίθριος έως συννεφιασμένος, αργότερα βροχή.'),('Anfangs noch Schauer, dann Besserung.','Showery Early, Improving','Βροχόπτωση στην αρχή και μετά βελτίωση.'),('Wechselhaft mit Schauern','Changeable Mending','Εναλλαγή με βροχόπτωση.'),('Heiter bis wolkig, vereinzelt Regen.','Fairly Fine , Showers likely','Αίθριος έως συννεφιασμένος, κατά διαστήματα βροχή.'),('Unbeständig, später Aufklarung.','Rather Unsettled Clearing Later','Ασταθής, αργότερα καθάρος.'),('Unbeständig, evtl. Besserung.','Unsettled, Probably Improving','Ασταθής, πιθανώς βελτίωση.'),('Regnerisch mit heiteren Phasen.','Showery Bright Intervals','Καθαρός με διαστήματα βροχής.'),('Regnerisch, wird unbeständiger.','Showery Becoming more unsettled','Βροχερό, όλο και πιο ασταθές.'),('Wechselhaft mit etwas Regen.','Changeable some rain','Αλλάζει με λίγη βροχή.'),('Unbeständig mit heiteren Phasen.','Unsettled, short fine Intervals','Άστατα, μικρά καθαρά διαστήματα'),('Unbeständig, später Regen.','Unsettled, Rain later','Άστατη, αργότερα βροχή.'),('Unbeständig mit etwas Regen.','Unsettled, rain at times','Άστατος με λίγη βροχή.'),('Wechselhaft und regnerisch','Very Unsettled, Finer at times','Μεταβλητός και βροχερός.'),('Gelegentlich Regen, Verschlechterung.','Rain at times, worse later','Περιστασιακές βροχές, επιδείνωση.'),('Zuweilen Regen, sehr unbeständig.','Rain at times, becoming very unsettled','Βροχή κατά περιόδους, πολύ ασταθής.'),('Häufiger Regen.','Rain at Frequent Intervals','Συχνή βροχή.'),('Regen, sehr unbeständig.','Very Unsettled, Rain','Βροχή, πολύ ασταθής.'),('Stürmisch, evtl. Besserung.','Stormy, possibly improving','Θυελλώδης, πιθανώς βελτίωση.'),('Stürmisch mit viel Regen.','Stormy, much rain','Καταιγίδα με πολλές βροχές.')]%} {%if z==0 %}{%set type = "none"%} {%elif z in [1,10,20] %}{%set type = 0%} {%elif z in [2,11,21] %}{%set type = 1%} {%elif z in [11] %}{%set type = 2%} {%elif z in [3] %}{%set type = 3%} {%elif z in [12] %}{%set type = 4%} {%elif z in [23] %}{%set type = 5%} {%elif z in [24] %}{%set type = 6%} {%elif z in [4] %}{%set type = 7%} {%elif z in [25] %}{%set type = 8%} {%elif z in [26] %}{%set type = 9%} {%elif z in [13] %}{%set type = 10%} {%elif z in [27] %}{%set type = 11%} {%elif z in [28] %}{%set type = 12%} {%elif z in [14] %}{%set type = 13%} {%elif z in [5] %}{%set type = 14%} {%elif z in [15] %}{%set type = 15%} {%elif z in [29] %}{%set type = 16%} {%elif z in [6] %}{%set type = 17%} {%elif z in [16] %}{%set type = 18%} {%elif z in [30] %}{%set type = 19%} {%elif z in [7] %}{%set type = 20%} {%elif z in [8] %}{%set type = 21%} {%elif z in [17] %}{%set type = 22%} {%elif z in [9,18] %}{%set type = 23%} {%elif z in [31] %}{%set type = 24%} {%elif z in [19,32] %}{%set type = 25%} {%endif%} {%if z==0 %}{%set type_l = "none"%} {%elif z in [1,10,20] %}{%set type_l = "A"%} {%elif z in [2,11,21] %}{%set type_l = "B"%} {%elif z in [11] %}{%set type_l = "C"%} {%elif z in [3] %}{%set type_l = "D"%} {%elif z in [12] %}{%set type_l = "E"%} {%elif z in [23] %}{%set type_l = "F"%} {%elif z in [24] %}{%set type_l = "G"%} {%elif z in [4] %}{%set type_l = "H"%} {%elif z in [25] %}{%set type_l = "I"%} {%elif z in [26] %}{%set type_l = "J"%} {%elif z in [13] %}{%set type_l = "K"%} {%elif z in [27] %}{%set type_l = "L"%} {%elif z in [28] %}{%set type_l = "M"%} {%elif z in [14] %}{%set type_l = "N"%} {%elif z in [5] %}{%set type_l = "O"%} {%elif z in [15] %}{%set type_l = "P"%} {%elif z in [29] %}{%set type_l = "Q"%} {%elif z in [6] %}{%set type_l = "R"%} {%elif z in [16] %}{%set type_l = "S"%} {%elif z in [30] %}{%set type_l = "T"%} {%elif z in [7] %}{%set type_l = "U"%} {%elif z in [8] %}{%set type_l = "V"%} {%elif z in [17] %}{%set type_l = "W"%} {%elif z in [9,18] %}{%set type_l = "X"%} {%elif z in [31] %}{%set type_l = "Y"%} {%elif z in [19,32] %}{%set type_l = "Z"%} {%endif%} {{[t_lang[type|int(9)][language],type,type_l]}}{#text,0-25 the higher the worse#}) renders=4>' for attribute 'forecast_zambretti' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p0'') while processing template 'Template<template=({##} {# Negretti and Zambras 'slide rule' algorythm #} {##} {# local vars #} {%set hem = 1%} {#Northern = 1 Southern = 0#} {%set bar_top = 1050%} {%set bar_bottom = 950%} {%set rise_opt = [25,25,25,24,24,19,16,12,11,9,8,6,5,2,1,1,0,0,0,0,0,0]%} {%set steady_opt = [25,25,25,25,25,25,23,23,22,18,15,13,10,4,1,1,0,0,0,0,0,0]%} {%set fall_opt = [25,25,25,25,25,25,25,25,23,23,21,20,17,14,7,3,1,1,1,0,0,0]%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set dir = states.sensor.local_forecast.attributes.wind_direction[1]|int(0) %} {%set windfak_speed = states.sensor.local_forecast.attributes.wind_direction[3]|int(0)%} {%set t_lang = [('Beständiges Schönwetter!','Settled Fine','Σταθερός καλός καιρός!'),('Schönes Wetter!','fine','Ωραίος καιρός!'),('Es wird schöner.','Becoming Fine','Θα καλυτερεύσει.'),('Schön, wird wechselhaft.','Fine Becoming Less Settled','Μεταβλητός.'),('Schön, Regenschauer möglich.','Fine, Possibly showers','Πιθανή βροχή.'),('Heiter bis wolkig, Besserung zu erwarten.','Fairly Fine, Improving','Αίθριος έως νεφελώδης, αναμένεται βελτίωση.'),('Heiter bis wolkig, anfangs evtl. Schauer.','Fairly Fine, Possibly showers, early','Αίθριος έως συννεφιασμένος, πιθανώς βροχές στην αρχή.'),('Heiter bis wolkig, später Regen.','Fairly Fine Showery Later','Αίθριος έως συννεφιασμένος, αργότερα βροχή.'),('Anfangs noch Schauer, dann Besserung.','Showery Early, Improving','Βροχόπτωση στην αρχή και μετά βελτίωση.'),('Wechselhaft mit Schauern','Changeable Mending','Εναλλαγή με βροχόπτωση.'),('Heiter bis wolkig, vereinzelt Regen.','Fairly Fine , Showers likely','Αίθριος έως συννεφιασμένος, κατά διαστήματα βροχή.'),('Unbeständig, später Aufklarung.','Rather Unsettled Clearing Later','Ασταθής, αργότερα καθάρος.'),('Unbeständig, evtl. Besserung.','Unsettled, Probably Improving','Ασταθής, πιθανώς βελτίωση.'),('Regnerisch mit heiteren Phasen.','Showery Bright Intervals','Καθαρός με διαστήματα βροχής.'),('Regnerisch, wird unbeständiger.','Showery Becoming more unsettled','Βροχερό, όλο και πιο ασταθές.'),('Wechselhaft mit etwas Regen.','Changeable some rain','Αλλάζει με λίγη βροχή.'),('Unbeständig mit heiteren Phasen.','Unsettled, short fine Intervals','Άστατα, μικρά καθαρά διαστήματα'),('Unbeständig, später Regen.','Unsettled, Rain later','Άστατη, αργότερα βροχή.'),('Unbeständig mit etwas Regen.','Unsettled, rain at times','Άστατος με λίγη βροχή.'),('Wechselhaft und regnerisch','Very Unsettled, Finer at times','Μεταβλητός και βροχερός.'),('Gelegentlich Regen, Verschlechterung.','Rain at times, worse later','Περιστασιακές βροχές, επιδείνωση.'),('Zuweilen Regen, sehr unbeständig.','Rain at times, becoming very unsettled','Βροχή κατά περιόδους, πολύ ασταθής.'),('Häufiger Regen.','Rain at Frequent Intervals','Συχνή βροχή.'),('Regen, sehr unbeständig.','Very Unsettled, Rain','Βροχή, πολύ ασταθής.'),('Stürmisch, evtl. Besserung.','Stormy, possibly improving','Θυελλώδης, πιθανώς βελτίωση.'),('Stürmisch mit viel Regen.','Stormy, much rain','Καταιγίδα με πολλές βροχές.')]%} {%set t_lang_exceptional = ['außergewöhnliches Wetter, ','Exceptional Weather, ']%} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {##} {# calculations #} {##} {%set bar_range = bar_top-bar_bottom%} {%set constant = (bar_range/22)|round(3)%} {# calc range of pressure to options#} {%if 2 < now().month < 11%}{%set season = 1%}{#summer#}{%else%}{%set season = 0%}{#winter#}{%endif%} {%if p0change<=(-1.6) %}{%set trend = '-1'%}{%elif p0change>=(1.6) %}{%set trend = '1'%}{%else%}{%set trend = '0'%}{%endif%} {#northern hemisphere#} {%set z_hp = p0%} {%if hem == 1 %}
  {% if 11.25 < dir <= 33.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+5/100*bar_range%} {# NNE #}
  {% elif 33.75 < dir <= 56.25 and windfak_speed|int == 1%}{%set z_hp = z_hp+4+6/100*bar_range%} {# NE #}
  {% elif 56.25 < dir <= 78.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+2/100*bar_range%} {# ENE #} 
  {% elif 78.75 < dir <= 101.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-0.5/100*bar_range%} {# E #}
  {% elif 101.25 < dir <= 123.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-3-2/100*bar_range%} {# ESE #}
  {% elif 123.75 < dir <= 146.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-5/100*bar_range%} {# SE #}
  {% elif 146.25 < dir <= 168.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-8.5/100*bar_range%} {# SSE #}
  {% elif 168.75 < dir <= 191.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-11-12/100*bar_range%} {# S #}
  {% elif 191.25 < dir <= 213.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-10/100*bar_range%} {# SSW #}
  {% elif 213.75 < dir <= 236.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-6/100*bar_range%} {# SW #}
  {% elif 236.25 < dir <= 258.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-4.5/100*bar_range%} {# WSW #}
  {% elif 258.75 < dir <= 281.25 and windfak_speed|int == 1%}{%set z_hp = z_hp-3/100*bar_range%} {# W #}
  {% elif 281.25 < dir <= 303.75 and windfak_speed|int == 1%}{%set z_hp = z_hp-0.5/100*bar_range%} {# WNW #}
  {% elif 303.75 < dir <= 326.25 and windfak_speed|int == 1%}{%set z_hp = z_hp+1.5/100*bar_range%} {# NW #}
  {% elif 326.25 < dir <= 348.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+3/100*bar_range%} {# NNW #}
  {% elif dir > 348.75 and windfak_speed|int == 1%}{%set z_hp = z_hp+6/100*bar_range%} {# N #}
  {%endif%}
  {%if season|int == 1%}
    {%if trend|int == 1%}{%set z_hp = z_hp+7/100*bar_range%}
    {%elif trend|int == -1%}{%set z_hp = z_hp-7/100*bar_range%}
    {%endif%}
  {%endif%}
  {# for southern hemisphere all directions inverted #}
{%endif%} {%if z_hp|float == bar_top|float%}
  {%set z_hp = bar_top-1 %}
{%endif%}
{# calculate options for weather #} {%set z_option = ((z_hp-bar_bottom)/constant)|round(0,'floor')%} {%set z_out = ""%}
{%if z_option < 0%}
  {%set z_option = 0%}
  {%set z_out = t_lang_exceptional[language]%}
{%elif z_option > 21%}
  {%set z_option = 21%}
  {%set z_out = t_lang_exceptional[language]%}
{%endif%}
{# look at pressure and generate results #} {%if trend|int == 1%}{#rising pressure#}
  {%set z_out = z_out + t_lang[rise_opt[z_option]][language]%}
  {%set z_num = rise_opt[z_option]%}
{%elif trend|int == -1%}{#rising pressure#}
  {%set z_out = z_out + t_lang[fall_opt[z_option]][language]%}
  {%set z_num = fall_opt[z_option]%}
{%else%}
  {%set z_out = z_out + t_lang[steady_opt[z_option]][language]%}
  {%set z_num = steady_opt[z_option]%}
{%endif%} {%set z = z_num%} {%if z==0 %}{%set type_l = "none"%} {%elif z in [1,10,20] %}{%set type_l = "A"%} {%elif z in [2,11,21] %}{%set type_l = "B"%} {%elif z in [11] %}{%set type_l = "C"%} {%elif z in [3] %}{%set type_l = "D"%} {%elif z in [12] %}{%set type_l = "E"%} {%elif z in [23] %}{%set type_l = "F"%} {%elif z in [24] %}{%set type_l = "G"%} {%elif z in [4] %}{%set type_l = "H"%} {%elif z in [25] %}{%set type_l = "I"%} {%elif z in [26] %}{%set type_l = "J"%} {%elif z in [13] %}{%set type_l = "K"%} {%elif z in [27] %}{%set type_l = "L"%} {%elif z in [28] %}{%set type_l = "M"%} {%elif z in [14] %}{%set type_l = "N"%} {%elif z in [5] %}{%set type_l = "O"%} {%elif z in [15] %}{%set type_l = "P"%} {%elif z in [29] %}{%set type_l = "Q"%} {%elif z in [6] %}{%set type_l = "R"%} {%elif z in [16] %}{%set type_l = "S"%} {%elif z in [30] %}{%set type_l = "T"%} {%elif z in [7] %}{%set type_l = "U"%} {%elif z in [8] %}{%set type_l = "V"%} {%elif z in [17] %}{%set type_l = "W"%} {%elif z in [9,18] %}{%set type_l = "X"%} {%elif z in [31] %}{%set type_l = "Y"%} {%elif z in [19,32] %}{%set type_l = "Z"%} {%endif%} {{z_out,z_num,type_l}}) renders=4>' for attribute 'forecast_neg_zam' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'language'') while processing template 'Template<template=({%set p0change = states.sensor.local_forecast_pressurechange.state |float(0)%} {%set language = states.sensor.local_forecast.attributes.language|int(0)%} {%set p0 = states.sensor.local_forecast.attributes.p0|float(0)%} {%set trend_lang=[('fallend','falling','πέφτοντας'),('steigend','rising','αυξανόμενη'),('stabil','steady','σταθερή')]%} {%if p0change<=(-1.6) %}{%set trend = '0'%}{%elif p0change>=(1.6) %}{%set trend = '1'%}{%else%}{%set trend = '2'%}{%endif%} {{[trend_lang[trend|int][language],trend]}}) renders=4>' for attribute 'forecast_pressure_trend' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'') while processing template 'Template<template=({#ultra short term temperature prognosis#} {% set temp = states.sensor.local_forecast.attributes.temperature|float(0)%} {%set temp_change = states.sensor.local_forecast_temperaturechange.state|float(0)%} {%set first_time = states.sensor.local_forecast_zambretti_detail.attributes.first_time[1]|float(0)%} {%set second_time = states.sensor.local_forecast_zambretti_detail.attributes.second_time[1]|float(0)%} {%if first_time>0%}{%set t_forecast = ((temp_change/60*first_time)+temp)|round(1)%}{%set intervall = 0%} {%elif second_time>0%}{%set t_forecast = ((temp_change/60*second_time)+temp)|round(1)%}{%set intervall = 1%} {%else%}{%set t_forecast = "unavailable"%}{%set intervall = -1%}{%endif%} {{[t_forecast,intervall]}}) renders=4>' for attribute 'forecast_temp_short' in entity 'sensor.local_forecast'
2024-01-02 14:33:08.024 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{"more details on zambretti forecast",states.sensor.local_forecast.attributes.forecast_zambretti[1]|int(0)+1}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: None has no element 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: None has no element 1
2024-01-02 14:33:08.025 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_zambretti[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [1,1]%} {%elif z == 6%}{%set forecast = [1,0]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [1,1]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: None has no element 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: None has no element 1
2024-01-02 14:33:08.026 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%if forecast[0]==0 and forecast[1]==0 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==2 and forecast[1]==1 %}{%set rain_prob = [60,10]%} {%elif forecast[0]==1 and forecast[1]==1 %}{%set rain_prob = [30,30]%} {%elif forecast[0]==1 and forecast[1]==0 %}{%set rain_prob = [10,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%elif forecast[0]>=2 and forecast[1]<2 %}{%set rain_prob = [50,10]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.11/site-packages/jinja2/sandbox.py", line 303, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'
2024-01-02 14:33:08.028 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.11/site-packages/jinja2/sandbox.py", line 303, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'
2024-01-02 14:33:08.031 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({{"more details on zambretti forecast",states.sensor.local_forecast.attributes.forecast_zambretti[1]|int(0)+1}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.local_forecast_zambretti_detail'
2024-01-02 14:33:08.031 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_zambretti[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [1,1]%} {%elif z == 6%}{%set forecast = [1,0]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [1,1]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=4>' for attribute 'forecast' in entity 'sensor.local_forecast_zambretti_detail'
2024-01-02 14:33:08.031 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%if forecast[0]==0 and forecast[1]==0 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==2 and forecast[1]==1 %}{%set rain_prob = [60,10]%} {%elif forecast[0]==1 and forecast[1]==1 %}{%set rain_prob = [30,30]%} {%elif forecast[0]==1 and forecast[1]==0 %}{%set rain_prob = [10,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%elif forecast[0]>=2 and forecast[1]<2 %}{%set rain_prob = [50,10]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=4>' for attribute 'rain_prob' in entity 'sensor.local_forecast_zambretti_detail'
2024-01-02 14:33:08.031 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=4>' for attribute 'icons' in entity 'sensor.local_forecast_zambretti_detail'
derjoerg commented 6 months ago
2024-01-02 14:33:08.032 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{"more details on neg_zam forecast", states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: None has no element 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: None has no element 1
2024-01-02 14:33:08.034 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1943, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
           ^^^^^^^^^^
jinja2.exceptions.UndefinedError: None has no element 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: None has no element 1
2024-01-02 14:33:08.035 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.11/site-packages/jinja2/sandbox.py", line 303, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'
2024-01-02 14:33:08.037 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.11/site-packages/jinja2/sandbox.py", line 303, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 695, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'
2024-01-02 14:33:08.041 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({{"more details on neg_zam forecast", states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.local_forecast_neg_zam_detail'
2024-01-02 14:33:08.041 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=4>' for attribute 'forecast' in entity 'sensor.local_forecast_neg_zam_detail'
2024-01-02 14:33:08.042 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=4>' for attribute 'rain_prob' in entity 'sensor.local_forecast_neg_zam_detail'
2024-01-02 14:33:08.042 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=4>' for attribute 'icons' in entity 'sensor.local_forecast_neg_zam_detail'
2024-01-02 14:33:08.042 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _async_at_core_state.<locals>._matched_event(<Event homeassistant_start[L]>) at /usr/src/homeassistant/homeassistant/helpers/start.py:37
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in _onetime_listener
    self._hass.async_run_job(listener, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 719, in async_run_job
    return self.async_run_hass_job(HassJob(target), *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 40, in _matched_event
    hass.async_run_hass_job(at_start_job, hass)
  File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 478, in _async_template_startup
    result_info.async_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1035, in async_refresh
    self._refresh(None)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1215, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 429, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
    raise ValueError(
ValueError: Sensor sensor.local_forecast_pressure has device class 'None', state class 'None' unit 'hpa' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
2024-01-02 14:33:08.065 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'forecast' is undefined when rendering '{% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}'
2024-01-02 14:33:08.097 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'forecast' is undefined when rendering '{% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}'
francistheodorecatte commented 4 months ago

I'm also having similar errors thrown in the Home Assistant log, such as the following:

Logger: homeassistant.helpers.event

Source: helpers/template.py:575
First occurred: 8:28:21 PM (26 occurrences)
Last logged: 8:40:17 PM

Error while processing template: Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h]#} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=2>
Error while processing template: Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=2>
Error while processing template: Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=2>
Error while processing template: Template<template=({# figure out if forecast is olf if yes add 6h -> next intervall #} {%set halftime = 6*60-(as_timestamp(now()) - as_timestamp(states.sensor.local_forecast_neg_zam_detail.last_changed))/60%} {%if halftime<0%}{%set correction = 6+((halftime/60)|float(0))%}{%else%}{%set correction = 0%}{%endif%} {%set time_offset_first = 3+correction%}{#time from last forecast update to the first forecast state #} {%set time_to = time_offset_first*60-(as_timestamp(now()) - as_timestamp(states.sensor.local_forecast_neg_zam_detail.last_changed))/60%} {{[(as_timestamp(now())+time_to*60)| timestamp_custom('%H:%M'), time_to|round(2)]}}{# [time of first state, minutes to first state] #}) renders=2>
Error while processing template: Template<template=({# figure out if forecast is olf if yes add 6h -> next intervall #} {%set halftime = 6*60-(as_timestamp(now()) - as_timestamp(states.sensor.local_forecast_neg_zam_detail.last_changed))/60%} {%if halftime<0%}{%set correction = 6+((halftime/60)|float(0))%}{%else%}{%set correction = 0%}{%endif%} {%set time_offset_second = 9+correction%}{#time from last forecast update to the first forecast state #} {%set time_to = time_offset_second*60-(as_timestamp(now()) - as_timestamp(states.sensor.local_forecast_neg_zam_detail.last_changed))/60%} {{[(as_timestamp(now())+time_to*60)| timestamp_custom('%H:%M'), time_to|round(2)]}}{# [time of first state, minutes to first state] #}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 573, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2364, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
jinja2.exceptions.UndefinedError: None has no element 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 699, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 575, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: None has no element 0

The card on my dashboard also looks like this: Screen Shot 2024-03-08 at 8 59 36 PM

The only thing that updates is the pressure forecast, and only very erratically.

I'm assuming this is being caused by the sensor.local_forecast_zambretti_detail entity never being populated (it's always in an unknown state). I poked at the weather_forecast.yaml to see what would cause that, but I don't know enough about jinja to fully comprehend it, and there are no associated errors in the log to go off of, beside what the lovelace card generates. I've removed my wind speed and direction sensors (and set them to 0), but that made no difference; as of right now I only have sensors for pressure in hPa, temperature in °C, and humidity entered.

This is happening with Home Assistant Core 2024.4.0.dev, but I'm assuming the issue goes back to ~2024.1.x given when this issue was first filed.

Edit I realized Home Assistant had actually made a mistake at some point in the past, and had added my pressure sensor entity, which is in pascals, set as hectopascals without doing any conversion. I removed the entity and re-added it with pascals as the unit of measurement, and now it's correctly being converted from Pa -> hPa.

I then removed the weather_forecast.yaml, ran a database purge to clear out the entities, and restarted Home Assistant. After re-adding the weather_forecast.yaml, the forecast card now shows 'Stormy'. I'll leave it running overnight to see if it's working properly now.

francistheodorecatte commented 3 months ago

I'm fairly sure at this point that these errors are caused by sensor values that screw with the math in the forecast. It was still broken this morning but after making sure the Home Assistant is giving values like 1008.00hPa instead of 1008.0000hPa for the pressure sensor (by setting suggested_display_precision: 0), the forecast seems to actually be working. sensor.local_forecast_zambretti_detail is still unknown, so I'll check back in 6-12 hours to see if that changes

Also, very relatedly, it may be worth explicitly documenting what this integration needs for sensor values/units of measurement/precision requirements to prevent easily fixed errors like this.

Edit: Looks like it's working fine now ¯\ (ツ)/¯: Screen Shot 2024-03-09 at 1 40 08 PM

leovj commented 3 months ago

Hi, I think I have the same problem as you, did you set the pressure with a value without a decimal point? And the suit temperature sensor? A number only after the decimal point? Thank you

Screenshot 2024-03-20 alle 16 38 59 Screenshot 2024-03-20 alle 16 39 11
francistheodorecatte commented 3 months ago

yes, for pressure it's xxxx.xxhPa (two decimal points; in my case, w/ suggested_display_precision set to 0), and temperature it's xx.x°C (one decimal point, which I think is the default w/ temperature entities in HA). as I noted above, my pressure sensor is in raw pascals, but Home Assistant automatically converted it to hectopascals with unit_of_measurement set to 'Pa', and device_class set to 'atmospheric_pressure'.

another important thing I found, to prevent Home Assistant trying to do math with empty strings, is to make sure your sensors have availability_template set to something like: availability_template: "{{ states('sensor.outdoor_temperature') | is_number }}"

this also goes for the forecast temperature/pressure sensor entities, and subsequently the temp/pressure change statistics entities. the latter is easy to work around, but the former is not, due to how Home Assistant's statistics integration 'works'.

in regard to that last point, I've been working on some fixes to the weather_forecast.yaml integration that might help alleviate the garbage forecast data and logspam within <3hr of the integration starting up. if I can get something I'm happy with, I'll open up a PR with those changes (and some others I've made).

HAuser1234 commented 3 months ago

Thanks for working out the bugs. With the latest updates the integration broke a bit. I am happy to test out and integrate the PR but sadly I dont have much time at the moment to fix it myself :)

leovj commented 3 months ago

Thank you francistheodorecatte for your information. In fact, I noticed that my simple aqara sensor shows the pressure in hpa, so I think it's the right way. The sensor has two decimal points after the decimal point.

Screenshot 2024-03-21 alle 08 08 59 Screenshot 2024-03-21 alle 08 09 11

This is how I set up my sensor. Despite this approach, however, it seems that the forecast is wrong. Now you tell me that the weather is rainy and that rain is forecast, when in fact it is clear and we are in a moment of high pressure... So I think I did something wrong.

Screenshot 2024-03-21 alle 08 12 37

Now I'll try to install the package with the updates and see what happens..

leovj commented 3 months ago

UPDATE: I waited for 3/4 hours and now it seems to be better

Screenshot 2024-03-21 alle 15 18 30

Although there are still many errors in the log:

Registratore: homeassistant.helpers.event Fonte: helpers/template.py:575 Prima occorrenza: 15:14:18 (54 occorrenze) Ultima registrazione: 15:14:30

Error while processing template: Template<template=({%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=2>
Error while processing template: Template<template=({{"More details on neg_zam forecast", states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1}}) renders=2>
Error while processing template: Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h] #} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=2>
Error while processing template: Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=2>
Error while processing template: Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 573, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2364, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.12/site-packages/jinja2/sandbox.py", line 303, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast_zambretti'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 699, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 575, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast_zambretti'
Registratore: homeassistant.components.template.template_entity
Fonte: components/template/template_entity.py:199
integration: Template (documentazione, problemi)
Prima occorrenza: 15:14:30 (14 occorrenze)
Ultima registrazione: 15:14:30

TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({%set forecast = states.sensor.local_forecast_zambretti_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=4>' for attribute 'icons' in entity 'sensor.local_forecast_zambretti_detail'
TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({{"More details on neg_zam forecast", states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.local_forecast_neg_zam_detail'
TemplateError('UndefinedError: None has no element 1') while processing template 'Template<template=({% set z = states.sensor.local_forecast.attributes.forecast_neg_zam[1]|int(0)+1%} {# translate zambretti number to forecast icons: [next 6 h, next 12 h] #} {%if z == 1%}{%set forecast = [0,0]%} {%elif z == 2%}{%set forecast = [1,1]%} {%elif z == 3%}{%set forecast = [2,1]%} {%elif z == 4%}{%set forecast = [1,2]%} {%elif z == 5%}{%set forecast = [2,2]%} {%elif z == 6%}{%set forecast = [2,1]%} {%elif z == 7%}{%set forecast = [2,1]%} {%elif z == 8%}{%set forecast = [1,4]%} {%elif z == 9%}{%set forecast = [4,2]%} {%elif z == 10%}{%set forecast = [4,4]%} {%elif z == 11%}{%set forecast = [2,2]%} {%elif z == 12%}{%set forecast = [3,1]%} {%elif z == 13%}{%set forecast = [3,3]%} {%elif z == 14%}{%set forecast = [2,2]%} {%elif z == 15%}{%set forecast = [4,5]%} {%elif z == 16%}{%set forecast = [4,4]%} {%elif z == 17%}{%set forecast = [2,2]%} {%elif z == 18%}{%set forecast = [2,4]%} {%elif z == 19%}{%set forecast = [2,2]%} {%elif z == 20%}{%set forecast = [5,5]%} {%elif z == 21%}{%set forecast = [2,4]%} {%elif z == 22%}{%set forecast = [4,4]%} {%elif z == 23%}{%set forecast = [4,4]%} {%elif z == 24%}{%set forecast = [6,4]%} {%elif z == 25%}{%set forecast = [6,6]%} {%endif%} {{forecast}}) renders=4>' for attribute 'forecast' in entity 'sensor.local_forecast_neg_zam_detail'
TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=4>' for attribute 'rain_prob' in entity 'sensor.local_forecast_neg_zam_detail'
TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=4>' for attribute 'icons' in entity 'sensor.local_forecast_neg_zam_detail'
leovj commented 3 months ago

Is it possible that with the 2024.3.2 core update it stopped working? 😢

francistheodorecatte commented 3 months ago

I'm on 2024.4.0.dev, and the integration is working fine. the fact your lovelace card is populated means it's pretty much working for you too, so this is likely an intermittent logspam thing caused by sensors going unavailable/expiring.

my outdoor sensors are 433MHz Oregon Scientific gear going through rtl_433; with the non-ideal antenna placement I have, occasionally of the sensors won't update for a while, expire, and cause the integration to throw errors. I added the following to the Home Assistant config of all the weather sensors this integration uses to help limit the logspam (so the integration and lovelace card only throw roughly one error each when this occurs): availability_template: "{{ states('sensor.outdoor_humidity') | is_number }}"

without that, Home Assistant will try to do math with empty strings (as the state for an expired/dead entity is always set to '') or possibly divide by zero. if that's happening, there should be corresponding log entries where it says something along the lines of: ValueError: could not convert string to float: ''

I would double check the history of all the sensor entities you're using, especially your barometer, and make sure they're not expiring or otherwise going into an unknown state. if they are, fix that first.

leovj commented 3 months ago

Thanks Francis for your help, this morning I updated HA and now the package doesn't seem to work anymore..

Screenshot 2024-03-22 alle 17 49 32

My sensor is a stupid aqara temperature and humidity integrated on HA via Zigbee2MQTT so the value should always maintain it even if it goes offline I think..

These are the errors I found in the registry:

Registratore: homeassistant.helpers.event
Fonte: helpers/template.py:575
Prima occorrenza: 15:41:12 (119 occorrenze)
Ultima registrazione: 17:49:25

Error while processing template: Template<template=(~ {{states.sensor.local_forecast_zambretti_detail.attributes.second_time[0]}}) renders=34>
Error while processing template: Template<template=(Pioggia: {{states.sensor.local_forecast_zambretti_detail.attributes.rain_prob[1]}}% {%if states.sensor.local_forecast.attributes.forecast_temp_short[1] == 1%}{{states.sensor.local_forecast.attributes.forecast_temp_short[0]}}°C{%endif%}) renders=34>
Error while processing template: Template<template=(- {%if states.sensor.local_forecast.attributes.forecast_temp_short[1] >= 0%}{{states.sensor.local_forecast.attributes.temperature}}°C{%endif%}) renders=86>
Error while processing template: Template<template=(Pioggia: {{states.sensor.local_forecast_neg_zam_detail.attributes.rain_prob[0]}}% {%if states.sensor.local_forecast.attributes.forecast_temp_short[1] == 0%}{{states.sensor.local_forecast.attributes.forecast_temp_short[0]}}°C{%endif%}) renders=58>
Error while processing template: Template<template=(Pioggia: {{states.sensor.local_forecast_neg_zam_detail.attributes.rain_prob[1]}}% {%if states.sensor.local_forecast.attributes.forecast_temp_short[1] == 1%}{{states.sensor.local_forecast.attributes.forecast_temp_short[0]}}°C{%endif%}) renders=58>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 573, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2364, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 4, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2037, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 699, in async_render_to_info
    render_info._result = self.async_render(
                          ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 575, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'temperature'
Registratore: homeassistant.components.template.template_entity
Fonte: components/template/template_entity.py:199
integration: Template ([documentazione](https://www.home-assistant.io/integrations/template), [problemi](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+template%22))
Prima occorrenza: 15:41:12 (17 occorrenze)
Ultima registrazione: 17:45:20

    TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({# give approx. values for rain probability #} {%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%if forecast[0]<2 and forecast[1]<2 %}{%set rain_prob = [0,0]%} {%elif forecast[0]==1 and forecast[1]>=2 %}{%set rain_prob = [20,60]%} {%elif forecast[0]==2 and forecast[1]==2 %}{%set rain_prob = [50,50]%} {%elif forecast[0]==2 and forecast[1]>2 %}{%set rain_prob = [50,70]%} {%else%}{%set rain_prob = [90,90]%}{%endif%} {{rain_prob}}) renders=4>' for attribute 'rain_prob' in entity 'sensor.local_forecast_neg_zam_detail'
    TemplateError('UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'forecast'') while processing template 'Template<template=({%set forecast = states.sensor.local_forecast_neg_zam_detail.attributes.forecast%} {%set conditions = [('mdi:weather-sunny','mdi:weather-night'),('mdi:weather-partly-cloudy', 'mdi:weather-night-partly-cloudy'),('mdi:weather-partly-rainy','mdi:weather-partly-rainy'),('mdi:weather-cloudy','mdi:weather-cloudy'),('mdi:weather-rainy','mdi:weather-rainy'),('mdi:weather-pouring','mdi:weather-pouring'),('mdi:weather-lightning-rainy','mdi:weather-lightning-rainy')]%} {# [State][day/night], available states: sunny (0), partlycloudy(1), partlycloudyrain(2), cloudy(3), rainy(4), pouring(5), lightning-rainy(6) #} {%if is_state('sun.sun', 'below_horizon')==true%}{%set daynight=1%}{%else%}{%set daynight=0%}{%endif%} {%set now = conditions[forecast[0]|int(0)][daynight|int(0)]%} {%set later = conditions[forecast[1]|int(0)][daynight|int(0)]%} {{(now,later)}}) renders=4>' for attribute 'icons' in entity 'sensor.local_forecast_neg_zam_detail'
    TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{{ states('sensor.psv_ultimo_mese')|replace(',', '.')|float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.psv_ultimo_mese')|replace(',', '.')|float }}) renders=6>' for attribute '_attr_native_value' in entity 'sensor.costo_gas_attuale'
    TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{{ states('sensor.psv_ultimo_mese')|replace(',', '.')|float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.psv_ultimo_mese')|replace(',', '.')|float }}) renders=10>' for attribute '_attr_native_value' in entity 'sensor.costo_gas_attuale'
    TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{% if states('sensor.piante_garage_illuminazione') == 'unavailable' %} N/A {% elif states('sensor.piante_garage_illuminazione') | float < 7000 %} {{ states('sensor.piante_garage_temperatura') }} {% else %} Sole {% endif %}' but no default was specified') while processing template 'Template<template=({% if states('sensor.piante_garage_illuminazione') == 'unavailable' %} N/A {% elif states('sensor.piante_garage_illuminazione') | float < 7000 %} {{ states('sensor.piante_garage_temperatura') }} {% else %} Sole {% endif %}) renders=10>' for attribute '_attr_native_value' in entity 'sensor.temperatura_condizionale_garage'
francistheodorecatte commented 3 months ago

if you just updated HA, try dumping your browser cache by hitting shift+f5 on your dashboard first, but it looks like your temperature entity is the current problem, as pressure_change statistics entity (and therefore the barometer entity) are working properly. if you haven't already, explicitly set the following in your temperature entity's config: unit_of_measurement: '°C' device_class: 'temperature'

and doublecheck sensor.local_forecast_temperature and sensor.local_forecast_temperaturechange entities aren't unknown/dead.

explicitly setting the unit of measurement and device class for sensor entities as per this list has fixed a lot of integration/automation problems for me in the past, including with this integration.

leovj commented 3 months ago

Thanks Francis. So now it seems to work again, but I haven't changed anything!

Screenshot 2024-03-22 alle 22 20 34

My temperature sensor seems to already be configured correctly..

Screenshot 2024-03-22 alle 22 16 44
DJBenson commented 1 month ago

I tried setting this up earlier this week and it didn't work for me so I moved on until I had more time. The attributes of the sensor were never populated so it never worked properly. I've just gone through all the attributes and changed the format to the "new" format e.g. states('sensor.x') instead of states.sensor.x.state and it's now working.