How to Automate Lights Based on Sunrise and Sunset (2026)
Automating lights based on sunrise and sunset is the single most impactful automation you can set up in a smart home. It takes 5 minutes to configure and saves you from ever walking into a dark house again.
This guide covers exactly how to do it on every major platform: Alexa, Google Home, Apple Home, and Home Assistant.
Why Sunrise/Sunset Triggers Beat Fixed Schedules
A fixed schedule breaks twice a year. Sunset in June is around 9:15 PM where I live. In December, it’s 4:45 PM. That’s a 4.5-hour swing. If you set your porch lights to turn on at 7 PM, they’re either too early in summer or way too late in winter.
Sunrise/sunset triggers solve this permanently. They shift with the seasons automatically. Set it once, forget it forever.
Which Lights to Automate First
Not every light needs this treatment. Start with these three:
Porch and exterior lights: The most obvious choice. Nobody wants a dark front porch when they come home. Turn on at sunset, off at sunrise (or 11 PM to save energy).
Living room lamp: A single lamp at 40% brightness makes the house feel lived-in when sunset hits. Great for security, too.
Hallway or entryway: If you come home after dark, you don’t want to fumble for a switch. Set these to turn on at sunset at 20-30% brightness.
For bulb recommendations, check out our best smart bulbs guide.
Method 1: Alexa Routines (Easiest)
Alexa added native sunrise/sunset triggers and they work great. Here’s the exact setup:
- Open the Alexa app
- Tap “More” then “Routines”
- Tap ”+” to create a new routine
- Under “When this happens,” select “Schedule”
- Choose “Sunrise” or “Sunset”
- Set your offset (I recommend +15 minutes after sunset)
- Under “Add action,” select “Smart Home” then choose your lights
- Set brightness and color temperature
- Save the routine
The offset feature is critical. Sunset technically happens when the sun touches the horizon, but it’s still light outside for another 15-20 minutes. Setting +15 minutes after sunset means your lights come on right when it actually gets dark.
For the morning routine, try -30 minutes before sunrise to wake up gently with lights fading in.
Want more Alexa routine ideas? See our comparison of Home Assistant vs Alexa Routines.
Method 2: Google Home Automations
Google Home handles this through their “Automations” tab.
- Open the Google Home app
- Tap “Automations” at the bottom
- Tap ”+” then “Household”
- Under starters, select “At sunrise” or “At sunset”
- Choose which home location to use
- Set offset (up to 4 hours before or after)
- Under actions, select your lights and set brightness/color
- Save
Google’s offset support goes up to 4 hours, which is more than you’d ever need. One annoyance: you can’t set a gradual fade-in within the automation itself. The lights snap to whatever level you pick.
Google does let you specify days of the week. Maybe you only want this on weekdays because you’re home on weekends and prefer manual control. That flexibility is nice.
Method 3: Apple Home (Time-Based Automation)
Apple Home handles sunrise/sunset through the Home app’s “Automation” tab.
- Open the Home app
- Tap “Automation” (or ”+” in the Automations section)
- Choose “A Time of Day Occurs”
- Select “Sunset” or “Sunrise”
- Adjust the offset using the slider
- Choose “People” conditions (when someone is home, nobody home, etc.)
- Select your lights and configure the scene
- Toggle “Run After Confirmation” off for fully automatic operation
Apple’s advantage is the people condition. You can say “only turn on the porch light at sunset IF someone is home.” This prevents wasted energy when you’re traveling. Though honestly, lights on when you’re away is decent security.
The offset slider works in 15-minute increments up to 1 hour. Less flexible than Google’s 4-hour range, but good enough for most people.
If you’re building an Apple-based smart home, our guide on how to start a smart home from scratch covers the ecosystem choice.
Method 4: Home Assistant (Most Powerful)
Home Assistant uses the sun.sun entity, which tracks sunrise and sunset based on your configured location. This is the most flexible option by far.
Basic automation in YAML:
automation:
- alias: "Lights on at sunset"
trigger:
- platform: sun
event: sunset
offset: "+00:15:00"
action:
- service: light.turn_on
target:
entity_id:
- light.porch
- light.living_room_lamp
data:
brightness_pct: 70
color_temp_kelvin: 2700
For gradual dimming at night, add a second automation:
- alias: "Dim lights at 10 PM"
trigger:
- platform: time
at: "22:00:00"
action:
- service: light.turn_on
target:
entity_id: light.living_room_lamp
data:
brightness_pct: 30
transition: 900
That transition: 900 means the light takes 15 minutes (900 seconds) to dim from its current level down to 30%. It’s barely noticeable in real time, which is exactly the point.
Home Assistant also supports elevation-based triggers. Instead of sunset, you can trigger when the sun drops below a specific angle (like -6 degrees for civil twilight). Overkill for most people, but available if you want it.
For a full Home Assistant guide, check our best smart home hub comparison.
The Offset Trick That Makes Everything Feel Natural
Here’s what I’ve settled on after 3 years of tweaking:
- Exterior lights ON: Sunset + 10 minutes
- Living room lamp ON: Sunset + 5 minutes
- Hallway ON: Sunset + 0 (low brightness)
- All lights dim to 30%: 10:00 PM (fixed time, not sun-based)
- Exterior lights OFF: Sunrise - 10 minutes
- Interior lights OFF: Sunrise + 0
Staggering by 5-10 minutes prevents the “everything just snapped on at once” feeling. It mimics how you’d naturally turn on lights: porch first when you notice it’s dark, then inside.
Gradual Dimming at Night
Smart bulbs really shine here. Instead of lights staying at 70% until you turn them off, set up a gradual dim schedule:
- Sunset + 15 min: 70% brightness, warm white (2700K)
- 9:00 PM: 50% brightness, warmer (2200K)
- 10:00 PM: 30% brightness, very warm (2000K)
- 11:00 PM or bedtime: Off
This isn’t just cozy. It helps your circadian rhythm. Blue-heavy light in the evening suppresses melatonin. Shifting to warm, dim light before bed genuinely helps you sleep better.
Not all bulbs support color temperature changes. If yours don’t, just dimming is still worthwhile. See which bulbs handle this best in our smart bulbs comparison.
Platform Comparison Table
| Platform | Setup Steps | Offset Support | Dimming Support | Difficulty |
|---|---|---|---|---|
| Alexa Routines | 5-6 taps in app | Yes, per-minute | Set specific % only | Easy |
| Google Home | 5-6 taps in app | Yes, up to 4 hours | Set specific % only | Easy |
| Apple Home | 5-6 taps in app | Yes, 15-min increments | Scenes with % levels | Easy |
| Home Assistant | YAML or UI editor | Yes, per-second precision | Gradual transitions supported | Medium |
Tips for Reliability
Use local control when possible. Cloud-based automations (Alexa, Google) depend on your internet. If WiFi goes down at sunset, your lights won’t turn on. Home Assistant running locally with Zigbee bulbs works even during outages.
Test your offset. After setting up, pay attention for a few days. Does it get dark before your lights activate? Adjust by 5 minutes. Every house is different because of trees, buildings, and window direction.
Don’t forget seasonal changes. Your offset might be perfect in summer but slightly off in deep winter when twilight is shorter. Most people find +10 to +20 minutes works year-round.
For more automations worth setting up, see our best smart home automations guide.
FAQ
Can I use sunrise/sunset automations without smart bulbs? Yes. Smart switches and smart plugs work too. Plug a regular lamp into a smart plug, and you can schedule it on sunset. You just won’t get dimming or color temperature changes.
Do sunrise/sunset triggers account for daylight saving time? Yes. All platforms calculate actual sunrise/sunset times based on your GPS location and the current date. Daylight saving shifts are handled automatically.
What happens on cloudy days when it gets dark earlier? None of these platforms adjust for cloud cover. They use astronomical sunset times regardless of actual light levels. If you want cloud-aware lighting, you’d need Home Assistant with a lux sensor. Our best smart sensors guide covers those options.
Can I combine sunrise/sunset with motion sensors? Absolutely. A great setup: after sunset, if motion is detected in the hallway, turn on the light at 30%. The light only activates when someone walks through, but only during dark hours.
Will this work if I have multiple homes in my account? Yes. Each home calculates its own sunrise/sunset times independently. Alexa, Google, and Apple all support multiple locations with separate automations per home.