def getSwitchValue(self): time.sleep(1) while True: packet = self._switchQueue.get(block=True) if not (COMMAND_TO_ENUM_MAP[packet.command] != packet.command): continue break bytes = _getBytesFromData(packet) return bytes[0]
def getDeviceInfo(self): packet = self._getPacket(Command.INFO) if not packet: return None bytes = _getBytesFromData(packet) deviceinfo = DeviceInfo(); DeviceInfo.manufacturer=_bytes_to_int(bytes, 2, 0) DeviceInfo.product_type=_bytes_to_int(bytes, 2, 2) DeviceInfo.product_id=_bytes_to_int(bytes, 2, 4) DeviceInfo.role=_bytes_to_int(bytes, 1, 6) return DeviceInfo
def setSensor(self, type, precision, scale, value): data = bytearray(8) data[0] = type data[1] = precision data[2] = scale _int_to_bytes(data, 3, value) data = data[0 : 8 - (4 - data[3])] packet = self._getPacket(Command.SET_SENSOR, data) if not packet: return False bytes = _getBytesFromData(packet) return bytes[0] == 1
def setDeviceRole(self, role): packet = self._getPacket(Command.ROLE, role) if not packet: return False bytes = _getBytesFromData(packet) return bytes[0] == GENERIC_TYPES.GENERIC_TYPE_SWITCH_MULTILEVEL