gieljnssns / buienalarm-sensor-homeassistant

Buienalarm custom_component for Home-Assistant
MIT License
35 stars 6 forks source link

Template issue #28

Open JoeAstor opened 2 years ago

JoeAstor commented 2 years ago

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 🙂

bramstroker commented 2 years ago

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