• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python devices.Motion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_delay_light_specific

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


示例17: test_delay_light_specific

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


示例18: test_motion_retrigger

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


示例19: MotionTests

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


示例20: test_motion_on

 def test_motion_on(self):
     m = Motion()
     m.command(command=Command.ON, source=None)
     self.assertEqual(m.state, State.MOTION)        
开发者ID:kengle3,项目名称:pytomation,代码行数:4,代码来源:motion.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python devices.StateDevice类代码示例发布时间:2022-05-27
下一篇:
Python devices.Light类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap