Saturday, January 20, 2018

AWS IoT Button and Philips Hue API...

I bought some Philips Hue Lights, and have really enjoyed them - but I enjoy them even more now that I have the IoT button integrated with the lights. 

Here is a video showing my AWS IoT button interacting with my Philips Hue Go lamp.

Philips Hue API:

The Philips Hue REST API is really easy to use to retrieve information about the lights connected to the Hue bridge, and for controlling the lights. You can follow the instructions on this page to help you get up and running with the API.

AWS IoT Button:

I had seen the AWS IoT button on Amazon and, although I didn't have any ideas of what I would do with the button, I wanted to work on a project which would use one of the buttons. I found this fun project that also uses an AWS IoT button, and the Philips Hue API with the Go lamp. I had bought a Philips Hue Go light, as well as a number of other Philips Hue lights, so I decided to recreate the project from the youtube video above but using an AWS lambda instead of using a raspberry pi

Something that was pointed out to me (embarrassingly) is that this method is not secure. Sending unencrypted information to the Hue bridge, which includes the auth, would allow an attacker to send their own API calls to the bridge. One of the API calls could have a security hole that could be used by an attacker / curious person. 

A couple of ideas I've had for using the Philips Hue lights are flash lights with certain colors to indicate either a rise above, or drop below, stock or crypto currency price points, and flash lights when people are close to home (integrate with IFTTT).

However, using the IoT button to control the lights looked fun and gave me an excuse to learn a little bit about AWS Lambdas. It's worth mentioning that Philips makes a switch that can be easily programmed to control your Philips Hue lights.

Parts list :

- Philips Hue Go light, but it works with all of the Philips Hue color lights
- AWS IoT Button

Set up IoT Button:

I used the "Getting Started" guide to set up the IoT button.  It walks you through registering your device, creating and activating a device certificate, creating and attaching an IoT policy to the device certificate, attach the certificate to a "Thing" (the button), and configuring your IoT button to know how to connect to your WiFi.

One of the last steps in the "Getting Started" guide is configuring and testing rules. The example has the IoT button pushes send an SNS message that gets sent as a text message to your phone. I decided to have the SNS message trigger a lambda, and use the lambda to send the REST calls to my Philips Hue bridge.

AWS Lambda:

Here is the AWS Lambda code that I used:

I have my router configured to use Dynamic DNS, and then I have a port forwarding rule to forward to the Philips Hue bridge.  The lambda figures out if the button click was a single click, a double click, or a long click.  The double clicks will turn the light on and off, the single click will increment the hue to set the light to, and a long click will set the light to use the color loop effect.

I hope you find this post useful! Please leave links to any projects you feel like sharing using AWS IoT buttons and/or Philips Hue lights in the comment section below.


  1. Wouldn't anyone sniffing traffic see your inbound http request which includes the auth id and target IP? If so, they could start sending any api to the Bridge and even exploit security holes in the Bridge (if any). I love the idea, just protective of my LAN. Thoughts?

    1. I think you have a great point, and it makes sense to always have security in mind.

      I linked a video above that is more or less doing this: the IoT lambda publishes an SQS message. A service running on the LAN polls for IoT messages. The messages are transformed into the desired API call and forwarded on to the bridge.

      I liked the idea, and it is definitely more secure than what I posted. Other than it not being secure (I know, I know ;) ), I liked my approach because the only code is in one lambda.

      There is a pretty good thread on about the bridge API still not supporting HTTPS:

      Thank you for the comment, and the very good point!

  2. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information.
    filter paper

  3. Connect devices with IoT platform is necessary for transmit data from one device to another. We have the best wireless senors which connects with IoT platform. Our IoT products help you to track temperature measurements in multiple environment conditions. Keep it up!

  4. Nice post. However, I'd suggest creating an app at and use oauth token (documentation at With that, you can use remote API and won't need to expose your bridge to the internet with DDNS and port-forwarding.

    1. That's a good suggestion for people that want to write a Hue app! I wasn't specifically wanting to write a Hue app as much as I wanted to do anything that could interact with the IoT button (and I had bought some Philips Hue lights), but your suggestion sounds fun - I'll look into it.