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