Sun sunrise/set template no longer working

This is odd.

I’ve had the times of sunrise and sunset on my wall panel for over a year now. I create my entities with the following yaml@

template:
  sensor:
    - name: nextsunrise
      icon: mdi:weather-sunset-up
      unit_of_measurement: " "
      state: >
        {{as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%H:%M')}}
    - name: nextsunset
      icon: mdi:weather-sunset-down
      unit_of_measurement: " "
      state: >
        {{as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom('%H:%M')}}

I’ve noticed that the entities are no longer available. I have lots of other entities in the template/sensor block that still work fine and the template itself still works fine in developer tools.

Have I missed a breaking change or something?

As an aside, I have recently installed Studio Code Server as an alternate file editor and the whole block of yaml for the template/sensors is marked as having a problem with the error

Incorrect type. Expected "array"

Like I said everything else appears to be working.

Remove the unit_of_measurement lines.

1 Like

Thanks, that solved it.

But they have always been there and I don’t know why!

System update — it’s now more strict about the use of units.

Where can we find info on that breaking change? I looked in the release notes and didn’t find anything obvious.

It’s an SBD: "Sun" attribute sensor shows as Unknown when it worked before - #9 by 123

1 Like

thanks for the link.

I thought I had seen it somewhere but I couldn’t remember where until you posted that link.

it would still be nice to know where the change was defined so we could know what the new rules for this kind of thing is.

I’m not asking you to find it for me but just generally remarking on these kind of silent breaking changes in general.