This is probably the last Amazon Dash hack I can come up with. The previous one – Wireless Doorbell was a great success and I’m still using it whenever I’m awaiting a delivery. If you have not seen that one yet, go and take a look. We are going to build on it. With that in mind, I’d like to introduce the Amazon Dash security sensor.
Amazon Dash Security Sensor
Before we start, I’d like to point out that ‘security sensor’ should be taken with a pinch of salt, as most often than not, the DIY solutions don’t come close professional installation. You can read more about the biggest pitfalls of home-made security systems here.
The warning has been issued, I can jump straight to the meat of things. Turns out that you can replace the button with a simple reed switch. This eliminates the need for pressing the button to activate the Amazon Dash security sensor. A magnetic field will do this for you. The same behaviour is used in professional alarms. The reed switches are placed near the point of entrance to enable the door/window monitoring. A magnet or an electromagnetic field is used to activate the switch and close the circuit.
Reed switches come in 2 flavors:
- NO – Normally Open: the switch remains open until magnetic field is applied
- NC – Normally Closed: just the opposite
For this hack, we are using the NO reed switch. When a magnet comes close enough to the switch, out Amazon Dash security sensor with register this as a button press.
Limitations
Because this is a hack, it comes with a few limitations. If you can live with it, this hack could be for you:
- no ‘low battery’ indicator
- the switch can be activated once every 10 sec
- the switch cannot stay in ‘on’ position for more than 4 sec
- the specific position of the magnet
The Amazon Dash’s battery is pretty good. I still have my 1st generation buttons (from 2 years ago) and they work just fine. Just bear in mind, that you should test the battery once a while.
The cooldown for the button is about 10 sec. There is no way around it. I’m ok with it, as my alarm will only trigger once before it has to be reset.
If the button is held in ‘pressed down for about 6sec – Amazon Dash enters the pairing mode. All the examples shown by me are not affected by this. It’s just something for you to keep in mind. This also means that the button is activated by a sliding motion of the magnet.
Lastly, the magnet should pass the reed sensor rather than stay in the vicinity of the reed switch, otherwise, the Amazon Dash security sensor will enter the pairing mode.
Amazon Dash Security Sensor – hardware mod
Despite having screws, buttons are not meant to be taken apart, but once disassembled, you will be able to glue them back together. There are no latches that can close the enclosure once opened.
I’m going to add the reed switch to both terminals of the button. This is labeled on the picture below. When the reed switch is activated the Amazon Dash will think that you have pressed the button.
Due to the size of the wire used in my case, I was unable to put the button part back together. While it doesn’t bother me that much, it may be a limiting factor for you. If you have a very thin, isolated wire, with good soldering skills you could assemble it all together and make the button usable as well.
I used a hot needle to pierce the enclosure and slot the reed pins inside. It connects to the button pins inside via cable. I had to use a hot screwdriver to make some extra space in the plastic enclosure for the wires. In theory, you could enclose the switch inside (it looks like there is enough space, but I found it much easier to align the sensor and the magnet when the sensor is visible).
Put back the newly created Amazon Dash security sensor. You can use glue, or piece of the isolating tape to keep the enclosure together.
Software
If this is your first hack, please see the Wireless Doorbell tutorial to set up the Amazon Dash buttons and connect Raspberry Pi to a mobile via AutoRemote.
The script has been simplified. It’s launched via AutoRemote and sends the notification back that the script is running. When the button activates, another notification is sent. A few seconds later the script terminates.
The notification will be sent only once.
Amazon Dash requires:
pip3 install scapy-python3
********************"""
from scapy.all import *
import urllib.request
from sys import exit
url_mobile = 'https://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message=alarm=:=BUTTON_NAME=:=warning'
def confirmation():
mobile = 'https://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message=alarm=:=BUTTON_NAME=:=set'
response = urllib.request.urlopen(mobile).read()
confirmation()
def arp_display(pkt):
if pkt[ARP].op == 1:
if pkt[ARP].hwsrc == 'Amazon Dash MAC': #Your button MAC
response = urllib.request.urlopen(url_mobile).read()
exit(5)
print (sniff(prn=arp_display, filter="arp", store=0, count=0))
The setup is very simple. There are two profiles, one to handle the alarm message and one to take care of the resetting the script.
Alarm profile – responds to the ‘alarm’ AutoRemote message. If the AR message contains ‘set’ as %arcomm2 – a short confirmation is displayed. If the AR message says %arcomm2 = ‘warning’ a notification is issued with an option to reset it.
The reset is handled by an AutoApps command ‘alarm=:=reset’ .
The reset profile responds to AutoApp command ‘alarm=:=reset’. A notification is canceled when the message is received. I can use the linked task Alarm to create a shortcut as well. This way I can arm the alarm directly from the phone’s home screen.
You can use AutoTools SSH (or AutoRemote) to issue a resetting command to the Raspberry Pi. In both cases the command should be:
sudo python3 /path/to/file/script.py
It’s worth noting that the message issued by the SecuritySensor script has the following structure:
alarm=:=button_name=:=command
This way you can assign multiple buttons to your notifications.
Conclusion
I hope you enjoyed this little hack and you come up with some fantastic usage. I’m going to use mine for letterbox notifications and the garage door sensor. There is no way I will open and close this thing in less than 10 seconds 🙂
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.