The sun component will use your current location to track if the sun is above or below the horizon.The sun can be used within automation as a trigger with an optional offset to simulate dawn/dusk.

# Example configuration.yaml entry

Configuration variables:

  • elevation (Optional): The (physical) elevation of your location, in metres above sea level. If ommitted will be retrieved from Google Maps.

Implementation Details

The sun’s event listener will call the service when the sun rises or sets with an offset.

The sun event need to have the type ‘sun’, which service to call, which event (sunset or sunrise) and the offset.

    "type": "sun",
    "service": "switch.turn_on",
    "event": "sunset",
    "offset": "-01:00:00"

Maintains entity sun.sun

Possible state Description
above_horizon When the sun is above the horizon.
below_horizon When the sun is below the horizon.
State Attributes Description
next_rising Date and time of the next sun rising (in UTC).
next_setting Date and time of the next sun setting (in UTC).
elevation Solar elevation. This is the angle between the sun and the horizon. Negative values mean the sun is below the horizon.
azimuth Solar azimuth. The angle is shown clockwise from north.