Hack the Amazon Dash button to control a SmartThings switch

Hi, I’m about to publish a blog entry: I chose a similar, yet less extravagant approach. Instead of digging through the whole ARP stuff, I specifically listen to DHCP requests. When I’m on the DHCP server itself, it’s usually enough to watch the log entries with a tail / awk / regex one-liner. Otherwise installing dhcpdump and then also scanning its output with awk / regex does a great job in just one line. Would you be interested in hearing about this? In that case I’ll get back to you once I’ve got my blog entry up.

1 Like

I installed the smartapp and then fired toggle_st() but got nothing,

I then sent it to IFTTT maker and it successfully triggered so at least the button press part of the program is working.

The smartthings debug log show nothing so I am guessing it never reached the destination.

I am a python noob, anyone can help me with debugging this?

What does the full hardcoded URL http request look like? I’d like to see if I can just enter that from a web browser to see if smartthings would receive it. TIA

Heads up UK users (and maybe elsewhere in the world too, but I haven’t checked)
Dash buttons are 99p today, still get your £4.99 credit too but it seems you have to avoid setting it up to use it as a SmartThings switch.

Does the Python script needs to be executed all the time (e.g. a server or computer running it)?
After all the process is enough the device handler as any other thing?

Hi, like the article, I found scapy not working for me pi or PC so I used wireshark to get Mac.
Gave it a fixed (dhcp) address and used python to ping and I was off.
Next is the physical back to make the switch external.
I am making a You have post" mail box sensor that does not need mains power unlike my previous attempt.
Read some stuff about wi-fi and numbers of devices so am using separate ap and said, let’s hope I understood.
Thanks

Don’t even waste your time with the 4.99 dash button plus using a Pi. But spend the $20 for a button and save yourself a headache.
Check this out: 1st Generation AWS IoT Button Amazon https://www.amazon.com/dp/B01C7WE5WM/ref=cm_sw_r_sms_awdb_H5vByb11HDVS1

Hi JD I was thinking about your argument around total cost of ownership (TCO). I think that becomes a really valid point once the uses cases for these things mature. Today the average Joe will use it a few times and then move on so the $5 is likely the best bet for the hobbiest at this point I think.

Nice article. Thank you for sharing! :smiley:

Is there a way to trigger the SmartApp via something other than a Python script (i.e. Tasker or cURL)?
I’m entirely new to HTTP requests so I’m kinda lost.

Has anyone gotten a version of this to work with AWS Lambda and an AWS IoT Button? I have the button talking to AWS and attempting to fire the script, but I don’t think it is sending through the correct commands.

import pycurl
import json

def lambda_handler(event, context):

Run Smartthings Command

#Good Morning Home

url = 'https://<st endpoint url>'
data = json.dumps('{"command":"toggle"}')
c = pycurl.Curl()
c.setopt(pycurl.HTTPHEADER, ['Authorization:Bearer <secret key>','content-type:application/json'])
c.setopt(pycurl.PUT, 1)
c.setopt(pycurl.POSTFIELDS, data)
c.setopt(pycurl.URL, url)
c.perform()

I use ifttt with webhooks on my AWS IoT buttons. Its not quite as fast as a $5 Dash button running redloro’s smartapp w/ SmartThings node proxy but being able to control 3 things with one button is nice. Could probably use the IoT Dash with smartthings node proxy as well, but thats a bit more than I am capable of at the moment.

That could work… I have a friend from work looking at it, so I will post
progress (if I make any).

+1 for Rurico, I’d like to know what configuration/scripts you are running to emulate a response from Amazon.

Can anyone assist with the listen.py script.

After pressing the Dash button i get the response to say ‘Toggle the light’ but nothing happens.

I have added /switches to the URL as mentioned by one user.

Nothing shows in the smartthings logs so I can only assume it is not authorizing.

When I look at the URL in the simulator I get a different URL when I select virtual switch and dining room lights, then if I just select dining room lights. What should I be selecting?

I assume I do not need the OAuth client id / secret?

…the part i think i am getting wrong …

def toggle_st():
url = 'https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/xxxxx-58bf-47cf-b3fb-41010c885bf0/switches
headers = {“Authorization”: “xxxxx-a0ad-42aa-8f00-ff2da468802e”}
data = '{“command”:“toggle”}'
r = requests.put(url, data=data, headers=headers)

Thanks in advance.

Working!!

Found my issue - I missed Bearer

headers = {“Authorization”: “Bearer a4xxxx8-a0ad-42aa-8f00-ff2da468802e”}

Also to answer my own question, there was no need to make changes in the smartthings mobile App

To add a 2nd dash I assume I create a new smartapp plus modify the if statement in the listen.py

As a better solution I have ordered a load of buttons and sensors from here.

https://www.gearbest.com/smart-light-bulb/pp_257679.html

I have one on each of my nightstands, press once to operate the light on that night stand and hold for 2 seconds operates both night stands. I have used them for a couple months now and they work great.