コード例 #1
0
 def switches(self, switchesConfig):
     for switchConfig in switchesConfig:
         switch = Switch(self)
         if type(switchConfig) == dict or type(switchConfig) == OrderedDict:
             serial = switchConfig['serial']
             name = switchConfig['name'] or 'switch-' + str(serial)
         elif type(switchConfig) == int:
             serial = switchConfig
             name = 'switch-' + str(serial)
         switch._name = name
         switch._serial = serial
         switch._serialAsBytes = Convert.intToBytes(serial,
                                                    byteorder='little',
                                                    length=4)
         self._appendDevice(switch)
コード例 #2
0
 def lights(self, lightsConfig):
     for lightConfig in lightsConfig:
         light = Light(self)
         if type(lightConfig) == dict or type(lightConfig) == OrderedDict:
             serial = lightConfig['serial']
             name = lightConfig['name'] or 'lamp-' + str(serial)
         elif type(lightConfig) == int:
             serial = lightConfig
             name = 'lamp-' + str(serial)
         light._name = name
         light._serial = serial
         light._serialAsBytes = Convert.intToBytes(serial,
                                                   byteorder='little',
                                                   length=4)
         self._appendDevice(light)
         light.requestState()
コード例 #3
0
ファイル: devices.py プロジェクト: pierniq/pyXcomfort
 def serial(self, value):
     self._serial = value
     self._serialAsBytes = Convert.intToBytes(value,
                                              byteorder="little",
                                              length=4)
コード例 #4
0
ファイル: crc.py プロジェクト: kedMertens/pyXcomfort
 def generate(data):
     crcData = bytes(data[3:-3])
     crc = Crc.calc(crcData)
     data[-3:-1] = Convert.intToBytes(crc)
     return data
コード例 #5
0
 def setBrightness(self, serial, brightness):
     if brightness > 1:
         command = Convert.intToBytes(brightness, length=1)
         self._sendDimCommand(serial, command)
     else:
         self.setState(serial, False)