The sun integration will use the location as configured in your Home Assistant configuration to track if the sun is above or below the horizon. The sun can be used within automations as a trigger with an optional offset to simulate dawn/dusk or as a condition with an optional offset to test if the sun has already set or risen.
Configured by default
This integration is by default configured and installed, and you don’t need
to configure it yourself, unless you’ve disabled or removed the
default_config: line from your
If that is the case, you can configure it as described in the next paragraphs.
Adding Sun to your Home Assistant instance can be done via the user interface, by using this My button:
If the above My button doesn’t work, you can also perform the following steps manually:
Browse to your Home Assistant instance.
In the sidebar, select Settings.
From the configuration menu, select Devices & Services.
In the bottom right, select the Add Integration button.
From the list, search and select Sun.
Follow the instructions on screen to complete the setup.
Alternatlively, this integration can be configured and set up manually via YAML
instead. To enable the sun integration in your installation, add the
following to your
# Example configuration.yaml entry sun:
The sun’s event listener will call the service when the sun rises or sets with an offset.
The sun trigger need to have the type ‘sun’, which event (sunset or sunrise) and an optional offset.
trigger: - platform: sun event: sunrise offset: "-01:00:01"
||An optional offset for the sun event trigger, in a positive or negative number of seconds, or specified in
Maintains entity sun.sun
||When the sun is above the horizon.|
||When the sun is below the horizon.|
The sensors are also available as attributes on the
sun.sun entity for backwards compatibility reasons.
|Next rising||Date and time of the next sun rising (in UTC).|
|Next setting||Date and time of the next sun setting (in UTC).|
|Next dawn||Date and time of the next dawn (in UTC).|
|Next dusk||Date and time of the next dusk (in UTC).|
|Next noon||Date and time of the next solar noon (in UTC).|
|Next midnight||Date and time of the next solar midnight (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.|
||True if the Sun is currently rising, after solar midnight and before solar noon.|