Specifically, I’ll be using inbound email to control home lighting with the
Philips Hue light bulbs.
For the next few days, anyone can control the lights in my apartment and I’ve set up a livestream (embedded above) to show the current status. There is a 20-30 second delay in the stream, but you'll get an idea for how it works.
Update: When I first wrote this post, I let people control the lights in my apartment and view a livestream. For obvious reasons, I can't continue this in perpetuity. You can see an example in the video embedded above and continue along to see how it worked and get the code to try it yourself.
Send an email to: change@lights.bymail.in
The
subject can be any of the options below:
- on
- off
- an integer between 0 and 65535
A subject of
0 will change the lights to red. Here are the other settings:
- 12750 = Yellow
- 25500 = Green
- 46920 = Blue
- 56100 = Pink
- 65280 = Red
The Philips bulbs come with a bridge that communicates with the bulbs over a protocol called ZigBee Light Link. We just need to create an application on our local network which can make PUT requests to the bridge.
I decided to use MeteorJS, a real-time JavaScript framework. You can find an my earlier
introduction to receiving email with Meteor.
Here’s an example call from Meteor to the Philips bridge:
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/1/state', {data: {"on": true}})
That line of code will turn on the light bulb. We can change that payload to change colors, turn off the bulb, or schedule lighting as well. Philips has
full documentation on its developer site.
To connect to inbound emails, I am
running ngrok on my local machine to open up my Meteor application to the internet and use the URL the service provides as the route SendGrid will post email data.
Thanks to a web-enabled light bulb, the Inbound Parse Webhook and some Internet plumbing, anyone can control my lights. And if you check out the
source code on GitHub, you can control your own lights this way, too.
For more details on the feature behind this tool, download the Parse Webhook Guide for free now.