[OBSOLETE] Amazon Dash Button

Figured with the anniversary of the Amazon Dash button, it would be a fun project to get a bunch hooked up to SmartThings. This SmartApp allows you to connect Dash buttons to devices in SmartThings and turn these devices/routines on/off at the press of a button.

Provides integration of the Amazon Dash Button with the the following features:

  • Ability to connect multiple buttons
  • Ability to turn devices/routines ON/OFF
  • Ability to receive push/test notifications when a button is triggered

And the following requirements / dependencies:

** Update 03/12/2021 **

  • The short story is that this integration is NO LONGER BEING MAINTAINED; please feel free to clone the repo and carry it forward!
  • The long story is that ever since ST rolled out the new app and basically broke support for tons of integrations (including this one), I waited, waited and tried many times to find a good enough solution for all of us to enjoy. Unfortunately that never came and I decided earlier this year to explore other home automation options… and I found one that fits the bill perfectly… Home Assistant. The system is stable, flexible and growing in the way all of us had hoped ST would. The great news about Home Assistant is that there are tons of integrations available, including support for this one: GitHub - danimtb/dasshio: Hass.io add-on to easily use Amazon Dash Buttons with Home Assistant. For those of you who are worried about your Z-Wave/Zigbee devices, what I have done is continue to use the ST Hub as the Z-Wave/Zigbee bridge and use the Home Assistant - SmartThings integration to control everything. I can’t tell you how happy I have been with the Home Assistant platform, capabilities, community, everything… it’s pretty amazing. If you’re like me and frustrated with the current status of ST, give it a look… you won’t be disappointed. It’s been a lot of fun!

Update 12/12/2017
How to Block Orders
If you’ve got a Surprise Sweets button that you want to use without placing an order or are getting the “choose a product for your… Dash Button” message every time you press your button, and you want to stop this… then this is for you. In a nutshell, you’ve got to block the request made to Amazon when the button is pressed, and listed below are a couple options:

  1. DNS Filter: In your firewall/router/etc place a new DNS rule that assigns dash-button-na.amazon.com to 127.0.0.1 (or other bogus address). When the button is pressed it sends the order request to dash-button-na.amazon.com, which we are now effectively blocking. When you want to add a new button, you’ve got to temporarily remove this rule so that the new button setup can complete.
  2. MAC Filter: In your firewall/router/etc place a MAC address filter that will block all outbound/internet access for that device, effectively preventing the specified Dash Button from sending any requests outside your network. You’ve got to put in one MAC address filter for each button.

Update 04/19/2017
Posted installation video at: SmartThings Node Proxy + Amazon Dash Button - YouTube

Installation

Since the Dash Button communicates with SmartThings via SmartThings Node Proxy (STNP), make sure that you have the proxy and the Dash plugin installed and working before adding the SmartApp to SmartThings.

  1. SmartThings Node Proxy + Dash plugin installed and configured on a machine
  2. Setup and discover Dash Buttons; register button MAC address with SmartThings Node Proxy
  3. Create a new SmartApp and use this code: smartthings/dash-button.groovy at master · redloro/smartthings · GitHub
  4. Add the Dash Button SmartApp from the SmartThings marketplace
  5. Configure the SmartApp
  • SmartThings Hub: REQUIRED
  • SmartThings Node Proxy: REQUIRED to connect to the SmarThings Node Proxy
  • Notifications: OPTIONAL
  • Buttons: OPTIONAL register Dash Button MAC address and Device Switch to control
  1. Done! Note that there is a slight delay between pressing the Dash Button and the activity taking place.

Enjoy…

FAQ
Going to cover a couple questions here to hopefully aid others in their quest to get this setup.

  • Do you have an installation video?
    Here you go… SmartThings Node Proxy + Amazon Dash Button - YouTube

  • What the heck is Node?
    Node is awesome! https://nodejs.org

  • What the heck is JSON?
    JSON… pronounced like the name Jason (JAY-sun) is also awesome… http://www.json.org/

  • Why do I need SmartThings Node Proxy?
    If you want to connect a Dash Button to SmartThings you need STNP. It listens to network activity, “catches” messages from the Dash Button and then notifies SmartThings. All traffic stays on your local LAN and communication between your Dash Button and the Hub happen in near-realtime.

  • What do I need to do to get this running?

  1. Forget about SmartThings for a second… we’ll come back to that.
  2. First things first, let’s get SmartThings Node Proxy installed, configured and working.
  3. Identify a host machine on your network that can run NodeJS
  4. Download and install NodeJS from here: https://nodejs.org
  5. Download SmartThings Node Proxy and place in a target folder on your machine (ie. /home/smartthings-nodeproxy)
  6. Create a subfolder called plugins (ie. /smartthings-nodeproxy/plugins)
  7. Move dash.js from avail_plugins to your new plugins folder
  8. Copy the contents of config.json.sample and paste them here: http://jsonmate.com/
  9. Edit the document so that it matches your configuration… remove all comments (anthing starting with //) and then click “Beautify”.
  10. Create a new file named config.json in your SmartThings Node Proxy folder
  11. Copy the contents of the json document into config.json and force network discovery by removing the “dash” key; it should look something like this:
{
  "port": 8080,
  "authCode": "secret-key"
}
  1. Install pcap, which varies depending on your OS… for the RPi run the following: sudo apt-get install libpcap-dev
  2. Install dependencies by running: npm run install:dash
  3. Fire up the server by typing: sudo node server.js
  4. It should go into network discovery mode; press your Dash Button and record the address that is displayed (ie. aa:bb:cc:dd:ee:f1)
  5. Edit your config.json and add the “dash” key back; it should look something like this:
{
  "port": 8080,
  "authCode": "secret-key",
  "dash": {
    "buttons": ["aa:bb:cc:dd:ee:f1"]
  }
}
  1. Now we can move on to setting up the SmartApp in SmartThings…
  • How do I know it’s running?
    When you start SmartThings Node Proxy you should see something like the following:
$ sudo node server.js
SmartThings Node Proxy listening at http://:::8080
Loaded plugin: dash
9 Likes

Cannot wait to try this!!

I’ve installed and love it! Works amazing. Only question: how do you deal with all these amazon app alerts? Is there a way to deactivate a button without it losing its wifi setup?

Fix: Amazon app settings allows you to modify dash notifications
Caveat: Turns off notifications for real use dash buttons (when a purchase is made)

Awesome… I’ve turned off all Amazon app notifications so didn’t even realize that was an issue. Thanks!

1 Like

Very cool. Are you using the IoT developer kit button? I may try to use one of these as a garage door opener that runs a routine (door, lock, lights, etc.) I’m hopeful that the Dash finds Wifi faster than all the zigbee/z-wave buttons find ST on arrival.

Thanks for the good work.

Nope… I just got all the buttons I could at $0.99. But the IoT dev kit button will work too. It does take a second or two after pressing the button to trigger the activity in ST, but the delay is not unreasonable.

A couple seconds is great if the button finds Wifi fast when I arrive home.

I got this working (although getting all the prerequisites set up on an original Raspberry Pi B was quite a headache!) One question, though: what’s the best way to set up STNP to run as a service instead of as a foreground application?

Thanks!

I forgot to mention: I also had a small problem with the SmartApp. When passing params to buttonSettings, the num value was getting recast as a float for some reason, which meant the config variable names were getting lost in translation. I don’t know why this was happening, but putting the following line at the beginning of the buttonSettings method patched it up:

params.num = (int)params.num;

Couple different options… I just use forever to run it as a background process but that works for me cause the machine never goes down. If you want to make sure it comes back if the RPi reboots, check the following out:

Thanks… added this to the SmartApp.

Thank you so very much for the time you took to produce a video and details. I have a question please.
I installed and ran everything on a Mac Mini that I am using as a “server”. It seems that when I run “sudo node server.js”, it keeps on checking and trigger the event to smartthings.

Here is an example that keeps repeating itself if I have the notify settings in the JSON file:

[2017-04-25T05:00:57.732Z] [stnp] SmartThings Node Proxy listening at http://:::8080
[2017-04-25T05:00:57.758Z] [stnp] Loaded plugin: dash
[2017-04-25T05:01:01.471Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}
[2017-04-25T05:01:09.837Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}

and example if I don’t:

[2017-04-25T04:58:16.150Z] [stnp] SmartThings Node Proxy listening at http://:::8080
[2017-04-25T04:58:16.177Z] [stnp] Loaded plugin: dash
[2017-04-25T04:58:16.863Z] [dash] {“address”:“aa:20:66:e1:5c:00”,“status”:“active”}
[2017-04-25T04:58:16.863Z] [stnp] Notify server address and port not set!
[2017-04-25T04:58:18.435Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}
[2017-04-25T04:58:18.435Z] [stnp] Notify server address and port not set!
[2017-04-25T04:58:26.449Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}
[2017-04-25T04:58:26.449Z] [stnp] Notify server address and port not set!
[2017-04-25T04:58:35.237Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}
[2017-04-25T04:58:35.237Z] [stnp] Notify server address and port not set!
[2017-04-25T04:58:44.055Z] [dash] {“address”:“0e:4d:e9:ca:15:00”,“status”:“active”}
[2017-04-25T04:58:44.055Z] [stnp] Notify server address and port not set!

I am obviously missing something :slight_smile:

Thanks in advance for any insights!

Couple things… first I should have mentioned that the notify settings are automatically set by the SmartApp… so you don’t need to set that in the config.json. Just create the config.json as I show in the video and proceed to setup your SmartApp. When you configure the SmartApp, it’ll set the notify settings for you.

Second… are you sure the MAC address is correct?? Cause it looks like it’s triggering too often to be the Dash Button… also a MAC vendor lookup for the address does not find the vendor. If I type in the MAC address for my Dash Buttons @ https://macvendors.com, it returns “Amazon Technologies Inc.” Double check the MAC address and make sure you got the right one.

@redloro
Yes, you were right. The first anomaly is that the server.js didn’t get the correct mac addresses. I was able to get them by going the “low tech” way and check the logs from my router. :slight_smile:I checked the addresses from macvendors and they all belong to Amz.

It does seem to resolve the constant polling… for a while. Adding correct mac address seems to work for a little while in the terminal. But after I configure the smart app, nothing happens now :frowning: I click the dash and no action and after a few minutes the server.js tries to discover dash buttons again.

[2017-04-25T06:52:26.152Z] [stnp] SmartThings Node Proxy listening at http://:::8080
[2017-04-25T06:52:26.182Z] [stnp] Loaded plugin: dash
[2017-04-25T06:54:48.984Z] [stnp] ::ffff:192.168.1.15 GET /subscribe/192.168.1.15:39500
[2017-04-25T06:54:49.352Z] [stnp] ::ffff:192.168.1.15 GET /plugins/dash/discover/30
[2017-04-25T06:54:49.357Z] [dash] Discovering Dash Buttons on local network…
[2017-04-25T06:54:57.700Z] [dash] {“address”:“aa:20:66:e1:5c:00”,“protocol”:“udp”}
[2017-04-25T06:55:06.441Z] [dash] {“address”:“aa:20:66:e1:5c:00”,“protocol”:“udp”}
[2017-04-25T06:55:15.054Z] [dash] {“address”:“aa:20:66:e1:5c:00”,“protocol”:“udp”}
[2017-04-25T06:55:19.358Z] [dash] Finished discovery on local network

We’re making progress though, thanks to you!

Ok - you probably have the MAC addresses in the config.json and the MAC addresses in the SmartApp out of sync. I should probably also mention that you can’t edit the config.json when the STNP is running… it’ll overwrite whatever you put in your config.json if it’s running… So to get this fixed, do the following:

  1. Delete the SmartApp if you’ve already set it up… we only want to set it up once we know that STNP is running correctly
  2. Stop STNP
  3. Edit your config.json and make sure that the MAC addresses are correctly listed
  4. Start STNP
  5. Push your Dash Button and watch STNP correctly identify it and send a message
  6. Once we know that STNP + Dash Button is working correctly, setup the SmartApp

Thank you. I followed the steps, but no luck. I know that the dash mac address is correct from looking at router logs, but when running stnp, with the correct mac address in the config.json file and pressing the dash, all it does is stop on:

Mini-Mac:smartthings-nodeproxy minimac$ sudo node server.js
[2017-04-26T05:56:35.286Z] [stnp] SmartThings Node Proxy listening at http://:::8080
[2017-04-26T05:56:35.312Z] [stnp] Loaded plugin: dash

The weird part is that when I try it in “discovery” mode, it keeps returning those 2 other mac addresses which I cannot see associated with anything on my network :frowning:

Hmmmm not sure what could be causing this… the setup I have at home is also on a Mac-Mini so this should work. And the Dash button has been configured with the Amazon app… all the way to pick your product?? If so, let’s try the following:

  • Stop STNP
  • Change your config.json so that the Dash settings look like this:
  "dashX": {
    "buttons": ["aa:bb:cc:dd:ee:f1", "aa:bb:cc:dd:ee:f2"]
  }
  • Start STNP, the Dash plugin will go into Discovery Mode
  • Wait 5 secs and press the Dash Button…
  • Wait 20 secs and press the Dash Button again (note that you can’t press it too frequently as it has a built in delay and will just ignore repeated presses)

If you see the MAC address show up in the STNP console log, then you’re good. If you do not, we need to figure out why… and I would guess it has to do with your network. Is your Mac-Mini on the same network, subnet, VLAN, etc as the wireless network that the Dash Button is connecting to… with no firewalls in between?

Another thing you can try is to see if the Dash Button is sending ARP requests instead of UDP…

  • Stop STNP
  • Uncomment line 88 of the dash.js plugin so that it looks like this:
// if (protocol === 'arp') { return; }
  • Start STNP and re-run the tests above

Good luck!

Thanks, but the results are just the same. The mac mini is on the same network as I used to activate the dash (didn’t pick the product) I can see that dash button in my router logs. The mac mini with osx firewall off or on is same result.

Don’t worry about it, no big deal if I can’t get it to work. Not the end of the world for me :slight_smile:
Thanks again!

@solutionssquad did you get it working?

NodeJs yes.
Having issues with the button itself not doing anything other than saying it was pressed multiple times, but havent had time to work on it.

1 Like