def write_parameter(self, type, value, options): if type == ParameterType.UINT8: self.write(value) elif type == ParameterType.UINT16: self.write(value, 2) elif type == ParameterType.UINT32: self.write(value, 4) elif type == ParameterType.IEEEADDR: if isinstance(value, Iterable): for i in value: self.write(i) else: self.write(value, 8) elif type == ParameterType.BUFFER: self.buffer += value elif type == ParameterType.LIST_UINT8: for v in value: self.write(v) elif type == ParameterType.LIST_UINT16: for v in value: self.write(v, 2) elif type == ParameterType.LIST_NEIGHBOR_LQI: for v in value: self.write_neighbor_lqi(v) else: raise TODO("write %s, value: %s, options: %s", ParameterType(type), value, options)
def read_parameter(self, type, options): if type == ParameterType.UINT8: res = self.read_int() elif type == ParameterType.UINT16: res = self.read_int(2) if options.is_address: res = zigpy.types.NWK(res) elif type == ParameterType.UINT32: res = self.read_int(4) elif type == ParameterType.IEEEADDR: res = zigpy.types.EUI64(self.read(8)) elif type == ParameterType.BUFFER: length = options.length res = self.read(length) else: # list types res = [] if type == ParameterType.LIST_UINT8: for i in range(0, options.length): res.append(self.read_int()) elif type == ParameterType.LIST_UINT16: for i in range(0, options.length): res.append(self.read_int(2)) elif type == ParameterType.LIST_UINT32: for i in range(0, options.length): res.append(self.read_int(4)) else: raise TODO("read %s", ParameterType(type)) return res
def read_parameter(self, type, options): if type == ParameterType.UINT8: res = self.read_int() elif type == ParameterType.UINT16: res = self.read_int(2) if options.is_address: res = zigpy.types.NWK(res) elif type == ParameterType.UINT32: res = self.read_int(4) elif type == ParameterType.IEEEADDR: res = self.read_ieee_addr() elif ParameterType.is_buffer(type): type_name = ParameterType(type).name length = int(type_name.replace("BUFFER", "") or options.length) res = self.read(length) elif type == ParameterType.INT8: res = self.read_int(signed=True) else: # list types res = [] if type == ParameterType.LIST_UINT8: for i in range(0, options.length): res.append(self.read_int()) elif type == ParameterType.LIST_UINT16: for i in range(0, options.length): res.append(self.read_int(2)) elif type == ParameterType.LIST_NEIGHBOR_LQI: for i in range(0, options.length): res.append(self.read_neighbor_lqi()) else: raise TODO("read type %d", type) return res
def write_parameter(self, type, value, options): if type == ParameterType.UINT8: self.write(value) elif type == ParameterType.UINT16: self.write(value, 2) elif type == ParameterType.UINT32: self.write(value, 4) elif type == ParameterType.IEEEADDR: for i in value: self.write(i) elif type == ParameterType.BUFFER: self.buffer += value elif type == ParameterType.LIST_UINT8: for v in value: self.write(v) elif type == ParameterType.LIST_UINT16: for v in value: self.write(v, 2) else: raise TODO("write %s", ParameterType(type))
async def permit_with_key(self, node, code, time_s=60): raise TODO("permit_with_key")
async def Restore(znp, backupPath, options): raise TODO("Restore")