Skip to content

Instantly share code, notes, and snippets.

@magsol
Last active January 29, 2019 08:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magsol/420787f963ee3f682c4d8927142fe828 to your computer and use it in GitHub Desktop.
Save magsol/420787f963ee3f682c4d8927142fe828 to your computer and use it in GitHub Desktop.
Attempts to get the Amazon Dash button working with Hue lights.
FROM ubuntu:14.04.4
MAINTAINER Shannon Quinn "magsol@gmail.com"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y wget build-essential openjdk-7-jdk vim git tcpdump
# Install Anaconda, specifically Python 3.
ENV ANABIN Miniconda3-latest-Linux-x86_64.sh
ENV PY3 /opt/python
RUN wget https://repo.continuum.io/miniconda/$ANABIN && \
chmod +x $ANABIN && /bin/bash ./$ANABIN -f -b -p $PY3 && rm $ANABIN
ENV PATH $PY3/bin:$PATH
RUN conda update -y --all
RUN pip install scapy-python3 && pip install requests && pip install phue
# Pull in the Python script.
ADD run.py /run.py
CMD /bin/bash
from phue import Bridge # for hue
import logging # for the following line
logging.getLogger("scapy.runtime").setLevel(logging.ERROR) # suppress IPV6 warning on startup
from scapy.all import * # for sniffing for the ARP packets
import requests # for posting to the IFTTT Maker Channel
# setting up and connecting to Hue bridge
b = Bridge('192.168.1.243')
b.get_api()
# 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.')
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '0.0.0.0': # ARP Probes will match this
if pkt[ARP].hwsrc == '74:75:48:a5:33:be': # this is the first button MAC address
# [Black Button 1]
print("Pushed Black Button 1")
else:
print("ARP Probe from unknown device: " + pkt[ARP].hwsrc)
print(sniff(prn = arp_display, filter = "arp", store = 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment