Personal "condition_template" in Template Weather Provider!

Hi everyone, how to set a variable in “condition template” in Template Weather Provider? where am I going wrong?

it returns an unknown value

Immagine

This is the code

weather:
  - platform: template
    name: "Stazione Meteo Casa"
    unique_id: "stazione_meteo_casa"
    condition_template: |
         [[[
         if (states['sensor.stazione_meteo_pluviometro_precipitazione'].state > '0') {
         return `rainy`;
         }
         return (states['weather.accuweather'].state);
         ]]]
....

I need it because the weather providers (I’ve tried many) are not reliable on real-time weather conditions and the netatmo integration (which I use for my personal weather station) does not have this entity (absurd!)

You are using javascript templates where jinja2 templates are expected.

weather:
  - platform: template
    name: "Stazione Meteo Casa"
    unique_id: "stazione_meteo_casa"
    condition_template: |
       {% if states('sensor.stazione_meteo_pluviometro_precipitazione') | float(0) > 0 %}
         {{ 'rainy' }}
       {% else %}
         {{ states('weather.accuweather') }}
       {% endif %}
         

…here is the error!!
Great…now it works!

Thanks

1 Like