Control Home Lighting with the Parse Webhook


Posted on

Our Parse webhook lets your application receive inbound email. The common use cases for this tend to be web app related. It’s awesome for creating applications like a support ticketing system or receiving data for a social or content management site. In this post, I’ll share how well it also works to control web-enabled hardware.

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.

Control My Lights

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

Philips hue

How It Works

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.


Meet Kunal, Developer Evangelist at-large for SendGrid and home-grown New Jersey hacker. He previously ran General Machines, which developed Deaftel - a phone service for the deaf that converts voice to text and text back into voice over a phone call. Since March 2013, Kunal has been working as a Developer Evangelist at SendGrid, helping enable developers to get the tools and resources they need to make awesome, creative stuff.

Kunal Batra on Twitter
Have thoughts on this post?
Chat with us about it on Twitter and Google+