本文整理匯總了Python中pytomation.devices.Motion.command方法的典型用法代碼示例。如果您正苦於以下問題:Python Motion.command方法的具體用法?Python Motion.command怎麽用?Python Motion.command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pytomation.devices.Motion
的用法示例。
在下文中一共展示了Motion.command方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_motion_delay_from_interface
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
def test_motion_delay_from_interface(self):
i = Mock()
m = Motion(devices=i,
delay={
Attribute.COMMAND: Command.STILL,
Attribute.SECS: 2,
})
m.command(command=Command.MOTION, source=i)
self.assertEqual(m.state, State.MOTION)
m.command(command=Command.STILL, source=i)
self.assertEqual(m.state, State.MOTION)
time.sleep(3)
self.assertEqual(m.state, State.STILL)
示例2: test_light_scenario1
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
def test_light_scenario1(self):
m = Motion()
l = Light(
address=(49, 6),
devices=m,
mapped={
Attribute.COMMAND: Command.MOTION,
Attribute.SECS: 30*60
},
ignore=({
Attribute.COMMAND: Command.STILL
},
{
Attribute.COMMAND: Command.DARK
},
),
name='Lamp',
)
self.assertEqual(l.state, State.UNKNOWN)
m.command(command=State.ON, source=None)
self.assertEqual(l.state, State.UNKNOWN)
示例3: MotionTests
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
class MotionTests(TestCase):
def setUp(self):
self.interface = Mock()
self.interface.state = State.UNKNOWN
self.device = Motion('D1', self.interface)
def test_instantiation(self):
self.assertIsNotNone(self.device,
'Motion Device could not be instantiated')
def test_motion_motion(self):
self.assertEqual(self.device.state, State.UNKNOWN)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.ON)
self.assertEqual(self.device.state, State.MOTION)
# self.device._on_command('D1', State.OFF)
self.device.command(Command.STILL, source=self.interface)
self.assertEqual(self.device.state, State.STILL)
def test_motion_ignore(self):
self.device = Motion('D1', devices=(self.interface), ignore={
'command': Command.STILL,
},
)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.ON, self.interface)
self.assertEqual(self.device.state, State.MOTION)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.OFF, self.interface)
self.assertEqual(self.device.state, State.MOTION)
def test_motion_on(self):
m = Motion()
m.command(command=Command.ON, source=None)
self.assertEqual(m.state, State.MOTION)
示例4: test_motion_retrigger
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
def test_motion_retrigger(self):
i = Mock()
m = Motion(devices=i,
retrigger_delay={
Attribute.SECS: 2,
},
)
s = Light(devices=m)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.OFF)
time.sleep(3)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)
示例5: test_motion_on
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
def test_motion_on(self):
m = Motion()
m.command(command=Command.ON, source=None)
self.assertEqual(m.state, State.MOTION)
示例6: MotionTests
# 需要導入模塊: from pytomation.devices import Motion [as 別名]
# 或者: from pytomation.devices.Motion import command [as 別名]
class MotionTests(TestCase):
def setUp(self):
self.interface = Mock()
self.interface.state = State.UNKNOWN
self.device = Motion('D1', self.interface)
def test_instantiation(self):
self.assertIsNotNone(self.device,
'Motion Device could not be instantiated')
def test_motion_motion(self):
self.assertEqual(self.device.state, State.UNKNOWN)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.ON)
self.assertEqual(self.device.state, State.MOTION)
# self.device._on_command('D1', State.OFF)
self.device.command(Command.STILL, source=self.interface)
self.assertEqual(self.device.state, State.STILL)
def test_motion_ignore(self):
self.device = Motion('D1', devices=(self.interface), ignore={
'command': Command.STILL,
},
)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.ON, self.interface)
self.assertEqual(self.device.state, State.MOTION)
self.device.command(Command.MOTION, source=self.interface)
# self.device._on_command('D1', State.OFF, self.interface)
self.assertEqual(self.device.state, State.MOTION)
def test_motion_on(self):
m = Motion()
m.command(command=Command.ON, source=None)
self.assertEqual(m.state, State.MOTION)
def test_motion_delay_from_interface(self):
i = Mock()
m = Motion(devices=i,
delay={
Attribute.COMMAND: Command.STILL,
Attribute.SECS: 2,
})
m.command(command=Command.MOTION, source=i)
self.assertEqual(m.state, State.MOTION)
m.command(command=Command.STILL, source=i)
self.assertEqual(m.state, State.MOTION)
time.sleep(3)
self.assertEqual(m.state, State.STILL)
def test_motion_retrigger(self):
i = Mock()
m = Motion(devices=i,
retrigger_delay={
Attribute.SECS: 2,
},
)
s = Light(devices=m)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.OFF)
time.sleep(3)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)