Blue hour started
The Blue hour started trigger fires when blue hour begins, the deeper part of twilight just before sunrise and just after sunset when the sky takes on a rich blue color. Blue hour is the period when the sun’s elevation is between 6° and 4° below the horizon, just below golden hour. You can react to the morning blue hour, the evening one, or both. Home Assistant calculates the exact time for every day from your home location.
Use it to turn on garden or path lighting as the sky darkens, start a calm evening scene once the sun is well down, or set the mood for the short blue-lit window.
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 Blue hour started.
- Under Period, select Any, Morning, or Evening.
- Optionally, set an offset to fire before or after blue hour starts:
- Under Offset, enter how far from the start of blue hour to fire, such as 10 minutes.
- Under Offset type, select Before or After.
- Select Save.
Options in the UI
Which blue hour the trigger reacts to:
- Any: both the morning and the evening blue hour. This is the default.
- Morning: only the blue hour before sunrise, while the sun is rising.
- Evening: only the blue hour after sunset, while the sun is descending.
The length of time from the start of blue hour when the trigger fires, in days, hours, minutes, and seconds. By default there is no offset, so the trigger fires exactly when blue hour starts.
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.blue_hour_started. A basic example looks like this:
trigger: sun.blue_hour_started
This fires when either the morning or the evening blue hour starts. To react to only the morning or the evening, add the period option:
trigger: sun.blue_hour_started
options:
period: evening
To fire a fixed amount of time before or after blue hour starts, add the offset and offset_type options:
trigger: sun.blue_hour_started
options:
period: evening
offset:
minutes: 10
offset_type: before
This fires 10 minutes before the evening blue hour starts.
Options in YAML
Which blue hour the trigger reacts to. Accepts any (both the morning and the evening blue hour), morning (the blue hour before sunrise, while the sun is rising), or evening (the blue hour after sunset, while the sun is descending).
The length of time from the start of blue hour when the trigger fires. Accepts a time period mapping in hours, minutes, seconds, and days. Also accepts a duration string in HH:MM:SS format. Combine it with offset_type to fire before or after blue hour starts.
Good to know
- This trigger does not use a target. It applies to the sun at your configured home location.
- Blue hour is the period when the sun’s elevation is between -6° and -4°. In the morning, it starts as the sun rises to -6°. In the evening, it starts as the sun descends to -4°, where golden hour ends.
- To react to the moment blue hour ends, use Blue hour ended. For the warmer light just outside blue hour, use Golden hour started.
- The length of blue hour changes through the year and with your latitude. Near the poles, it can last much longer or fail to occur on some days. When it does not occur, the trigger does not fire that day.
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 next blue hour, or temporarily switch to a trigger you can control while you build the rest of the automation.
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: turn on garden lights when evening blue hour begins
When the evening blue hour starts and the sky turns blue, turn on the garden lights so the yard is lit as it gets dark.
-
Trigger: Blue hour started
- Period: Evening
-
Action: Turn on light
- Target: Garden lights
YAML example for garden lights at blue hour
alias: "Garden lights at evening blue hour"
triggers:
- trigger: sun.blue_hour_started
options:
period: evening
actions:
- action: light.turn_on
target:
entity_id: light.garden
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:
-
Blue hour ended: Triggers when blue hour ends, in the morning, the evening, or either.
-
Golden hour started: Triggers when golden hour starts, in the morning, the evening, or either.
-
Dusk: Triggers at dusk, when civil, nautical, or astronomical twilight ends.