buienalarm-sensor-homeassistant icon indicating copy to clipboard operation
buienalarm-sensor-homeassistant copied to clipboard

Template issue

Open JoeAstor opened this issue 3 years ago • 1 comments

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 🙂

JoeAstor avatar Nov 09 '21 19:11 JoeAstor

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 %}

bramstroker avatar Aug 27 '22 13:08 bramstroker