Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2016 18:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kellbot/1dcd1ad8a7ec04148d38c18275a55bb8 to your computer and use it in GitHub Desktop.
from scapy.all import *
from lifxlan import *
import sys
from copy import copy
from time import sleep, time
#find all our lights
lifx = LifxLAN()
bulbs = lifx.get_lights()
#Find the bulb we want
for bulb in bulbs:
if bulb.mac_addr == 'your:bulb:mac:address:here':
target_bulb = bulb
#detect ARP packet from button
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '': # ARP Probe
if pkt[ARP].hwsrc == 'your:button:mac:address:here': # Huggies
print "Pushed Huggies"
print "ARP Probe from unknown device: " + pkt[ARP].hwsrc
#fade the bulb in and out
def breathe_light(bulb):
half_period_ms = 1500
duration_secs = 30
#turn the bulb on
start_time = time()
while True:
cyan = [29814, 65535, 65535, 3500]
half_bright = int(cyan[2]/2)
dim_cyan = [29814, 65535, half_bright, 3500]
bulb.set_color(cyan, half_period_ms, rapid=True)
bulb.set_color(dim_cyan, half_period_ms, rapid=True)
if time() - start_time > duration_secs:
raise KeyboardInterrupt
except KeyboardInterrupt:
print("Leaving bulb on")
bulb.set_color( [29814, 65535, 65535, 3500])
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