Commit 131c7ae2 authored by Caughlin Bohn's avatar Caughlin Bohn
Browse files

Remote Activated lighting, listens to head on :80/control

parent 4daf9820
from piglow import PiGlow
import time
import socket
import subprocess
import psutil
from random import randint
import urllib2, json
p = PiGlow()
val = 100
colour = 1
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
def getControlData():
rawData = urllib2.urlopen("http://192.168.1.1/control").read()
print(rawData)
controls = json.loads(rawData)
print(controls)
host = socket.gethostname()
print(controls[host])
return controls[host]
while True:
#try:
p.all(0)
if getControlData():
print("in")
p.white(10)
time.sleep(0.1)
p.blue(20)
time.sleep(0.1)
p.green(30)
time.sleep(0.1)
p.yellow(40)
time.sleep(0.1)
p.orange(50)
time.sleep(0.1)
p.red(60)
time.sleep(0.1)
p.white(255)
time.sleep(0.1)
p.red(0)
time.sleep(0.1)
p.orange(0)
time.sleep(0.1)
p.yellow(0)
time.sleep(0.1)
p.green(0)
time.sleep(0.1)
p.blue(0)
time.sleep(0.1)
p.white(0)
time.sleep(0.1)
else:
p.all(0)
time.sleep(0.5)
# except Exception as e:
# print(e)
# p.all(0)
# p.red(255)
# p.white(255)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment