Solar midnight
The Solar midnight trigger fires when the sun reaches its lowest point below the horizon for the day. This is the astronomical midpoint between sunset and sunrise, and it rarely lands exactly at 00:00 on the clock. Home Assistant calculates the exact time from your home location.
Use it as a reliable “deep night” marker: run a nightly maintenance task, reset daily counters, or make sure everything is switched off at the darkest point of the night.
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: Solar midnight.
- Select Save.
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.solar_midnight. It has no options:
trigger: sun.solar_midnight
This fires every day, the moment the sun reaches its lowest point.
Good to know
- This trigger does not use a target. It applies to the sun at your configured home location.
- Solar midnight is the moment the sun is opposite the meridian, not 00:00 on the clock. The clock time drifts through the year and depends on your longitude within your time zone.
- To act on the opposite moment, when the sun is at its highest, use Solar noon.
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 solar midnight, 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: reset a daily counter at solar midnight
At the darkest point of the night, reset a counter so it starts fresh for the new day.
- Trigger: Solar midnight
-
Action: Reset counter
- Target: Daily counter
YAML example for resetting a counter at solar midnight
alias: "Reset daily counter at solar midnight"
triggers:
- trigger: sun.solar_midnight
actions:
- action: counter.reset
target:
entity_id: counter.daily_runs
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:
-
Solar noon: Triggers when the sun reaches its highest point.
-
Sunset: Triggers when the sun sets.
-
Sun elevation changed: Triggers whenever the sun’s elevation changes, optionally limited to a threshold or range you set.