buienalarm-sensor-homeassistant
buienalarm-sensor-homeassistant copied to clipboard
Template issue
After update october/november i have logbook error.
Error
Template warning: 'as_timestamp' got invalid input 'unknown' when rendering template '{% if as_timestamp(states('sensor.buienalarm_next_rain_forecast')) %} {{ ( ( as_timestamp(states('sensor.buienalarm_next_rain_forecast')) - as_timestamp(now()) ) / 60 ) | round }} {% else %} {{ states('nonexistent') }} {% endif %}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2022.1
Thanks for checking 🙂
Something like this will fix it:
{% set state = states('sensor.buienalarm_next_rain_forecast') %}
{% if state == "unknown" %}
unknown
{% elif as_timestamp(state) %}
{{ ( ( as_timestamp(state) - as_timestamp(now()) ) / 60 ) | round }}
{% else %}
unknown
{% endif %}