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:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the When section, select Add trigger.
  4. From the search box, search for and select Sun: Sun elevation changed.
  5. 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.
  6. Select Save.

Options in the UI

Threshold type

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:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
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:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
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.

threshold map Required

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 above value. Provide value with a number key (a fixed angle in degrees) or an entity key (an input_number, number, or sensor entity).
  • type: below (exclusive): Fires when the new elevation is strictly below value. Provide value with a number key (a fixed angle in degrees) or an entity key (an input_number, number, or sensor entity).
  • type: between (exclusive): Fires when the new elevation is strictly between value_min and value_max. Provide both, each with a number key (a fixed angle in degrees) or an entity key.
  • type: outside (inclusive): Fires when the new elevation is at or below value_min, or at or above value_max. Provide both, each with a number key (a fixed angle in degrees) or an entity key.

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.

Tip

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
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
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.

Tip

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: