Exemplo n.º 1
0
    def parseSensor(data, device):
        value = Convert.bytesToDecimal(data[21:22])
        state = Convert.bytesToInt(data[24:25]) == 255
        device.value = value
        device.state = state

        return device
Exemplo n.º 2
0
    def parseSensor(self, data, device):
        value = Convert.bytesToDecimal(data[21:22])
        state = Convert.bytesToInt(data[24:25]) == 255
        device._state = state
        device._value = value
        device._runCallbacks()

        return device
Exemplo n.º 3
0
    def parseLight(data, device):
        stateValue = Convert.bytesToInt(data[22:23])
        state = True

        if stateValue == 3:
            device.isDimable = False

        if stateValue < 3:
            state = False

        device.silentBrightness = stateValue
        device.silentState = state

        return device
Exemplo n.º 4
0
    def parseLight(self, data, device):
        stateValue = Convert.bytesToInt(data[22:23])
        state = True

        if (stateValue == 3):
            device._isDimable = False

        if stateValue < 3:
            state = False

        device._state = state
        device._brightness = stateValue
        device._runCallbacks()
        return device
Exemplo n.º 5
0
    def parseSerial(byteArray, device):
        deviceType = type(device)

        if deviceType == Switch:
            serialAsBytes = byteArray[10:14]
        elif deviceType == Sensor:
            serialAsBytes = byteArray[15:19]
        elif deviceType == Light:
            serialAsBytes = byteArray[10:14]

        serial = Convert.bytesToInt(serialAsBytes, byteorder="big")
        # device.serialAsBytes = serialAsBytes
        device.serial = serial

        return device
Exemplo n.º 6
0
    def parseSerial(self, byteArray, device):
        deviceType = type(device)

        if deviceType == Switch:
            bytes = byteArray[10:14]
        elif deviceType == Sensor:
            bytes = byteArray[15:19]
        elif deviceType == Light:
            bytes = byteArray[10:14]

        serial = Convert.bytesToInt(bytes, byteorder='big')
        device._serialAsBytes = bytes
        device._serial = serial

        return serial
Exemplo n.º 7
0
 def test_bytesToInt(self):
     data = bytearray(b"\xc5\xc4\x55\x00")
     ints = Convert.bytesToInt(data)
     self.assertEqual(5620933, ints)