Sunset/Sunrise Sensor stopped working, while template does

I’ve had a sensor to translate the sun.sun next_setting & next_rising into a short time format, to display it in a Badge. As of v2021.12 of HA the sensors have stopped working, while the template seems valid and working.

This should not be impacted by the breaking change to timestamp_local and timestamp_utc

Anyone any idea why this template works, when testing it in the Developer Tools Template editor and doesn’t for my 2 sunset/sunrise sensors?

# Sunrise & Sunset time
- sensor:
  - name: "Sunrise"
    unit_of_measurement: ^
    icon: mdi:weather-sunset-up
    device_class: timestamp
    state: >
      {{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%H:%M") }}
  - name: "Sunset"
    unit_of_measurement: ˅
    icon: mdi:weather-sunset-down
    device_class: timestamp
    state: >
      {{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom("%H:%M") }}

There may be an issue with device_class: timestamp.

One of you two should open an issue.

I have opened an issue:

1 Like

I was going to mention the requirement for a timestamp or ISO date.

Looks like that was your issue.

Screenshot 2021-12-13 at 23-24-54 Sensor

https://www.home-assistant.io/integrations/sensor/#device-class

Just remove device_class timestamp, especially if you were using it to just grab the state as HH:MM