def updateDirectory(message): """Update the local directory with information about this device""" now = time.time() header = message["header"] sensorId = header["sensorid"] if not directory.has_key(sensorId): # new device discovered desc = Devices.getDescription(header["mfrid"], header["productid"]) print("ADD device:%s %s" % (hex(sensorId), desc)) directory[sensorId] = {"header": message["header"]} print(allkeys(directory)) directory[sensorId]["time"] = now
def updateDirectory(message): """Update the local directory with information about this device""" now = time.time() header = message["header"] sensorId = header["sensorid"] if not directory.has_key(sensorId): # new device discovered desc = Devices.getDescription(header["mfrid"], header["productid"]) print("ADD device:%s %s" % (hex(sensorId), desc)) directory[sensorId] = {"header": message["header"]} print(allkeys(directory)) directory[sensorId]["time"] = now
def updateDirectory(self, message): '''Update the local directory with information about this device''' now = time.time() header = message["header"] sensorId = header["sensorid"] if not self.directory.has_key(sensorId): # new device discovered desc = Devices.getDescription(header["mfrid"], header["productid"]) self.logger.info("ADD device:%s %s" % (hex(sensorId), desc)) self.directory[sensorId] = {"header": message["header"]} self.logger.info(self.allkeys(self.directory)) self.directory[sensorId]["time"] = now
def updateDirectory(self, message): '''Update the local directory with information about this device''' now = time.time() header = message["header"] sensorId = header["sensorid"] if not self.directory.has_key(sensorId): # new device discovered desc = Devices.getDescription(header["mfrid"], header["productid"]) self.logger.debug("ADD device:%s %s" % (hex(sensorId), desc)) self.directory[sensorId] = {"header": message["header"]} self.logger.debug(self.allkeys(self.directory)) self.directory[sensorId]["time"] = now
def updateDirectory(message): # Add the data from the most recent message into our storage directory. header = message['header'] mfrid = header['mfrid'] productid = header['productid'] sensorid = header['sensorid'] deviceID = "OT_%s-%s-%s" % (mfrid, productid, sensorid) if not directory.has_key(deviceID): directory[deviceID] = {} directory[deviceID]['Description'] = Devices.getDescription(header["mfrid"], header["productid"]) directory[deviceID]["time"] = int(time.time()) directory[deviceID]["data"] = getData(message) directory["__META"]["time"] = directory[deviceID]["time"]
def test_getDescription(self): self.assertEqual("Manufactuer:Energenie Product:C1 MONITOR", Devices.getDescription(0x04,0x01)) self.assertEqual("Manufactuer:Energenie Product:R1 MONITOR/CONTROL", Devices.getDescription(0x04,0x02)) self.assertEqual("Manufactuer:Energenie Product:eTRV", Devices.getDescription(0x04,0x03)) self.assertEqual("Manufactuer:Energenie Product:UNKNOWN", Devices.getDescription(0x04,0xff)) self.assertEqual("Manufactuer:UNKNOWN Product:UNKNOWN", Devices.getDescription(0xff,0x03), "Product ID should be manufacturer specific")