IoT Kids Night Lights

Backstory: We have 2 small toddlers, who recently moved into a room together.
They still need night-lights, and will at some stage need reading lights. In addition to this, we’re trying to get them to not get out of bed and come through to our room at 5:30am (ie as soon as the sun is up in summer).

There are, obviously, many sensible solutions to these problems that don’t involve Banggood orders, soldering, individually addressable LEDs, and Home Assistant; but where’s the fun in that?

Ordered some WS2812b LED strips (as well as some LED mountings) off Banggood, and used a D1 mini running Esphome as a controller. Stuck it all in a switch box with a dimmer switch acting as a physical push button.

(Apologies in advance for potato quality photos, turns out it’s difficult to photograph LEDs with a phone).
Can act as a normal light (single press of the switch):

Or a night light (kinda light yellow, just barely lit; either via a HA automation at 6:30pm, or a double press of the switch):

Then (and this is the bit I like most), at 6:30am a HA automation turns the lights green. Then the kids know it’s time to get up and they can come through. Surprisingly, this has had a >80% success rate so far :slight_smile:

As a bonus, if you triple-press the switch, you get a dance party :sunglasses: :
(if embedded gif doesn’t work: https://photos.app.goo.gl/NHGN1gvnpcn6Goku5)

The lights are completely controllable through HA (used the RGB card here, which makes it easier):
image

Very pleased with how it turned out though the next project, the lights in our guest room, will have some changes:

  • More hidden cabling
  • Different switches (though I haven’t solved this yet, toggle switches seem really difficult to find, and 3x the price of a normal one…)
4 Likes

Nicely done, I like this idea…

1 Like

Very cool project. I do love the green light idee.

It might be to late for my kids. Although the teens might enjoy the dance party mode. But who would know? Risk it to great to try :smiley:

1 Like

It’s funny I see this now again. My 10 year old just asked me yesterday for the same thing in his room. I’ve been itching to play with these so he didn’t need a lot of time to convince me lol.

Did you do your own sketch in ESPHome or did you download something?

1 Like

Pretty much wrote it myself, I like the yaml in Esphome, it mostly makes sense to me.

I need to look into moving some of the code into modules or something, to reduce the duplication across the 2 lights.

I made a whole bunch of logical switches, which just make it easier to centralise logic, and call it from the RGB card in HA.

esphome:
  name: kids_lights
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !wifi
  password: !wifi_pwd
  manual_ip:
    static_ip: 192.168.1.235
    gateway: 192.168.1.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kids Lights Fallback Hotspot"
    password: "6oe8KZTSKyDR"

captive_portal:

# Enable logging
logger:
web_server:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: wifi_signal
    name: "Kids Lights WiFi Signal"
    update_interval: 60s
  - platform: uptime
    name: "Kids Lights Uptime"

switch:
  - platform: template
    name: "Normal Light"
    id: switch_normal_light
    turn_on_action:
      - light.turn_on:
          id: boy_light_strip
          brightness: 80%
          red: 100%
          green: 100%
          blue: 100%
          effect: None
      - light.turn_on:
          id: girl_light_strip
          brightness: 80%
          red: 100%
          green: 100%
          blue: 100%
          effect: None
      - switch.turn_off: switch_normal_light
  - platform: template
    name: "Off"
    id: switch_off_light
    turn_on_action:
      - light.turn_off:
          id: boy_light_strip
      - light.turn_off:
          id: girl_light_strip
      - switch.turn_off: switch_off_light
  - platform: template
    name: "Night Light"
    id: switch_night_light
    turn_on_action:
      - light.turn_on:
          id: boy_light_strip
          brightness: 12%
          red: 100%
          green: 100%
          blue: 0%
          effect: Half
      - light.turn_on:
          id: girl_light_strip
          brightness: 12%
          red: 100%
          green: 100%
          blue: 0%
          effect: Half
      - switch.turn_off: switch_night_light
  - platform: template
    name: "Morning Light"
    id: switch_morning_light
    turn_on_action:
      - light.turn_on:
          id: boy_light_strip
          brightness: 15%
          red: 0%
          green: 100%
          blue: 0%
          effect: None  
      - light.turn_on:
          id: girl_light_strip
          brightness: 15%
          red: 0%
          green: 100%
          blue: 0%
          effect: None  
      - switch.turn_off: switch_morning_light
      
  - platform: template
    name: "Dance Light"
    id: switch_dance_light
    turn_on_action:
      - light.turn_on:
          id: boy_light_strip
          brightness: 100%
          effect: "color wipe"
      - light.turn_on:
          id: girl_light_strip
          brightness: 100%
          effect: "color wipe"
      - switch.turn_off: switch_dance_light
  - platform: template
    name: "Rainbow Light"
    id: switch_rainbow_light
    turn_on_action:
      - light.turn_on:
          id: boy_light_strip
          brightness: 60%
          red: 100%
          green: 100%
          blue: 100%
          effect: Rainbow
      - light.turn_on:
          id: girl_light_strip
          brightness: 60%
          red: 100%
          green: 100%
          blue: 100%
          effect: Rainbow
      - switch.turn_off: switch_rainbow_light

light:
  - platform: neopixelbus
    method: ESP8266_UART1
    pin: 2
    num_leds: 23
    name: "boy Light Strip"
    id: boy_light_strip
    effects:
      - addressable_rainbow:
      - addressable_color_wipe:
          name: "Color wipe"
      - addressable_scan:
      - addressable_twinkle:
      - addressable_lambda:
          name: "Half"
          update_interval: 100ms
          lambda: |-
            for (int i = 0; i < it.size(); i++) {
              if(i % 2 == 0)
                it[i] = ESPColor::BLACK;
              else
                it[i] = current_color;
            }
            
  - platform: neopixelbus
    pin: 3
    num_leds: 23
    name: "girl Light Strip"
    id: girl_light_strip
    effects:
      - addressable_rainbow:
      - addressable_color_wipe:
          name: "Color wipe"
      - addressable_scan:
      - addressable_twinkle:
      - addressable_lambda:
          name: "Half"
          update_interval: 100ms
          lambda: |-
            for (int i = 0; i < it.size(); i++) {
              if(i % 2 == 0)
                it[i] = ESPColor::BLACK;
              else
                it[i] = current_color;
            }
    
binary_sensor:
- platform: gpio
  pin:
    number: D3
    #mode: INPUT_PULLUP
    inverted: yes
  id: scroll_btn
  internal: true
  filters:
    - delayed_on: 20ms
  on_multi_click:
    - timing:
        - ON for at most 500ms
        - OFF for at least 500ms
      then:
        - logger.log: "Single-Clicked"
        - if:
            condition:
              light.is_on: boy_light_strip
            then:
              - logger.log: "Light on, turning off"
              - light.toggle: boy_light_strip
              - light.toggle: girl_light_strip
        - if:
            condition:
              light.is_off: boy_light_strip
            then:
              - logger.log: "Single-Clicked"
              - switch.turn_on:
                  id: switch_normal_light
    - timing:
        - ON for at most 500ms
        - OFF for at most 500ms
        - ON for at most 500ms
        - OFF for at least 500ms
      then:
        - logger.log: "Double-Clicked - reducing brightness"
        - switch.turn_on:
            id: switch_night_light
    - timing:
        - ON for at most 500ms
        - OFF for at most 500ms
        - ON for at most 500ms
        - OFF for at most 500ms
        - ON for at most 500ms
        - OFF for at least 500ms
      then:
        - logger.log: "Triple-Clicked - effect"
        - switch.turn_on:
            id: switch_dance_light

1 Like

Real men code in Assembler :smiley:

But thank you very much for that, I’ll give it a look see when my strips arrive

Awesome stuff, I really love it.

Need to start playing with some LED strips as well. Links to the stuff you bought?

Running off a D1 Mini, which you can pick up from anywhere.

I essentially bought the cheapest WS2812B 5m strip I could find on Banggood. Seems to change almost daily, but this is what I got (the 30 LEDs/m version). https://www.banggood.com/1-or-2-or-3-or-5M-WS2812B-Strip-Light-5050-RGB-1m-5m-30-or-60-LED-IC-Individual-Addressable-p-1751284.html?rmmds=myorder&cur_warehouse=CN&ID=457636296613

Mounting: https://www.banggood.com/1X-5X-10X-LUSTREON-50CM-Aluminum-Channel-Holder-For-LED-Strip-Light-Bar-Under-Cabinet-Lamp-p-1199458.html?rmmds=myorder&cur_warehouse=CN&ID=511073514617

Then it’s all housed inside a normal light-switch box, from Builders, because I have not yet convinced myself I need a 3D printer :slight_smile:

Haha, can’t you convince me that I need a 3D printer too?

Thanks, good stuff. I will show the significant other and I’m sure we might end up a with a couple of LED strips around the house.

Every year on Black Friday, DIY Electronics (whom I follow on social media) has a special on a 3d printer. Every year I paste the model name into pricecheck/google… and I’m so disgusted at the dishonesty of the alleged 50% off claim that I don’t pull the trigger.

This year the price was actually quite good (not 50% off… more like 10%), but it was sold out by the time I got there.

So yes… I too have not yet convinced myself that I need it that badly.

Edit: A bit of a rant really. If you say that the normal price is R8k, and now it is R4k, and I google it and find out that those sharks at ImportItAll sells it at 6.5k… I’m going to feel like you’re being dishonest. Sorry, I know 4k is a good price, but it’s psychological, okay?

Edit 2 + rant 2: Reminds me of coffee machine shopping (bean to cup). Special… only 10.5k today, normally 15k! I research it… Yuppichef sells it at 14.5k. Now Yuppichef is the benchmark of the max price you should ever pay… so that 15k was a lie. Then I found out later that OneDayOnly is only really a marketplace. The specials they have every day… they just ship it really. Someone else makes up the deals…

A special is only really a special if you know your prices.
I do like shopping a t Raru. When you have something in your wishlist and there is a special on they give your the discount from since you added it to the wishlist. That is nice.
Example:

2 Likes

Yeah, who needs a 3D printer when you have old hummus containers? :see_no_evil:

3 Likes

Soapboxes! Everybody knows you do DIY projects in soapboxes!

:stuck_out_tongue:

This is cool, didn’t know they do this.

I also used to check dealsdealsdeals.co.za quite a bit since they track prices for you. But then Takealot blocked them a couple of years ago (I wonder why…) and of course now it is a little bit less useful.

End of last year / beginning of this year, when the loadshedding hit quite bad, these guys on Takealot took the “Was x ZAR, now y ZAR!” to the extreme: https://mybroadband.co.za/forum/threads/router-battery-backup.993476/post-24575672

Takealot honestly do not care!

Takealot prices are NOT cheap anymore. Time and time again I compare a TAL price and inevitable I find it cheaper elsewhere. Now and then you get a bargain there, not like before when it was bargains galore.

BUT … that is how they roll. Start off very cheap and slowly increase the prices …

When I bought my printer a few weeks back, I found 3drone to be the cheapest of the lot. And they were just down the road from me, so I could go check it out before paying. Maybe have a look there?

Anyway, Led strips arrived to day. I took the easy route and just loaded WLED on a D1 Mini and was up and running in minutes. Awesome effect it has, and it’s integrated with HA. Now I just need to go mount them, my kid is driving me mad getting it done :slight_smile:

1 Like

DIY Electronics also have some proper specials from time to the , I think they had a Creallity for about R4k the other day.

Isn’t takealot also just like a marketplace? But yeah, I don’t even look at their “deals” anymore. I decided that when I really need something, I’ll do some research and then get it. Otherwise I convince myself I need something I don’t…

1 Like

That was the one I referred to above. It was a Creality ld-002r. They advertised it as “normally 8k, now 4k”. So I looked it up. The model they were selling was going for 6.5k at ImportItAll, 3dstore has it for 6k, and I think a few places had a mid-5k price. So 4k was still an excellent price… but I really hated the inflated discount number… and it was sold out by the time I got there.