So we made a mistake with our young son awhile back telling him it wasn’t OK to get out of bed in the morning until the sun was up. Fast forward to the spring/summer months and the sun is up in the 5:00 a.m. hour and we are paying for past choices.
Our son is learning his numbers and can identify them, however, telling time isn’t a bridge we have crossed yet. Colors however, he does well.
A number of friends have had good luck with products like this OK to Wake Light. Of course homeassistant seemed like a better solution to me and could allow dynamic wake up times and easy remote changing of parameters!
Materials:
This could be done with just about any light bulb or other light that can do color and can be connected to Home Assistant. These are just the specific materials I used.
I picked up a WiFi RGBW LED Controller and a RGBW LED strip off Amazon. The RGBW is important versus a RGB as it has a separate white channel. The RGB strips, IMO, aren’t great at creating white light. We wanted to use this as a reading light also so having the white option was important. You will need a 12V power supply also (I had a spare laying around).
I had previously picked up some Aluminum LED Channel/Diffuser and use this to mount the lights to his bed. The controller is stuck on the back of his bed with the supplied adhesive strip.
Optional: I use a Kuled K36 switch flashed with Tasmota for the main room light. The double tap feature in Tasmota was used to control the LED strip.
Setup and HomeAssitant Integration
The LED controller works with the Flux LED integration:
My setup for the light is as follows:
light:
- platform: flux_led
devices:
192.168.1.4:
name: Mikey's Bed Lights
mode: "rgbw"
Automations:
Reading Light:
The first automation is a simple one to turn on the LED strip at night when the main wall switch in his room is given a double tap.
- alias: "Kuled3 Double Tap"
initial_state: true
trigger:
platform: mqtt
topic: cmnd/kuledbutton3/POWER
payload: "TOGGLE"
action:
- service_template: >-
{%- if is_state('light.mikey_s_bed_lights' , 'off') -%}
script.readinglight
{%- else -%}
script.fadebedlightoff
{%- endif -%}
The subsequent script that is called if the LED strip is off is just a specific color to allow a warmer white light. The LED strip has a pretty cool white LED. It calls the same service twice as it sometimes doesn’t like to change the color LED and the white LED at the same time.
readinglight:
sequence:
- service: light.turn_on
entity_id: light.mikey_s_bed_lights
data:
rgb_color: [255,100,0]
brightness: 255
white_value: 255
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.mikey_s_bed_lights
data:
rgb_color: [255,100,0]
brightness: 255
white_value: 255
Fade to Sleep Light:
Another double tap on the wall switch when we leave the room triggers the automation from the reading light info above. However, since the LED strip is already on, it triggers a different script to slowly fade the LED strip off over ~20 minutes.
This is a super long script due to the capabilities of my LED strip controller and HA combined. It basically takes the current level of the RGB and White LED and subtracts ~10% every two minutes in the beginning and less as time goes on to make the change more gradual. It accounts for the light being any color and if the RGB or White LED is already off or very low and sends an 0 value as negative numbers will throw an error.
The script is really long so I will just link to it on my GitHub:
I think this could be done ALOT easier with the transistion
function available, however it doesn’t work with my lights. If are using an RGB only strip, the brightness_step
options are likely also easier.
Morning Time/ OK to Wake
At 5:00 a.m the light strip turns on a very low red. If he wakes up and sees red, he knows to go back to sleep.
- alias: "OK to Wake Red"
initial_state: true
trigger:
platform: time
at: '05:00'
action:
service: light.turn_on
data:
entity_id: light.mikey_s_bed_lights
brightness: 5
rgb_color: [255,0,0]
white_value: 0
At 7:00 the light turns green and lets him know it is OK to get out of bed.
- alias: "OK to Wake Green"
initial_state: true
trigger:
platform: time
at: '07:00'
action:
service: light.turn_on
data:
entity_id: light.mikey_s_bed_lights
brightness: 5
rgb_color: [0,255,0]
white_value: 0
At 8:00 a final automation turns off the light. He is always up by this point.
- alias: "OK to Wake Off"
initial_state: true
trigger:
platform: time
at: '08:00'
action:
service: light.turn_off
data:
entity_id: light.mikey_s_bed_lights
Teaching your Kid:
One of the biggest parts of this is telling your kid how this all works. They need to be able to identify colors and understand what each of them means in the morning. Also explain that lights are going to fade off by themselves at night. My son really loves having the light and understood it from the start. He did request that the light be able to be any color at night while it fades to off. This required some revision of the script but works now.
Future Plans:
I want to make the morning times dynamic. I think it would be nice to have different wake up times based on different needs. When he is back in school he may need to wake up earlier or on the weekends it could be nice to sleep in a bit. I think this is very possible, I just need to take the time to figure out.