It is blue hour
The It is blue hour condition passes during blue hour, 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 match any blue hour, or narrow it to the morning or the evening. Home Assistant works this out from your home location.
Use it to run an automation during that short, blue-lit window, like turning on garden or path lighting as the sky darkens, or starting a calm evening scene once the sun is well down.
Using this condition from the user interface
If you prefer building automations visually, Home Assistant walks you through this condition step by step. You pick what to check, tweak a few options, and save. No YAML knowledge required.
To use this condition in an automation:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the And if section, select Add condition.
- From the search box, search for and select It is blue hour.
- Under Period, select Any, Morning, or Evening.
- Select Save.
Options in the UI
Using this condition 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 condition as sun.is_blue_hour. A basic example looks like this:
condition: sun.is_blue_hour
This passes during any blue hour. To match only the morning or the evening, add the period option:
condition: sun.is_blue_hour
options:
period: evening
Options in YAML
Good to know
- This condition does not use a target. It checks the sun at your configured home location.
- Blue hour is the period when the sun’s elevation is between -6° and -4°. To test if the sun’s elevation is just above it, between -4° and 6°, use It is golden hour.
- Blue hour falls within civil twilight. For the wider twilight periods, use It is morning twilight and It is evening twilight.
- 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, and the condition does not pass then.
Try it yourself
Ready to test this? Go to Settings > Automations & scenes, open an automation, and add this condition. Trigger the automation with and without the condition met, and watch whether it continues or stops.
More examples
Real scenarios where this condition gates an automation. 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 during evening blue hour
When someone is home during the evening blue hour, turn on the garden lights so the yard is lit as the sky darkens.
- Trigger: Someone comes home
-
Condition: It is blue hour
- Period: Evening
-
Action: Turn on light
- Target: Garden lights
YAML example for garden lights during blue hour
alias: "Garden lights during blue hour"
triggers:
- trigger: state
entity_id: person.alex
to: "home"
conditions:
- condition: sun.is_blue_hour
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 condition 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 conditions or suggest the right one when you describe what you want in plain language.
Related conditions
These conditions work well alongside this one:
-
It is golden hour: Tests if it is golden hour, optionally for a specific period.
-
It is evening twilight: Tests if it is evening twilight, optionally of a specific type.
-
It is morning twilight: Tests if it is morning twilight, optionally of a specific type.