Sunrise and sunset automation is a type of smart home rule that triggers actions from the calculated solar events at the home’s location, rather than from a fixed clock time. In home automation, it is the standard way to switch porch lights on at dusk, close blinds after sunset or open them at dawn, because the trigger shifts automatically with the seasons and with daylight saving time.
The approach is also called sun-based automation. It relies on an astronomical calculation, not on a light sensor: the hub knows the latitude, longitude and date, and computes when the sun crosses the horizon or a chosen elevation angle.
How solar triggers are calculated
A sun-based trigger works by computing solar position from coordinates and time. Platforms such as Home Assistant, openHAB, Hubitat and Apple Home use standard astronomical algorithms that model the Earth’s orbit, axial tilt and the equation of time, then report sunrise, sunset and twilight times for each day. Sunrise is officially the moment the upper edge of the sun appears, which corresponds to a solar elevation of about -0.83 degrees once atmospheric refraction is included.
Because the calculation is local, the automation works without internet access once the hub has its location and an accurate clock. Accuracy is typically within one or two minutes of published tables, which is far finer than the variation caused by weather. The main source of error is a wrong location setting, for example coordinates left at a default city.
The following table shows the solar events that most hubs expose and how they are defined.
| Event | Sun elevation | Typical use |
|---|---|---|
| Sunrise | About -0.83 degrees, rising | Open blinds, end night mode |
| Sunset | About -0.83 degrees, setting | Turn on porch and garden lights |
| Civil dusk | -6 degrees | Indoor lighting when rooms become dim |
| Nautical dusk | -12 degrees | Security lighting, full darkness outdoors |
| Astronomical dusk | -18 degrees | Rarely used; sky fully dark |
| Solar noon | Highest point of the day | Shade control on south-facing windows |
Offsets, elevation triggers and conditions
Real homes rarely want an action exactly at sunset, so solar rules support time offsets and elevation thresholds. An offset such as “30 minutes before sunset” is simple to understand, but the actual darkness at that moment varies with latitude and season, since twilight lasts longer in summer and at high latitudes.
An elevation-based trigger, such as “sun below -4 degrees”, fires at a consistent level of natural light all year, which makes it more predictable for lighting. Many hubs also offer the sun as a condition rather than a trigger, for example “after sunset and before sunrise”, so that a motion sensor turns on a hallway light only at night.
The table below compares the main configuration options.
| Option | Example | Strength | Weakness |
|---|---|---|---|
| Plain solar event | At sunset | Simplest to set up | Light level differs by season |
| Time offset | 20 minutes before sunset | Easy to fine-tune | Offset drifts in meaning with latitude |
| Elevation threshold | Sun below -3 degrees | Consistent brightness all year | Not supported on every platform |
| Sun as condition | Motion only after sunset | Combines with other triggers | Needs a separate trigger to act |
| Clamped time | Sunset, but not before 17:00 | Prevents very early actions | More complex rule logic |
Solar schedules compared with other triggers
Sun-based rules sit between fixed time-based automation and sensor-driven automation, and each has a place. A fixed schedule ignores the seasons, so lights that switch on at 18:00 are too late in winter and wasteful in summer. A light sensor measures actual brightness, but reacts to clouds, shadows and headlights, and needs hysteresis or delays to avoid flickering on and off.
The comparison below helps decide which trigger fits a given task.
| Trigger type | Reacts to weather | Needs hardware | Best suited for |
|---|---|---|---|
| Sunrise and sunset | No | No, only location | Outdoor lights, blinds, vacation simulation |
| Fixed time | No | No | Tasks tied to the household routine |
| Illuminance sensor | Yes | Lux sensor | Indoor lights on dark, overcast days |
| Presence detection | No | Phones or sensors | Actions tied to people arriving or leaving |
| Combined rule | Partly | Depends on design | Sunset trigger with a lux condition |
Experienced users often combine solar and sensor logic: the sunset event acts as a safe default, while an illuminance reading turns lights on earlier during a storm. This hybrid design keeps behavior predictable without ignoring real conditions.
Practical uses in the home
Solar rules cover the most common lighting and shading routines with little effort. Typical scenarios include the following.
- Exterior lighting: porch, path and garden lights at civil dusk, off at a fixed late-night time or at sunrise.
- Motorized blinds and shutters: open after sunrise on weekdays, close at sunset for privacy and insulation.
- Away mode and vacation simulation: interior lights follow sunset with random delays so the home looks occupied.
- Circadian or adaptive lighting: color temperature shifts warmer as the sun sets, cooler around solar noon.
- Energy management: solar noon or sun elevation steers loads such as water heating toward periods of rooftop solar production.
In Home Assistant and similar platforms, these rules are often packaged as an automation blueprint, so the same logic can be reused across rooms with different offsets.
Common mistakes and limitations
Most problems with sun-based automation come from configuration rather than the calculation. The table lists frequent symptoms and their fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Lights switch on far too early or late | Wrong home coordinates or time zone | Set exact location and verify hub clock |
| Action fires one hour off | Daylight saving handled incorrectly | Use the hub’s local time zone, not UTC offsets |
| Rule never fires in summer | Polar day at high latitudes | Add a fallback time trigger |
| Blinds open before residents wake | Sunrise is very early in June | Clamp with a not-before time condition |
| Missed action after power outage | Hub restarted after the event | Add a startup check that applies the expected state |
One structural limit deserves attention: solar events do not measure real light. On a dark winter afternoon, a sunset rule still waits for the calculated time, which is why a lux condition or manual override remains useful.
In simple terms
Sunrise and sunset automation lets a smart home act on the sun’s daily schedule instead of a fixed clock. The system knows where the house is and works out when the sun will rise and set each day.
So instead of setting the porch light for 18:00 and changing it every few weeks, the light simply turns on when it gets dark outside, in December as well as in June. It is like a gardener who starts and ends work with daylight rather than by the clock. The key benefit is that routines stay right all year without any manual changes.
A practical example
A family in a house at about 50 degrees north uses a local hub to manage garden lights and motorized living room shutters. Their first rule, lights on at 18:30, worked in autumn but left the garden dark for over two hours in December. They replaced it with a rule that fires when the sun drops below -4 degrees, which happens around 16:40 in midwinter and close to 21:50 in midsummer.
The shutters close 15 minutes after sunset and open at sunrise, but never before 07:00 on weekdays or 08:30 on weekends, thanks to a clamp condition. During vacations, interior lamps follow the same sunset trigger with random delays of up to 20 minutes. The household has not adjusted a lighting time in over a year, and the garden lights now run about 40 percent fewer hours in summer than under the old fixed schedule.