Sun values not valid

Please remove. No answers and I have chose another distribution entirely.

Maybe the documentation helps:

You can see that the times shown in the /dev-state are in UTC.

When you display the values in your GUI, however, they are automatically converted to your local timezone by using the entries in your configuration file. Same is valid for using these times in automations, conditions, etc.

Use this set up as a template sensor:

- platform: template
  sensors:
# Sunset & Sunrise
    next_sunrise:
      friendly_name: Sunrise
      value_template: '{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%H:%M") }}'
    next_sunset:
      friendly_name: Sunset
      value_template: '{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom("%H:%M") }}'

Try this as an entities-card in the Lovelace frontend and you’ll see what I mean:

# Sunset/Sunrise Info
      - type: entities
        title: Sunset & -rise
        entities:
          - entity: sensor.next_sunrise
            name: "Next Sunrise:"
            icon: mdi:weather-sunset-up
          - entity: sensor.next_sunset
            name: "Next Sunset:"
            icon: mdi:weather-sunset-down

.
Or just paste this into the (currently already filled /dev-template
'{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%H:%M") }}'

3 Likes

Thanks for your answer! I will try this out, hoping for a better result :slight_smile:
Cheers

Next time you have a question like this, just share the code that doesn’t work for you.
It’s much easier to provide an answer if people can understand the problem in more detail.

Hi!

Where do I put the 2 codes? in which files?

Thanks:-)