Sun elevation changed
The Sun elevation changed trigger fires when the sun’s elevation changes. Elevation is the angle between the sun and the horizon: 0° is right at the horizon, positive values are above it, and negative values are below it. Home Assistant recalculates the elevation continuously as the sun moves through the sky.
Use the threshold type to filter which changes matter. You can react to any change, or only to changes that land above an angle, below an angle, inside a range, or outside a range. This is handy for logging the sun’s path or for automations that should respond while the sun stays in a particular part of the sky.
Using this trigger from the user interface
If you prefer building automations visually, Home Assistant walks you through this trigger step by step. You pick what to watch, tweak a few options, and save. No YAML knowledge required.
To use this trigger in an automation:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the When section, select Add trigger.
- From the search box, search for and select Sun: Sun elevation changed.
- Under Threshold type, configure which changes fire the trigger:
- Select Any change to fire on every elevation change, regardless of value.
- Select Above or Below and enter an angle in degrees to fire only when the new elevation is above or below that angle.
- Select In range and enter a lower and upper angle to fire only when the new elevation falls inside the range.
- Select Outside range and enter a lower and upper angle to fire only when the new elevation is outside the range.
- For each option except Any change, you can enter a fixed angle in degrees, or reference a sensor entity or a number helper entity that holds the angle.
- Select Save.
Options in the UI
Controls which changes fire the trigger. Angles are in degrees, where 0° is the horizon, positive is above, and negative is below.
- Any change: fires on any elevation change, regardless of value.
- Above or Below (exclusive): fires only when the new elevation is strictly above or below the angle.
- In range (exclusive): fires only when the new elevation is strictly between the two angles.
- Outside range (inclusive): fires when the new elevation is at or below the lower angle, or at or above the upper angle.
For each mode except Any change you can enter a fixed angle in degrees, or reference a sensor entity or a number helper entity.
Using this trigger in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.
In YAML, refer to this trigger as sun.elevation_changed. A basic example looks like this:
trigger: sun.elevation_changed
options:
threshold:
type: any
This fires on every elevation change. To fire only while the new elevation is above an angle, use type: above with a value:
trigger: sun.elevation_changed
options:
threshold:
type: above
value:
number: 30
Options in YAML
YAML sometimes provides additional options for more complex use cases that are not available through the UI.
A mapping that defines which kind of change fires the trigger. Angles are in degrees.
-
type: any: Fires on any change (no additional keys needed). -
type: above(exclusive): Fires when the new elevation is strictly abovevalue. Providevaluewith anumberkey (a fixed angle in degrees) or anentitykey (aninput_number,number, orsensorentity). -
type: below(exclusive): Fires when the new elevation is strictly belowvalue. Providevaluewith anumberkey (a fixed angle in degrees) or anentitykey (aninput_number,number, orsensorentity). -
type: between(exclusive): Fires when the new elevation is strictly betweenvalue_minandvalue_max. Provide both, each with anumberkey (a fixed angle in degrees) or anentitykey. -
type: outside(inclusive): Fires when the new elevation is at or belowvalue_min, or at or abovevalue_max. Provide both, each with anumberkey (a fixed angle in degrees) or anentitykey.
Good to know
- This trigger does not use a target. It always watches the sun at your configured home location.
- Elevation updates often, so Any change and the threshold types fire repeatedly while the sun is moving. If you want to react only to a single crossing of an angle, use Sun elevation crossed threshold instead.
- The maximum elevation the sun reaches depends on your latitude and the time of year, so pick threshold angles that the sun actually reaches at your location.
- To work with named twilight phases rather than raw angles, use Dawn and Dusk.
Try it yourself
Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, then change the state of the targeted entity to watch the trigger fire on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].
For this trigger, there is no target entity to change. To test it, wait for the sun to move, or temporarily set a threshold the sun is about to pass.
More examples
Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: dim the lights while the sun is high
While the sun’s elevation stays above 30°, keep the living room lights dimmed to save energy when there is plenty of daylight.
-
Trigger: Sun elevation changed
- Threshold type: Above (30°)
-
Action: Turn on light (brightness 30%)
- Target: Living room lights
YAML example for dimming lights while the sun is high
alias: "Dim lights while the sun is high"
triggers:
- trigger: sun.elevation_changed
options:
threshold:
type: above
value:
number: 30
actions:
- action: light.turn_on
target:
entity_id: light.living_room
data:
brightness_pct: 30
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the trigger you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain triggers or suggest the right one when you describe what you want in plain language.
Related triggers
These triggers work well alongside this one:
-
Sun elevation crossed threshold: Triggers when the sun’s elevation crosses a threshold you set.
-
Solar noon: Triggers when the sun reaches its highest point.
-
Solar midnight: Triggers when the sun reaches its lowest point.