当前位置: 首页>>代码示例>>Python>>正文


Python Environment.get_motion方法代码示例

本文整理汇总了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()

开发者ID:jcmb,项目名称:jcmbsoft,代码行数:31,代码来源:WeMo_Motion.py

示例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()

开发者ID:jcmb,项目名称:jcmbsoft,代码行数:31,代码来源:Test.py

示例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)
开发者ID:GuoJing,项目名称:homehue,代码行数:33,代码来源:main.py

示例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
开发者ID:jeffsharris,项目名称:jarvis,代码行数:33,代码来源:wemo.py


注:本文中的ouimeaux.environment.Environment.get_motion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。