Living up North in the Winter we have long hours of darkness because of the earth’s tilt away from the sun. This means getting up before the sun rises, and it’s a bit annoying to be jolted awake at 6:00am by an alarm when it’s pitch black outside. Or if I wake up before the alarm goes off, it’s dark, and I can’t tell if I should be going back to sleep or getting ready to get up without consulting a clock.
Wake-up Naturally with Your Own IoT Bulb
For Christmas I got a couple of these MagicLight WiFi Smart LED Bulbs.
There are quite a few IoT (Internet of Things) WiFi Light bulbs on the market, the reason I like these is they don’t rely on the vendors software to control them, and they don’t need to connect out to some cloud service on the internet which increases ones surface area to hackers.
Connect to WiFi
When the bulbs are initially turned on they power on and create their own WiFi hotspot, a phone app connects to it and programs it to connect to your WiFi network. As with all IoT devices I suggest having a dedicated IoT WiFi SSID and VLAN to keep them off the main network. They should get an IP address from DHCP, I then give it a static IP assignment with DHCP in pfSense.
Automate with Home Assistant
Next, install Home Assistant (which is a free open source home automation platform) on a server. I spun up an Ubuntu 16.04 VM.
The MagicLight / Flux Bulbs aren’t smart enough to gradually turn on or off, but I used multiple automation tasks to simulate a gradual fade-on over 30 minutes. The example below will gradually make the light brighter. It starts very dim, at 5:15am and stays dim for awhile. This won’t wake me up if I’m still asleep. Then around 5:40am it starts to get brighter at a faster rate until it reaches full brightness at 6:10am.
This wakes me up “naturally” every winter morning. I’m usually awake well before 6 and feel much better than if I had used an alarm.
The light stays on until 8am then it turns off and waits for the next day.
The nice thing about waking up to a gradual light is if I’m already waking up I’ll get up sometime after 5:15am, but if I’m in a deep sleep it won’t wake me up suddenly so I can get a few extra minutes of sleep until around 6am.
Here’s the part I added to configuration.yaml
light: - platform: flux_led devices: 10.7.0.36: name: flux_office automation 1: alias: Office Light 15 at 5:30am trigger: platform: time after: "5:15" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [15, 15, 6] automation 2: alias: Office Light 65 at 5:40am trigger: platform: time after: "5:40" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [65, 65, 40] automation 3: alias: Office Light 120 at 5:50am trigger: platform: time after: "5:50" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [120, 120, 60] automation 4: alias: Office Light 145 at 6:00am trigger: platform: time after: "6:00" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [145, 145, 75] automation 5: alias: Office Light 165 at 6:05am trigger: platform: time after: "6:05" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [165, 165, 85] automation 6: alias: Office Light 200 at 6:08am trigger: platform: time after: "6:08" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [200, 200, 95] automation 7: alias: Office Light 255 at 6:10am trigger: platform: time after: "6:10" action: service: light.turn_on data: entity_id: light.flux_office transition: 600 rgb_color: [255, 255, 135] automation 8: alias: Turn off at 8am trigger: platform: time after: "8:00" action: service: light.turn_off data: entity_id: light.flux_office transition: 600
There are also some other things one could do, Home Assistant can also monitor the weather and sunrise times. I could probably spend a little more effort and make the script only activate the bulb if the sun hasn’t risen yet, or I could have the bulb wake me up earlier if there’s a lot of snow so I have more time to shovel. Maybe it could be blue when it’s raining so I know to grab my hat.
My home automation script could definitely use some improvements, but even in it’s present state it’s a big improvement over waking up to an alarm.
Hi Benjamin, Did you ever figure out a way of making this track the sun? Just out of interest really. Been setting up HA now for a couple of days and adding more and more to it each day!
Hi, Karl. No, haven’t been able to track the sun, practically I always have to get ready for work at the same time anyway so I’ve just been doing it by time.