本文整理汇总了Python中ouimeaux.environment.Environment.get_motion方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_motion方法的具体用法?Python Environment.get_motion怎么用?Python Environment.get_motion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ouimeaux.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_motion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_switch
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get_motion [as 别名]
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: quit
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get_motion [as 别名]
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: SubscriptionRegistry
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get_motion [as 别名]
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: on_motion
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get_motion [as 别名]
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