Sunrise and sunset automation

Also known as: sun-based automation

On this page 7

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.

EventSun elevationTypical use
SunriseAbout -0.83 degrees, risingOpen blinds, end night mode
SunsetAbout -0.83 degrees, settingTurn on porch and garden lights
Civil dusk-6 degreesIndoor lighting when rooms become dim
Nautical dusk-12 degreesSecurity lighting, full darkness outdoors
Astronomical dusk-18 degreesRarely used; sky fully dark
Solar noonHighest point of the dayShade control on south-facing windows
Solar events available as triggers

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.

OptionExampleStrengthWeakness
Plain solar eventAt sunsetSimplest to set upLight level differs by season
Time offset20 minutes before sunsetEasy to fine-tuneOffset drifts in meaning with latitude
Elevation thresholdSun below -3 degreesConsistent brightness all yearNot supported on every platform
Sun as conditionMotion only after sunsetCombines with other triggersNeeds a separate trigger to act
Clamped timeSunset, but not before 17:00Prevents very early actionsMore complex rule logic
Ways to express a sun-based rule

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 typeReacts to weatherNeeds hardwareBest suited for
Sunrise and sunsetNoNo, only locationOutdoor lights, blinds, vacation simulation
Fixed timeNoNoTasks tied to the household routine
Illuminance sensorYesLux sensorIndoor lights on dark, overcast days
Presence detectionNoPhones or sensorsActions tied to people arriving or leaving
Combined rulePartlyDepends on designSunset trigger with a lux condition
Trigger types for daylight-related tasks

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.

SymptomLikely causeFix
Lights switch on far too early or lateWrong home coordinates or time zoneSet exact location and verify hub clock
Action fires one hour offDaylight saving handled incorrectlyUse the hub’s local time zone, not UTC offsets
Rule never fires in summerPolar day at high latitudesAdd a fallback time trigger
Blinds open before residents wakeSunrise is very early in JuneClamp with a not-before time condition
Missed action after power outageHub restarted after the eventAdd a startup check that applies the expected state
Troubleshooting sunrise and sunset rules

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.