Beispiel #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)
Beispiel #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()
Beispiel #3
0
 def serial(self, value):
     self._serial = value
     self._serialAsBytes = Convert.intToBytes(value,
                                              byteorder="little",
                                              length=4)
Beispiel #4
0
 def generate(data):
     crcData = bytes(data[3:-3])
     crc = Crc.calc(crcData)
     data[-3:-1] = Convert.intToBytes(crc)
     return data
Beispiel #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)