At home, I have several Amazon Dash Buttons throughout the house with a Raspberry Pi listening for clicks. I mainly use these buttons to track whether I have completed a specific task near the Amazon dash button. For example, I have have a button in my bathroom I click when I have flossed my teeth at night. Clicking this button would then mark the corresponding daily task completed.
Below is the script I use to mark a task done (some details omitted).
from scapy.all import * import requests # it takes a minute for the scapy sniffing to initialize, so I print this to know when it's actually ready to go print('Init done.') USER_ID = "" API_TOKEN = "" mac_address_to_task_data = { "40:b1:cd:24:e2:1d": ("task_id", "task_name"), "18:74:fd:eb:82:17": ("task_id", "task_name"), "38:f7:3d:ca:32:dd": ("task_id", "task_name") } def execute_task(task): url = "https://task-management-app.com/tasks/%s/%s" % (task[0], "up") headers = { "x-api-user": USER_ID, "x-api-key": API_TOKEN, } requests.post(url, headers=headers) print "Executed '%s'" % task[1] def detect_button(pkt): if pkt.haslayer(DHCP): if pkt[Ether].src in mac_address_to_task: task_data = mac_address_to_task.get(pkt[Ether].src) execute_task(task) else: print "Unknown: " + pkt[Ether].src sniff(prn=detect_button, filter="(udp and (port 67 or 68))", store=0)
For more info, then check out this blog post on hacking the Amazon Dash Button which helped in getting started with this.