Using an Amazon Dash button to control Philips Hue lights

It’s been about 3.5 years since I wrote a post – better late than never ūüėÄ

All of my old content was in some way inspired by customers that I was supporting as an admin for Rackspace Cloud. This one is different and just something geeky and fun.

The Dash button is a nifty little piece of technology that Amazon put out last year. A lot of people thought it was an April Fools joke when announced, but it was no joke and is meant to let Amazon customers purchase consumables at the push of a button anywhere in their house. I received one when my son was born in February that would let me purchase Huggies Diapers.


I thought instead of buying diapers with it, I could probably figure out a way to hijack the URL that it was calling to make the purchase and instead have it call my Philips Hue hub. It turns out, it’s actually even easier than that. See, Amazon was so deliberate about preserving battery life that they built these little guys to be completely turned off and when the button is pressed it connects to your router to get an IP address before making the call to Amazon for the purchase. A few seconds later, it turns off and the IP is released.

This is important because after the Dash button is issued an IP, it sends an ARP probe broadcast out to the rest of the network. The image below explains an ARP Probe.

arpProbe-DashButtonSo all we need to do is have some other device on the network constantly waiting to see the ARP probe, and when it does, have it kick off a script to interact with the lights. This can be some other computer in the house. For me, I used a RaspberryPi.

Getting Started – Setting up the Dash Button

The first thing you need to do is connect the dash button to your wireless network. The dash button uses the speaker on your phone to send a magically encrypted sound to the dash button, which it interprets as the wifi settings to be able to connect to your network. Can we just take a moment to appreciate how freakin’ cool that is?

Following the below steps will connect the dash button to your network, but not actually configure it to buy a product. Otherwise, you will have a box of diapers (or ziploc bags, or razor refills) showing up on your doorstep every time you turn on the lights. Not cool.

  1. Use your phone to Download the Amazon app
  2. In the Amazon App, login to your Amazon account
  3. In the app, go to “Your Account -> Dash Devices -> Set up a new device
  4. Go through the steps to enter your wifi credentials and connect the dash button. But..
  5. Do NOT actually pick a product that you want the dash button to buy. After it is connected to your network and you are on the “Choose a Product” page, just close the app, never actually completing setup.

Collecting all of the information

To make this work, you will need to know the following

  1. IP address of your Hue Bridge
  2. A valid user for the bridge
  3. The ID number of the light(s) you want to control
  4. The MAC address of the Dash button

IP address of your Hue Bridge

If you have never before tinkered with the API for your Philips Hue system, then you have probably never setup a new user. No worries, we will make it pretty easy. First, you need to find the IP of your bridge. Philips makes this pretty painless in most cases. Just go to while on your network and it will look for the bridge. Tada!

Note: If that didn’t work, you can use the official Hue app:¬†Go to the settings menu in the app. Go to My Bridge. Go to Network settings. Switch off the DHCP toggle. The ip address of the bridge will show. Note the ip address, then switch DHCP back on.

A valid user for the bridge

Now to register a new user. Craft a POST to http://<IP-of-Your-Bridge>/api with the payload ‘{“devicetype”:”my_dash_button_user”}’. The following cURL command should do the trick. Note: You MUST push the button on your bridge FIRST and run the following command while the light is flashing. Otherwise, you will get a response that says “link button not pressed”

In the response, you are looking for the randomly generated username. It is 32 characters long and will be between quotation marks. Copy that and save it somewhere.

The ID number of the light(s) you want to control

Now that we have the IP of the bridge and a valid user, we need to figure out what the ID number is for the light we will be controlling. The script below can be ran to list all of your Hue bulbs and their ID.

Edit it to include the correct variables for your bridge IP and user, save it as, and run it!

The MAC address of the Dash Button

Now we need to capture the MAC address of the Dash button. The easiest way to do this is with scapy. Scapy is a packet manipulation library for Python. I installed it via pip:

With it installed, you can use a simple script to find the MAC address. I created a file called

Paste this into a text document, and run it from terminal.

While the script is running, press your dash button. Within 1-5 seconds, you should see a MAC address show up. Press ctrl+c to stop the tool. Copy the MAC address and save it somewhere.

You’ve come a long way – now we just need to put it all together

You can edit the script below to toggle a single light on/off using your dash button

Copy/Paste the script, modify the variables at the top and then save it as Make the file executable and then run it!

With the script running, push the Dash button. With any luck, you will get a few blinks on the dash button and in about 3 seconds your hue light will turn on. Push it again and the light will turn off!

Three Second Delay?!? What the heck!

Yes, this isn’t a light switch. Think about everything that has to happen:

  1. Your Dash button needs to power on
  2. Dash connects to your wireless network and requests an IP address
  3. IP is assigned to Dash
  4. Dash sends a probe out to the rest of the network
  5. Your RaspberryPi (or other computer) sees the probe
  6. Your RaspberryPi calls to your hue bridge to get the current status of the light
  7. Your RaspberryPi calls to your hue bridge to request the light turn off/on

So yeah, it takes 3 seconds. Deal with it. :-p

Making it Persist

The script above is a neat party trick, but if you actually intend to use the dash button regularly to turn on/off your lights, you need to make sure that the python script is always running, that multiple copies of the script aren’t running simultaneously, and that it starts on boot automatically in case your Pi loses power. This is where an init script comes in handy. Below is a modified script from¬†

Create this script as /etc/init.d/dash-lights and edit lines 14-16 and line 20 based on where your files are stored, then change the permissions so it is executable:

Next, make sure that it starts on boot:

You can now start/stop this service just like you would any other daemon:

Extending the toggle script

The script above can get you started, but you may want to extend it to control multiple lights with the push of a button, or maybe have multiple dash buttons around the house for different lights. Here is an example of my script. I have one dash button that controls two lamps in the living room, and a different dash button that controls the light in the nursery.



Here were some of the resources that helped along the way

Creating an init script for a python script

Using scapy to catch ARP probes from a dash button:

Philips Hue API Docs:

I put all the scripts I referenced above in github at

  1. Awesome! Thanks this gave me a few ideas for my projects on my rv. May work for my security, lighting (though it’s 12V) and couple other things I want to control. Really appreciate the post! Kerdog

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">