當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。