#None has no element 0

1 messages · Page 1 of 1 (latest)

tribal sorrel
#

Question regarding referencing forecast using:
None has no element 0

        - condition: template
          value_template:
            "{% if (state_attr('sensor.daily_weather_forecast', 'forecast')[0].temperature
            | int) > 76 %}\n  {{ true }}\n{% else %}\n  {{ false }}\n{% endif %}"

This works perfectly except, if the internet is down, and then forecast doesn't populate...

I want it to be "true" if this happens. The above template returns: None has no element 0 and then doesn't work.

rough shoal
#
{% set forecasts = state_attr('sensor.daily_weather_forecast', 'forecast') %}
{{ forecasts is none or (forecasts[0].temperature | int(0) > 76) }}