I use this template for a sensor that tracks Google Home alarms. But sometimes my alarms and timer entities are hidden/not shown in states instead of showing “unavailable”.
{% if (states('sensor.bedroom_speaker_alarm')) != "unavailable" %}
{{ (as_timestamp(now()) -
as_timestamp(strptime(states('sensor.bedroom_speaker_alarm'), '%Y-%m-%dT%H:%M:%S+01:00')))|int }}
{% else %}
0
{% endif %}
When there’s no entity, I get logs with errors every minute. Is there any way to prevent the errors in case the entities go missing again?
P.S. entities sometimes go missing after restarting Hassio. When I set an alarm or timer, they show up in the states again.