本文整理汇总了Python中pytomation.devices.Motion.still方法的典型用法代码示例。如果您正苦于以下问题:Python Motion.still方法的具体用法?Python Motion.still怎么用?Python Motion.still使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytomation.devices.Motion
的用法示例。
在下文中一共展示了Motion.still方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_light_photocell_intial
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_light_photocell_intial(self):
motion = Motion()
motion.still()
photo = Photocell(address="asdf")
photo.dark()
light = Light(address="e3", devices=(photo, motion), initial_state=photo)
self.assertEqual(light.state, State.ON)
示例2: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_delay_light_specific(self):
# Motion.Still and Photocell.Light events do not retrigger
motion = Motion()
light = Light(address="D1", devices=(self.interface, motion), delay_off=3)
motion.motion()
self.assertEqual(light.state, State.ON)
time.sleep(2)
motion.still()
self.assertEqual(light.state, State.ON)
time.sleep(1)
self.assertEqual(light.state, State.OFF)
示例3: test_delay_non_native_command
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_delay_non_native_command(self):
m = Motion()
l = Light(
devices=m,
delay={
Attribute.COMMAND: Command.STILL,
Attribute.SECS: 2,
},
initial=State.ON
)
self.assertEqual(l.state, State.ON)
m.still()
self.assertEqual(l.state, State.ON)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例4: test_light_idle
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_light_idle(self):
m = Motion()
m.still()
l = Light(
devices=(m),
idle={Attribute.MAPPED: (Command.LEVEL, 30),
Attribute.SECS: 2,
}
)
l.on()
self.assertEqual(l.state, State.ON)
time.sleep(3)
self.assertEqual(l.state, (State.LEVEL, 30))
#Light shouldnt idle if it is off
l.off()
self.assertEqual(l.state, State.OFF)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例5: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_delay_light_specific(self):
# motion.off and Photocell.Light events do not retrigger
motion = Motion()
light = Light(address='D1',
devices=(self.interface, motion),
trigger={
'command': Command.ON,
'mapped': Command.OFF,
'secs': 3,
},
ignore={
'command': Command.STILL,
'source': motion,
}
)
motion.motion()
self.assertEqual(light.state, State.ON)
time.sleep(2)
motion.still()
self.assertEqual(light.state, State.ON)
time.sleep(1)
self.assertEqual(light.state, State.OFF)
示例6: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_delay_light_specific(self):
# motion.off and Photocell.Light events do not retrigger
motion = Motion()
light = Light(address='D1',
devices=(self.interface, motion),
trigger={
Attribute.COMMAND: Command.ON,
Attribute.MAPPED: Command.OFF,
Attribute.SECS: 3,
},
ignore={
Attribute.COMMAND: Command.STILL,
Attribute.SOURCE: motion,
}
)
motion.motion()
self.assertEqual(light.state, State.ON)
time.sleep(2)
motion.still()
self.assertEqual(light.state, State.ON)
time.sleep(1)
self.assertEqual(light.state, State.OFF)
示例7: test_light_scenario_g3
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import still [as 别名]
def test_light_scenario_g3(self):
m1 = Motion()
m2 = Motion()
interface = Mock()
l = Light(
devices=(interface, m1, m2),
ignore={
Attribute.COMMAND: Command.STILL,
},
trigger=(
{
Attribute.COMMAND: Command.ON,
Attribute.MAPPED: Command.OFF,
Attribute.SOURCE: m2,
Attribute.SECS: 2
},
{
Attribute.COMMAND: Command.ON,
Attribute.MAPPED: Command.OFF,
Attribute.SOURCE: m1,
Attribute.SECS: 10
},
),
initial=State.OFF,
)
self.assertEqual(l.state, State.OFF)
m1.motion()
self.assertEqual(l.state, State.ON)
# Interface updates us on the status
l.command(command=Command.ON, source=interface)
# call still just to add some noise. Should be ignored
m1.still()
self.assertEqual(l.state, State.ON)
time.sleep(2)
# Light should still be on < 10 secs
self.assertEqual(l.state, State.ON)
m2.motion()
self.assertEqual(l.state, State.ON)
# more noise to try and force an issue. Should be ignored
m2.still()
m1.still()
self.assertEqual(l.state, State.ON)
time.sleep(3)
# total of 5 secs have elapsed since m1 and 3 since m2
# Light should be off as m2 set the new time to only 2 secs
self.assertEqual(l.state, State.OFF)