Using Amazon Dash Buttons to Control HomeKit

I mainly control my smart lights using Alexa or my phone, but still like the tactile nature of a switch, especially after reading in bed. I don’t want to wake my girlfriend up by asking Alexa or look at my phone’s bright screen.

UPDATE: After writing this guide Amazon has sadly discontinued their range of Dash Button, which includes the ability to add new Dash Buttons to your network. This means this guide currently only works for Dash Buttons already connected. If I find a workaround for new buttons I will update this guide!

I have Hue Dimmer switches next to each light switch, but this still doesn’t work for when I’m sat in bed. I looked at the native HomeKit switches, but these were fairly expensive. Then I remembered that Amazon Dash buttons exist, £4.99 for a Wi-Fi button, good for around 30,000 pushes!

After researching, I found several Homebridge plugins dedicated to Amazon Dash integration. Before being able to add these devices to Homebridge, you first need to find their MAC Address.

Finding the Dash Buttons MAC Address

Before finding the MAC Address you’ll need to connect them to your Wi-Fi. This is extremely straightforward and involves using Amazon’s official setup method.

Using your phone, download the Amazon app, sign in and navigate to the ‘Your Account’ section. On this list is the option ‘Set up a new device’, start this and follow the instructions. When it comes to selecting a product to add, close the app. This will leave the button connected to your network without actually buying anything!

Something I found quite annoying is each time I press the button I go an email and notification telling me to finish the setup. After disabling the notification and creating an email rule it hasn’t been an issue.

If you already had your Dash buttons setup to buy things, disconnect it from your account using the app, then hold the button for 6 seconds, this resets it.

Now that you’ve setup the Dash button to your network you can find the MAC Address! For this, you’ll need the node-dash-button application. This application has a prerequisite, so to install type the below commands:

sudo apt-get install libpcap-dev
sudo npm install node-dash-button

Now that you’ve installed the node-dash-button plugin you can use it to find any Dash buttons on your network! To run the application type the below commands, do note that you have to use sudo to run the application:

cd node_modules/node-dash-button
sudo node bin/findbutton

Once this is running press the button on your Dash button, the application will then tell you possible hardware has been detected. Make sure that it’s the Dash button being detected by pressing it a few times. You can also look up the MAC Address using a lookup site like macvendors.com

Once you’ve got your MAC Address, exit the application using Ctrl+C. Now you can use this MAC Address in Homebridge, there are two plugins for this. One adds them as a stateless switch, and the other as a standard switch. The setup for both is almost identical. The only issue is that both plugins require Homebridge to be started with sudo/root. This is to give Homebridge elevated privileges.

Homebridge Setup

Whilst installing the plugin itself is easy, making it run as sudo/root on startup is slightly harder. I’ll first go through the Homebridge setup then the steps for running on startup.

For the purpose of this, I wanted to add functionality to my bedside tables. For this, a standard switch would be better. I’ll be using the homebridge-dash plugin, to install type the below command:

sudo npm install -g homebridge-dash

Once installed you can then configure the plugin. The syntax for this plugin is simple, below I’ve added my config for the above Dash button:

Once you’ve added this to your Homebridge config.json make sure to put it through a parser, as there are always a few syntax errors! Once done you can then type the below command to start Homebridge with elevated privileges:

sudo homebridge

The Dash button will now appear and work perfectly in HomeKit! Do note that there is a slight delay between pressing the button and the action happening. This is just because of the way the Dash button communicates.

One thing I did find is that the automation I built didn’t work well for trying to turn a light off if the switch is already in the ‘off’ state. This meant pressing the button twice. I solved this using several automation rules.

At some point I’ll create a guide to advanced HomeKit automation!

Starting Homebridge at Boot as Root

For starting Homebridge at boot I use the systemctl method. If you haven’t already set this up check out my Homebridge Setup Guide where I explain the steps required.

Once you’ve got that setup you’ll need to edit and move a few files. First, you’ll need to enable the root user, to do this type the below command:

sudo nano /etc/ssh/sshd_config

In this file, find the line #PermitRootLogin without-password. Remove the # and change without-password to yes. Save and exit the file and then reboot. After rebooting set a root password using the below command:

sudo passwd root

Now that you’ve enabled root you can adjust the two files that systemctl uses. Type the below command to open the first:

sudo nano /etc/default/homebridge

In this file, you’ll want to change the location of the Homebridge config.json file. Update your file so it looks like the below:

# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pai$
HOMEBRIDGE_OPTS=-U /root/.homebridge
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*

Open the other systemctl file, to do this type the below command:

sudo nano /etc/systemd/system/homebridge.service

In this file, you’ll want to change the user to root. Update your file so it looks like the below:

After updating both these files you’ll need to reload systemctl, to do this type the below command:

sudo systemctl daemon-reload

Before starting Homebridge, you need to move the config file to this new location. To do this I used WinSCP as it gives full file access as root. You can also do this by copying and pasting from one directory to the other but will need to log in as root to access both locations.

After this you can now start up Homebridge using the below command:

sudo systemctl start homebridge

Overall I’m extremely happy with my Dash buttons, I’ve used two for my bedside tables, and one for the hallway light. I’m planning to use one as a doorbell, so will post about that after I’ve done it! If you have any questions about this project, drop a comment below and I’d be more than happy to answer them!

I don’t run ads on my site, nor do I do this for profit, but if you found this post helpful and want to support me why not buy me a coffee!

7 Comments

Hi Sam. I don’t know if you’re looking back at this post. I followed your advice a few months ago and got my Pi working with Homebridge and my Dash Buttons. I’m starting from scratch with HOOBS and now can’t get it to work! I now get enoent errors when trying to install the Dash plugin.

Hey Cam, I’ve not used HOOBS but the ‘enoent error’ suggests that a directory is missing from where the plugin thinks it should be. I don’t know how it works with HOOBS but I’d recommend re-installing NPM/Homebridge, which should fix the issue.

Hey Tony, I’ve been looking and currently don’t think there is a way to connect these to your WiFi network after Amazon Discontinued them 🙁 I’m hoping that someone will create a hack and will update the article when I find a solution!

Looks like I was able to set mine by just holding the button and connecting it to my new network. I did need to use Wireshark to find the ARP packet with the MAC, but it did work. Now I’m working on getting the plugin added into HOOBS/homebridge

Ahh awesome, did you connect it to your network by connecting to the Dash’s WiFi point first? As saw a couple of people mention connecting it like that, but that it then lost connection after a short while. Do let me know if it stays connected 🙂

The device only stays connected for a few seconds after it connects to the network. I’m still working on getting the home bridge plugin to work so I can’t yet confirm that portion. But ordinarily, you would press the button. It would “boot”, connect, send packets, and then turn off.