folgendes Template zeigt nur "unbekannt" an.
state: Teil funktioniert im Template-Editot einwandfrei. Woran kann es liegen?
state: Teil funktioniert im Template-Editot einwandfrei. Woran kann es liegen?
Code:
# Zeit seit Sonnenaufgang
- name: "Time Since Sunrise"
unique_id: "time_since_sunrise"
state: |
{% if states('sun.sun') not in ['unknown', 'unavailable'] %}
{% set sunrise = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set now = as_timestamp(now()) %}
{% set last_sunrise = sunrise - 86400 if sunrise > now else as_timestamp(state_attr('sun.sun', 'last_rising')) %}
{% set diff = now - last_sunrise %}
{% if diff > 0 %}
{{ diff | timestamp_custom('%H:%M:%S', false) }}
{% else %}
00:00:00
{% endif %}
{% else %}
unknown
{% endif %}
availability: >
{{ states('sun.sun') not in ['unknown', 'unavailable'] }}
icon: mdi:weather-sunset-up
unit_of_measurement: "hh:mm:ss"