Internet-enabled children's nightlight
Powered by Node.JS and a variety of types of internet-controllable lights, such as:
Why Does This Exist?
I wanted my kids to have a nightlight in their room that:
- Had programmable color & brightness
- Had an adjustable timer (turns off X minutes after being turned on)
- Had an interface to show history of button pushes (so I can see when they were awake)
- Schedule the light to change color on a schedule (so at 7am it turns to blue to indicate "Ok, it's morning time!"). This is great for sleep training!
Other Great Uses
- Our kitchen lightstrips now turn on at 9pm, and off at 7am, to provide a great evening ambience.
|Demo of button turning light on|
|Demo of button turning light off|
What Does This Do?
There is a Node.js web server that runs on the network, connects to the Philips Hue bridge, and listens on the network for some button to get pushed.
Each button gets associated with a light on the network. If the button is pushed and the light is off - the light is turned on (and a timer is started to automatically turn the light off after X minutes). If the button is pushed and the light is on - the light is turned off.
There is also a web application that sets the default color and colors during specific time periods. The web interface - in addition to showing times of button pushes - permits turning the light on with & without the timer, and turning the light off.
Getting The App Running
For the most part, it is a straight-forward Node.js application. After downloading this repo and extracting it to a directory of your choice, run:
You can now access http://localhost:3000/ and view the complete interface. (On my home network, I put this on a Rapsberry Pi and set the in-house DNS to know it as "nightlight". So now babysitters and family just go to http://nightlight/ to use it.)
There are some variables that much be defined in the environment before starting the application.
For your convenience, you can also stored these in a
|SITE_NAME||Shown in page header and logged with Hue bridge||Nightlight System|
|NODE_ENV||Determines if application should cache & catch uncaught errors (if set to production), or exit||blank|
|PORT||Port app listens on||3000|
|SESSION_SECRET||How cookie data is encrypted||secret|
Keeping The App Running
You'll find plenty of other great tutorials on the web about running a Node.js app as a daemon, but here are a couple:
|Desktop interface for monitor and control|
|Mobile interface for monitor and control|
- Original blog about hacking the Dash button
- jscolor Color Picker - Makes selecting colors really easy
- Bootswatch - Great source for Bootstrap themes
- jQuery Timepicker - Fast way to add time handling to the interface
- node-dash-button - Fantastic module to find Node button on the network, and bind it to events. No longer used, but inspiring.
- node-hue-api - Wonderful module to find and control Philips Hue bridges and bulbs
- FastLED + ESP8266 Web Server - Saved me a ton of time programming a non-Hue LED circuit