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
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
def test_bytesToDecimal(self): data = bytearray(b"\xd5") ints = Convert.bytesToDecimal(data) self.assertEqual(21.3, ints)