Skip to content

Instantly share code, notes, and snippets.

@fffonion
Created September 28, 2019 22:32
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save fffonion/d4960503ff6782640286163d47a30080 to your computer and use it in GitHub Desktop.
Save fffonion/d4960503ff6782640286163d47a30080 to your computer and use it in GitHub Desktop.
Setting up dash button without Amazon App
import requests
import re
import sys
# Initial work from: https://mpetroff.net/2016/07/new-amazon-dash-button-teardown-jk29lp/
h = requests.Session()
BASE_URL = "http://192.168.0.1"
def wait_for_device():
print("* Long press the dash button until LED light blinks in blue")
print("* Connect to Wifi with SSID \"Amazon ConfigureMe\"")
print("* Waiting for connection...")
while True:
try:
r = h.get(BASE_URL, timeout=1)
if 'Amazon Dash' in r.content:
break
except:
pass
else:
break
print("+ Connected!")
content = r.content
serial = re.findall('Serial Number</th>[^/]+>([A-Z0-9_]+)</td', content, re.DOTALL)[0]
mac = re.findall('MAC Address</th>[^/]+>([A-Z0-9_]+)</td', content, re.DOTALL)[0]
firmware = re.findall('Firmware</th>[^/]+>([A-Z0-9_]+)</td', content, re.DOTALL)[0]
battery = re.findall('Battery</th>[^/]+>([A-Z0-9_]+)</td', content, re.DOTALL)[0]
print("* Serial: %s, MAC: %s, Firmware: %s, Battery: %s" % (serial, mac, firmware, battery))
return mac
def configure_wifi(ssid, password):
print("* Configure Dash button to connect to \"%s\"" % ssid)
# is the ssid in range ?
r = h.get(BASE_URL, headers={'Content-Type': 'application/json'}, timeout=5)
amzn_networks = r.json()['amzn_networks']
found = False
for amzn_network in amzn_networks:
if amzn_network['ssid'] == ssid:
found = True
break
if not found:
print("- SSID %s is not discoverable by Dash button" % ssid)
return
print("%s/?amzn_ssid=%s&amzn_pw=%s" % (BASE_URL, ssid, password))
r = h.get("%s/?amzn_ssid=%s&amzn_pw=%s" % (BASE_URL, ssid, password), timeout=5)
if r.status_code == 200:
print("+ Dash button configured!")
return True
if __name__ == '__main__':
if len(sys.argv) < 3:
print("Usage: setup.py WIFI_SSID WIFI_PASSWORD")
sys.exit(1)
try:
wait_for_device()
configure_wifi(sys.argv[1], sys.argv[2])
except KeyboardInterrupt:
print("Bye")
@PatiB87
Copy link

PatiB87 commented Mar 31, 2020

I'm stuck at waiting for connection even though I can access the WWW page in my browser and ping the device

I have the same issue! I can open the page in the browser and in the browser dev tools, the response looks fine. Still I'm stuck at "waiting for connection".
Any help? :(

@sangohandbz
Copy link

i would suggest replacing r.content by r.content.decode('utf-8') around Line 18 in order to compare string to string and not string to byte string.
Do the same around Line 25.

@mattia2007
Copy link

hello, can someone help me? when i start te script it opens up this screen.
sorry for the bad english i'm from italy.
error

@sangohandbz
Copy link

hello, can someone help me? when i start te script it opens up this screen.
sorry for the bad english i'm from italy.
error

It is literally telling you wath to do : "Usage: setup.py WIFI_SSID WIFI_PASSWORD"
Lets say your SSID is : My Private Network
And your passwor is : My very secure pasword

You have to type : setup.py "My Private Network" "My very secure pasword" after the python prompt (>>>)

PS : I recommand you read my previous post, it might avoid you some issues.

@mattia2007
Copy link

and then what i do?

@sidoh
Copy link

sidoh commented Mar 31, 2020

Keep in mind that this only works for buttons that have been set up before, or are really old (rev1 hardware circa 2015). If you bought your button off of ebay, it probably has been set up before. Most resellers bought the button for the $5 credit.

If you have old firmware, you can still run through the full setup. Instructions here:

https://blog.christophermullins.com/2019/12/20/rescue-your-amazon-dash-buttons/

@mattia2007
Copy link

how can i see if i have an old firmware?

@sidoh
Copy link

sidoh commented Mar 31, 2020

just try the setup process. if it works, you do.

@mattia2007
Copy link

mattia2007 commented Mar 31, 2020

i don’t know what to do after the the first step

@sidoh
Copy link

sidoh commented Mar 31, 2020

Wrote up the instructions in the link to my blog above. If these aren't detailed enough, I'm probably not going to be able to be of much help. Good luck!

@mattia2007
Copy link

but i can’t play the wav file

@sidoh
Copy link

sidoh commented Mar 31, 2020

Try VLC.

@mattia2007
Copy link

ok thank you i try this tomorrow

@mattia2007
Copy link

hey it does' work for any of mine dash button. is there another way?

@PatiB87
Copy link

PatiB87 commented Apr 1, 2020

I used the method from the writeup now. It worked with the sound exploit for one of two buttons (firmware 3-something). For the other button (firmware 6-something) it did not work. As I read here, the exploit was fixed there. So there is currently no way to use this one, right?
I read that the buttons delete everything incl. the customer secret when the battery is low, so opening it up, inserting a very low battery and letting it delete the secret could help?

Thanks so far to everyone! Having one of the two buttons working and be usable in my FHEM home automation is already really great!! :) :)

@mattia2007
Copy link

hey so what i can do with my dash buttons? i want to connect them to hassio for switch on or off a light. can someone help me?

@sidoh
Copy link

sidoh commented Apr 1, 2020

@mattia2007, if the exploit didn't work, I'm not aware of another way to recover your buttons. Sorry. :(

@PatiB87,

I read that the buttons delete everything incl. the customer secret when the battery is low, so opening it up, inserting a very low battery and letting it delete the secret could help?

Unfortunately it only clears user data when low battery is detected. It'll stay on the same firmware version.

@mattia2007
Copy link

so i can’t use them anymore?

@sangohandbz
Copy link

@mattia2007

so i can’t use them anymore?

Unfortunely if your button does not work with this script and/or the audio exploit you are out of luck. (see @ALL below for further info if not already done)

@mattia2007

hey so what i can do with my dash buttons? i want to connect them to hassio for switch on or off a light. can someone help me?

For your automation purposes you could buy some zigbee button (konke, xiaomi aquara, ...) and a usb/wifi/... zigbee bridge (like zigate, ...) see zha module compatibility list in the home assistant site (https://www.home-assistant.io/integrations/zha). It will probably be more expensive but reliable.

@ALL
If the script hangs :

  1. Replace r.content by r.content.decode('utf-8')
  2. If still doesn't work see sidoh's blog post for further reference on setting https://blog.christophermullins.com/2019/12/20/rescue-your-amazon-dash-buttons/
  3. If it still won't work : welcome to planned obsolecence !

@mattia2007
Copy link

mattia2007 commented Apr 2, 2020

hey, i've retested and for one works but i forgot to blacklist it is there a way to resolve?

@mattia2007
Copy link

what i do then?
Senza titolo

@corv45
Copy link

corv45 commented Apr 4, 2020

bonjour je n'arrive pas a détermine ou je dois rentre le ssid et le pass dans le script merci

@sangohandbz
Copy link

sangohandbz commented Apr 4, 2020

bonjour je n'arrive pas a détermine ou je dois rentre le ssid et le pass dans le script merci

-1. Pense a récupérer l'adresse MAC du bouton cf. messages précédent et/ou le post sur le blog de sidoh (connexion au wifi amazon configure me et consulter le site 192.168.0.1 avec ton navigateur).
0. Blacklist l'accès à internet de ton bouton en utilisant son adresse MAC dans ton routeur

  1. Installe Python3.xx
  2. Modifie les lignes contenant r.content cf. messages précédents
  3. Ouvre le python shell
  4. Navigue dans le dossier de ton script
  5. Tappe setup.py "Ton SSID" "Ton pass" après les 3 chevrons (les " sont particulièrement important si ton SSID et/ou ton PASS contiennent des espaces)

@Jackie78De
Copy link

Hi,

my Dash button (Firmware 60019520_EU) suddenly doesn't work anymore, from one day to the next it only lights up a blue light for about 10 seconds, and then flashes red. I doubt it was bricked by Amazon, because I use this button in the local intranet only to control some smart home devices, my Router does not allow the device to communicate with the internet. So I am not sure what actually bricked it.

The audio-hack didn't work, and also trying to access http://192.168.0.1/?amzn_ssid=SSID&amzn_pw=PASSWORD does not do anything at all, in fact, nothing happens in the browser when I call that URL.

When I access only http://192.168.0.1/, i can at least get the firmware version and MAC, serial, battery status, but that's all.

So my questions are:

1.) How could the device have become bricked? It has no internet access
2.) Is there any chance to unbrick?

Thanks!

@sangohandbz
Copy link

Hi,

my Dash button (Firmware 60019520_EU) suddenly doesn't work anymore, from one day to the next it only lights up a blue light for about 10 seconds, and then flashes red. I doubt it was bricked by Amazon, because I use this button in the local intranet only to control some smart home devices, my Router does not allow the device to communicate with the internet. So I am not sure what actually bricked it.

The audio-hack didn't work, and also trying to access http://192.168.0.1/?amzn_ssid=SSID&amzn_pw=PASSWORD does not do anything at all, in fact, nothing happens in the browser when I call that URL.

When I access only http://192.168.0.1/, i can at least get the firmware version and MAC, serial, battery status, but that's all.

So my questions are:

1.) How could the device have become bricked? It has no internet access
2.) Is there any chance to unbrick?

Thanks!

Hello.

My best bet is low battery.
Check the battery percentage in the webUI. The firmware erases the customer secret when the battery becomes to low (don't know the exact value). As the device is suposed to be trashed when it runs out if battery this is probably a safety feature to preserve your amazon account and wifi credential. From there if the audio hack doesn't work : there is no known recovery ...

To avoid this issue you have to swap the battery before it reaches the threshold -> that isnt causing a reset because the device isn't powered between press to save power.

@bummzulu
Copy link

I am a total noob with Python and faced similar issues as others here but finally it worked!

Firmware Version: 60019520_EU

On a windows machine I did the following:

  • Install Python

Then open a Windows cmd line and go to the path of your python installation. Example:
C:\Users\user\AppData\Local\Programs\Python\Python38-32\

  • install "requests" there:
    python -m pip install requests or py -m pip install requests

Save the script from above as py file at this path under the name "setup.py". In the script replace the
r.content with r.content.decode('utf-8') in line 18 and line 25.

in the windows cmd line run the programm by
image

@mhellmeier
Copy link

I´ve installed old amazon app apk version 18.4.0.100 wich has still the function to add new dash buttons.

I just tried the mentioned App version in the German region but no Dash menus or settings are visible to add a new button.

@Rothammel
Copy link

  • Long press the dash button until LED light blinks in blue
  • Connect to Wifi with SSID "Amazon ConfigureMe"
  • Waiting for connection...
  • Connected!
    Traceback (most recent call last):
    File "D:\setup-dashbutton.py", line 60, in
    wait_for_device()
    File "D:\setup-dashbutton.py", line 26, in wait_for_device
    serial = re.findall('Serial Number[^/]+>([A-Z0-9_]+)</td', content, re.DOTALL)[0]
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\re.py", line 240, in findall
    return _compile(pattern, flags).findall(string)
    TypeError: cannot use a string pattern on a bytes-like object

@elysweyr
Copy link

elysweyr commented May 5, 2023

File "D:\setup-dashbutton.py", line 26, in wait_for_device

You may need to append .decode('utf-8') to line 25.

@elysweyr
Copy link

elysweyr commented May 5, 2023

I am on FW version 60019520_EU and it worked.
The problem in my case was that I had to url encode the SSID and password because it contained spaces and special characters.

Note: Don't forget to block internet access for your dash buttons otherwise they will get an OTA update and brick themselves.

Seems like my button is connection to the wireless network but isn't able to acquire a DHCP lease - odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment