There is a latency on the order of 5 seconds between the button press and event showing up in EG, so this won't make a great light switch. Still, for $5 it's a button that you can use anywhere in WiFi range to send an event to EG which is pretty reasonable.
The source code I'm using appears below. Here are a few notes on how this is setup:
- I have no idea what I'm doing with Python, so getting all the modules setup was the hardest part for me. Also, don't laugh too hard at my code as I'm pretty sure I'm doing any number of dumb things.
- I'm running the 32bit version of Python 2.7 on this system (installed some time ago, not sure why I used 2.7 or 32bit at the time but it works OK so no point in breaking it)
- I installed the modules found here to get scapy working
- Installed the latest WinPcap
- Then I installed PIP
- Added C:\Python27 and C:\Python27\Scripts to my PATH
- Then used PIP to install requests with the command:
Code: Select all
pip install requests
- I followed the guide in the article, then hacked together a version of the script that will send a GET request to my EG server
Code: Select all
from scapy.all import * import requests import time def arp_display(pkt): if pkt[ARP].op == 1: #who-has (request) if pkt[ARP].psrc == '0.0.0.0': # ARP Probe if pkt[ARP].hwsrc == '74:c2:46:f2:31:4c': # On Button 1 print time.strftime("%Y-%m-%d %H:%M:%S") + ": ARP from " + pkt[ARP].hwsrc + ", requesting http://10.0.0.160/index.html?Dash.Button.On.1" r = requests.get('http://10.0.0.160/index.html?Dash.Button.On.1') else: print "ARP Probe from unknown device: " + pkt[ARP].hwsrc print sniff(prn=arp_display, filter="arp", store=0)