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: firstname.lastname@example.org
The subject can be any of the options below:
- 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
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.
Here’s an example call from Meteor to the Philips bridge:
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.