本文整理汇总了Python中pytomation.devices.Motion.motion方法的典型用法代码示例。如果您正苦于以下问题:Python Motion.motion方法的具体用法?Python Motion.motion怎么用?Python Motion.motion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytomation.devices.Motion
的用法示例。
在下文中一共展示了Motion.motion方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_motion_triggered
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_motion_triggered(self):
motion = Motion('D1', initial=State.STILL)
self.assertEqual(motion.state, State.STILL)
light = Light('D1', devices=motion)
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.ON)
示例2: test_motion_triggered
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_motion_triggered(self):
motion = Motion("D1", initial_state=State.STILL)
self.assertEqual(motion.state, State.STILL)
light = Light("D1", motion)
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.ON)
示例3: test_light_scenario_2
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_light_scenario_2(self):
m = Motion()
l = Light(
address=(49, 3),
devices=(m),
ignore=({
Attribute.COMMAND: Command.DARK,
},
{
Attribute.COMMAND: Command.STILL}
),
time={
Attribute.TIME: '11:59pm',
Attribute.COMMAND: Command.OFF
},
mapped={
Attribute.COMMAND: (
Command.MOTION, Command.OPEN,
Command.CLOSE, Command.LIGHT,
),
Attribute.MAPPED: Command.OFF,
Attribute.SECS: 2,
},
name='Foyer Light',
)
l.off()
self.assertEqual(l.state, State.OFF)
m.motion()
self.assertEqual(l.state, State.OFF)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例4: test_room_to_room_vacate
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_room_to_room_vacate(self):
m1 = Motion(name="m1")
m2 = Motion(name="m2")
m3 = Motion(name="m3")
r1 = Room(name="r1", devices=m1)
r2 = Room(name="r2", devices=(m2, r1))
r3 = Room(name="r3", devices=(m3, r2))
r1.add_device(r2)
r2.add_device(r3)
m1.motion()
self.assertEqual(r1.state, State.OCCUPIED)
self.assertEqual(r2.state, State.VACANT)
self.assertEqual(r3.state, State.UNKNOWN)
m2.motion()
self.assertEqual(r1.state, State.VACANT)
self.assertEqual(r2.state, State.OCCUPIED)
self.assertEqual(r3.state, State.VACANT)
m3.motion()
self.assertEqual(r1.state, State.VACANT)
self.assertEqual(r2.state, State.VACANT)
self.assertEqual(r3.state, State.OCCUPIED)
m1.motion()
self.assertEqual(r1.state, State.OCCUPIED)
self.assertEqual(r2.state, State.VACANT)
self.assertEqual(r3.state, State.OCCUPIED)
m2.motion()
self.assertEqual(r1.state, State.VACANT)
self.assertEqual(r2.state, State.OCCUPIED)
self.assertEqual(r3.state, State.VACANT)
示例5: test_room_occupied
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_room_occupied(self):
m = Motion()
r = Room(devices=m)
r.vacate()
self.assertEqual(r.state, State.VACANT)
m.motion()
self.assertEqual(r.state, State.OCCUPIED)
示例6: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [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)
示例7: test_light_unrestricted
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_light_unrestricted(self):
photo = Photocell('D1', initial=State.LIGHT)
self.assertEqual(photo.state, State.LIGHT)
motion = Motion('D1', initial=State.STILL)
light = Light('D2', devices=(motion, photo),
initial=photo)
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.OFF)
motion.unrestricted = True
motion.motion()
self.assertEqual(light.state, State.ON)
示例8: test_light_restricted
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_light_restricted(self):
photo = Photocell("D1", initial_state=State.LIGHT)
motion = Motion("D1", initial_state=State.STILL)
light = Light("D2", (motion, photo))
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.OFF)
photo.dark()
self.assertEqual(light.state, State.ON)
light.off()
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.ON)
示例9: test_light_scenario_g3
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [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)
示例10: test_light_restriction_idle
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [as 别名]
def test_light_restriction_idle(self):
ph = Photocell()
m = Motion()
ph.dark()
l = Light(
devices=(ph, m),
idle={Attribute.MAPPED: (Command.LEVEL, 30),
Attribute.SECS: 2,
}
)
m.motion()
self.assertEqual(l.state, State.ON)
ph.light()
self.assertEqual(l.state, State.OFF)
m.motion()
self.assertEqual(l.state, State.OFF)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例11: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [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)
示例12: test_delay_light_specific
# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import motion [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)