def reloadConfig(self, bootup=False): #load known sensors from file for k, v in self.config.items("childIds"): value = v.split(';') self.childIdLookupTable[value[0] + ";" + value[1]] = k self.availableIds[int(value[0])] = False #load unit M/I from file (A good programmer should check input values) self.unit = self.config.get('config', 'unit') #load InclutionMode from file and send it to gateway(A good programmer should check input values...) self.InclutionMode = self.config.get('config', 'inclusion-mode') #at bootup this is executed from init if bootup is False: self.setInclutionMode(self.InclutionMode) #initiate integrations #Openhab if self.config.get('config', 'openhab') == 'true': if self.oh is None: self.oh = Openhab(self.config, self.log) else: self.oh.reloadConfig() else: self.oh = None #Domoticz if self.config.get('config', 'domoticz') == 'true': if self.dom is None: self.dom = Domoticz(self.config, self.log) else: self.dom.reloadConfig() else: self.dom = None #RRD if self.config.get('config', 'rrd') == 'true': if self.rrd is None: self.rrd = Rrd(self.config, self.log) else: self.rrd.reloadConfig() else: self.rrd = None self.log.info("reloadConfig: Configuration reloaded.")
def requestStatus(self, incomingData, childId, altId): self.log.debug("Requesting status for: " + altId) #A device request its current status from msgw (when staring up) index = int(incomingData[3]) varType = self.tVarLookupNumType[index] #Requested variable value from one of the sensors variable = self.tVarTypes[varType] if (variable[2] is not None and childId is not None): value = None self.log.debug("Request status for " + variable[2]) #openhab if self.config.has_option('openhab', childId) and self.oh is not None: oh = Openhab(self.config, self.log) value = self.oh.requestStatus(incomingData, childId, altId) #support others here like Domoticz #Get default if there is none in the external system if value is None: self.sendRequestResponse(altId, varType, variable[3]) else: self.sendRequestResponse(altId, varType, value)