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


Python devices.Light类代码示例

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


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

示例1: test_delay_normal

    def test_delay_normal(self):
        # Door Open events retrigger delay
        # Instead of turning off in 2 secs should be 4
        door = Door()
        self.assertIsNotNone(door)
        light = Light(address='D1', 
                      devices=(self.interface, door),
                      delay={
                             'command': Command.OFF,
                             'secs': 3,
                             'source': door}
                       )
        door.open()
        self.assertEqual(light.state, State.ON)
        door.close()
        self.assertEqual(light.state, State.ON)
        time.sleep(2)
        self.assertEqual(light.state, State.ON)
        time.sleep(2)
        self.assertEqual(light.state, State.OFF)

        # Check to see if we can immediately and directly still turn off
        light.off()
        door.open()
        self.assertEqual(light.state, State.ON)
        light.off()
        self.assertEqual(light.state, State.OFF)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:27,代码来源:light.py

示例2: test_device_level_encoded

 def test_device_level_encoded(self):
     d=Light(name='device_test_1')
     d.off()
     self.assertEqual(d.state, State.OFF)
     response = self.api.get_response(method='POST', path="device/" + str(d.type_id), data=['command=level%2C72'])
     self.assertEqual(d.state, (State.LEVEL, 72))
     self.assertTrue('"name": "device_test_1"' in response)
开发者ID:E3Dev,项目名称:pytomation,代码行数:7,代码来源:pytomation_api.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_time_cron2

 def test_time_cron2(self):
     ttime = datetime.now().timetuple()[3:7]
     l = Light(address='12.03.BB',
                 time={
                 Attribute.TIME: (ttime[2]+2,ttime[1], ttime[0], '*','*','*'),
                 Attribute.COMMAND: Command.OFF
                 },
                 name='test')
     l.on()
     self.assertEqual(l.state, State.ON)
     time.sleep(2)
     self.assertEqual(l.state, State.OFF)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:12,代码来源:light.py

示例5: 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

示例6: test_scenario_g2

 def test_scenario_g2(self):
     d = StateDevice()
     l = Light(address='1E.39.5C', 
            devices=(d),
            delay={
                Attribute.COMMAND: Command.OFF,
                Attribute.SECS: 2
                },
            name='Stair Lights up')
     self.assertEqual(l.state, State.UNKNOWN)
     l.off()
     time.sleep(3)
     self.assertEqual(l.state, State.OFF)
     l.on()
     self.assertEqual(l.state, State.ON)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:15,代码来源:light.py

示例7: 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

示例8: test_read_only

 def test_read_only(self):
     self.loc.local_time = datetime(2012,6,1,0,0,0)
     self.assertEqual(self.loc.state, State.DARK)
     l2 = Light()
     l = Light(devices=(self.loc, l2))
     self.assertEqual(self.loc.state, State.DARK)
     l.on()
     self.assertEqual(l.state, State.ON)
     self.assertEqual(self.loc.state, State.DARK)
     l.off()
     self.assertEqual(self.loc.state, State.DARK)
     l2.off()
     self.assertEqual(self.loc.state, State.DARK)
     l2.on()
     self.assertEqual(self.loc.state, State.DARK)
开发者ID:E3Dev,项目名称:pytomation,代码行数:15,代码来源:location.py

示例9: test_light_scenario_g3

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

示例10: 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

示例11: 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

示例12: test_light_scenario_g1

 def test_light_scenario_g1(self):
     d = Door()
     p = Photocell()
     p.light()
     l =  Light(address='xx.xx.xx', 
         devices=(d, p),
         mapped={
            Attribute.COMMAND: (Command.CLOSE),
            Attribute.MAPPED: Command.OFF,
            Attribute.SECS: 2,
         },
         ignore=({Attribute.COMMAND: Command.DARK}),
         name="Hallway Lights",)
     l.on()
     self.assertEqual(l.state, State.ON)
     d.close()
     self.assertEqual(l.state, State.ON)
     time.sleep(3)
     self.assertEqual(l.state, State.OFF)
     d.open()
     self.assertEqual(l.state, State.OFF)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:21,代码来源:light.py

示例13: test_door_closed

    def test_door_closed(self):
        door = Door()
        self.assertIsNotNone(door)
        door.open()
        self.device = Light('D1', devices=(self.interface, door))
#        self.assertTrue(self.interface.initial.called)
        self.assertFalse(self.interface.off.called)
        door.close()
        self.assertTrue(self.interface.off.called)
#        self.interface.on.assert_called_once_with('')
        door.open()
        self.assertTrue(self.interface.on.called)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:12,代码来源:light.py

示例14: test_trigger_in_range_gc

    def test_trigger_in_range_gc(self):
        (s_h, s_m, s_s) = datetime.now().timetuple()[3:6]
        e_h = s_h
        e_m = s_m
        e_s = s_s + 2
        d1 = StateDevice()
        d2 = Light(
                   devices=d1,
                   trigger={
                            Attribute.COMMAND: Command.ON,
                            Attribute.MAPPED: Command.OFF,
                            Attribute.SECS: 2,
                            Attribute.START: '{h}:{m}:{s}'.format(
                                                                 h=s_h,
                                                                 m=s_m,
                                                                 s=s_s,
                                                                 ),
                            Attribute.END: '{h}:{m}:{s}'.format(
                                                                 h=e_h,
                                                                 m=e_m,
                                                                 s=e_s,
                                                                 ),
                            }
                   )
        self.assertEqual(d2.state, State.UNKNOWN)
        d1.on()
        self.assertEqual(d2.state, State.ON)
        time.sleep(3)
        self.assertEqual(d2.state, State.OFF)
 
        #Out range
        d2.off()
        self.assertEqual(d2.state, State.OFF)
        d1.on()
        self.assertEqual(d2.state, State.ON)
        time.sleep(3)
        self.assertEqual(d2.state, State.ON)
开发者ID:E3Dev,项目名称:pytomation,代码行数:37,代码来源:light.py

示例15: test_ignore_subcommand_wildcard

 def test_ignore_subcommand_wildcard(self):
     s1 = Light()
     s2 = Light(devices = s1,
                       ignore={
                               Attribute.COMMAND: Command.LEVEL,
                               },
                       )
     s1.on()
     self.assertEqual(s2.state, State.ON)
     s1.off()
     self.assertEqual(s2.state, State.OFF)
     s1.level(80)
     self.assertEqual(s2.state, State.OFF)
开发者ID:E3Dev,项目名称:pytomation,代码行数:13,代码来源:light.py


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