示例#1
0
Motion_Name=sys.argv[1]
print "Monitoring: ", Motion_Name
   
logging.basicConfig(level=logging.CRITICAL)
#def on_switch(switch):
#    print "Switch found!", switch.name

def on_motion(motion):
    print "Motion sensor found!", motion.name

env = Environment(motion_callback=on_motion,with_cache=False,with_subscribers=False)

env.start()

env.discover(seconds=3)

#pprint(env.list_switches())
#pprint(env.list_motions())
Motion=env.get_motion(Motion_Name)
#Motion.explain()
while 1:
   State = Motion.get_state()
#   print datetime.datetime.now()
#   print State
   if State != 0:
      print "Motion Detected"
      quit()
   time.sleep (0.25)
#env.wait()

示例#2
0
文件: Test.py 项目: jcmb/jcmbsoft
   print "Waits for the Motion Detector to detect motion and then exits with a result of 0
   quit(10)

if len(argv) != 2:
   help()
   
Motion_Name=argv[1]
print Motion_Name
   
logging.basicConfig(level=logging.CRITICAL)
#def on_switch(switch):
#    print "Switch found!", switch.name

def on_motion(motion):
    print "Motion found!", motion.name

env = Environment(motion_callback=on_motion,with_cache=False,with_subscribers=False)

env.start()

env.discover(seconds=2)

#pprint(env.list_switches())
pprint(env.list_motions())
Motion=env.get_motion('Motion')
Motion.explain()
while 1:
   print datetime.datetime.now(),Motion.get_state()
env.wait()

示例#3
0
文件: main.py 项目: GuoJing/homehue
from ouimeaux.subscribe import SubscriptionRegistry

registry = SubscriptionRegistry()

env = Environment(with_cache=False)

env.start()

env.discover(3)

ms = env.list_motions()
ss = env.list_switches()

m = ms[0]

m = env.get_motion(ms[0])
ss = [env.get_switch(s) for s in ss]

h = Hue()
ls = h.lights
print ls

sunset = dict(sofa = [0.5543, 0.4098],
              room = [0.5452, 0.4164],
              bed  = [0.5848, 0.3872],
              desk = [0.5413, 0.4193])

def updated():
    t = time.localtime()
    n = datetime.now()
    start_time = n.replace(hour=19, minute=5, second=0, microsecond=0)
示例#4
0
timeoutTime = 1800 # Wait 30 minutes without motion before turning off the volcano
reactivateTime = 300 # If motion is detected within 5 minutes of turning off, then turn on again. Must be less than timeoutTime
waitTime = 60 # Check if it has timed out every 60 seconds 

def on_motion(motion):
	print "Motion found!", motion.name

def on_switch(switch):
	print "Switch found!", switch.name

env = Environment(on_switch, on_motion)
env.start()
env.discover(seconds=10)

switch = env.get_switch('Volcano')
motion = env.get_motion('Living Room')

lastMovedTime = time.time()
timedOut = False

@receiver(statechange, sender=motion)
def motion_detected(state, sender, signal):
	global lastMovedTime
	if (state == 1):
		print "Motion detected"
		lastMovedTime = time.time()
		
@receiver(statechange, sender=switch)
def switch_detected(state, sender, signal):
	global lastMovedTime
	global timedOut