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


Python devices.Motion类代码示例

本文整理汇总了Python中pytomation.devices.Motion的典型用法代码示例。如果您正苦于以下问题:Python Motion类的具体用法?Python Motion怎么用?Python Motion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Motion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_light_photocell_intial

 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)
开发者ID:ssteinerx,项目名称:pytomation,代码行数:7,代码来源:light.py

示例2: test_room_occupied

 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)
开发者ID:aashir789,项目名称:pytomation,代码行数:7,代码来源:room.py

示例3: test_light_scenario_2

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:31,代码来源:light.py

示例4: test_motion_triggered

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:7,代码来源:light.py

示例5: test_motion_triggered

 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)
开发者ID:ssteinerx,项目名称:pytomation,代码行数:7,代码来源:light.py

示例6: test_delay_light_specific

 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)
开发者ID:ssteinerx,项目名称:pytomation,代码行数:11,代码来源:light.py

示例7: test_light_restricted

 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)
开发者ID:ssteinerx,项目名称:pytomation,代码行数:13,代码来源:light.py

示例8: test_motion_delay_from_interface

 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)
开发者ID:E3Dev,项目名称:pytomation,代码行数:13,代码来源:motion.py

示例9: test_light_restricted

 def test_light_restricted(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)
     photo.dark()
     self.assertEqual(light.state, State.ON)
     light.off()
     self.assertEqual(light.state, State.OFF)
     motion.motion()
     self.assertEqual(light.state, State.ON)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:15,代码来源:light.py

示例10: test_delay_non_native_command

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:15,代码来源:light.py

示例11: test_light_restriction_idle

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:18,代码来源:light.py

示例12: test_light_idle

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:18,代码来源:light.py

示例13: test_motion_ignore

    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)
开发者ID:kengle3,项目名称:pytomation,代码行数:11,代码来源:motion.py

示例14: test_motion_ignore

    def test_motion_ignore(self):
        self.device = Motion('D1', devices=(self.interface), ignore_off=True)
        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)

        # Make sure we can turn ignore off
        self.device.ignore_off(False)
        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.STILL)        
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:11,代码来源:motion.py

示例15: test_light_scenario1

 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)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:21,代码来源:light.py


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