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


Python Light.level方法代码示例

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


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

示例1: test_ignore_subcommand_wildcard

# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import level [as 别名]
 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,代码行数:15,代码来源:light.py

示例2: LightTests

# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import level [as 别名]

#.........这里部分代码省略.........
        motion.still()
        self.assertEqual(light.state, State.ON)
        time.sleep(1)
        self.assertEqual(light.state, State.OFF)

    def test_light_photocell_intial(self):
        motion = Motion()
        motion.still()
        photo = Photocell(address='asdf')
        photo.dark()
        light = Light(address='e3',
                      devices=(photo, motion),
                      initial=photo,
                      )
        self.assertEqual(light.state, State.ON)
        
    def test_light_photocell_delay(self):
        ## Dont like this behavior anymore
        # Delay off should not trigger when photocell tells us to go dark.
        # Do it immediately
#        photo = Photocell()
#        photo.dark()
#        light = Light(address='e3',
#                      devices=photo,
#                      delay={
#                             'command': Command.OFF,
#                             'secs': 3
#                             })
#        self.assertEqual(light.state, State.ON)
#        photo.light()
#        self.assertEqual(light.state, State.OFF)
        pass
    
    def test_level(self):
        self.device.command((Command.LEVEL, 40))
        self.interface.level.assert_called_with('D1', 40)
        
    def test_level_direct(self):
        self.device.level(50)
        self.interface.level.assert_called_with('D1', 50)
        
    def test_level_ramp(self):
        self.device.command((Command.LEVEL, 40, 20))
        self.interface.level.assert_called_with('D1', 40, 20)


    def test_time_cron(self):
        light = Light('a2',
                      time={
                            Attribute.COMMAND: Command.OFF,
                            Attribute.TIME:(0, 30, range(0,5), 0, 0)
                            })
        self.assertIsNotNone(light)
        
    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:E3Dev,项目名称:pytomation,代码行数:70,代码来源:light.py


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