Sunset Sensor

Hello I need to create a sensor in my config with the time of my next sunset using the sun.sun entity. Thank You

Please explain as the sun.sun already is a sensor with that data so why copy?

you can find an example for the usage in the demo template under the developer tools

Use Sun2 instead.

This way you can have yesterday’s, today’s and tomorrow’s sunset, sunrise and a whole lot of other sun related values.

This is my addition to configuration.yaml.


sensor sun2:
  - platform: sun2
    entity_namespace: Copenhagen
    latitude: 55.663
    longitude: 12.553
    time_zone: Europe/Copenhagen
    elevation: 3
    monitored_conditions:
      - sunrise
      - sunset
      - dawn
      - dusk

Which will give these sensors:

1 Like

I need the sunset on its own as I am trying to display it in a chipcard in the Minimalist UI Minimalist UI
If I set it to display sun.sun it looks like this:
Screenshot 2023-02-01 at 19.33.35

Here is the code:

- type: "custom:button-card"
            template: chip_mdi_icon_state
            variables:
                ulm_chip_mdi_icon_state_entity: sun.sun
                ulm_chip_mdi_icon_state_icon: mdi:sun
                ulm_chip_mdi_icon_state_icon_color: yellow

I would like it to display the time of next sunset

I have done this:Screenshot 2023-02-01 at 20.06.50
is there any way to make it just say the time?

{{as_timestamp(state_attr(‘sensor.copenhagen_sunrise’,‘today’),0)|timestamp_custom(’%H:%M’)}}

1 Like