def run(): global serverConfig global deviceConfig serverConfig = lethingaccesssdk.Config().getDriverInfo() deviceConfig = lethingaccesssdk.Config().getThingInfos() if "json" in serverConfig: if "opcServerList" in serverConfig["json"]: serverConfig = serverConfig["json"]["opcServerList"] else: return else: return if not opcdaUtil.checkOpcdaConfig(serverConfig, deviceConfig): _logger.warning("due to config %s is invalid, opcda driver will exit" % (lethingaccesssdk.getConfig())) return else: _logger.info("opcda driver starting...") opcda_monitor = OpcdaMonitor() for server in serverConfig: opcda_session = OpcdaSession(server, getDeviceConfigInServer(server)) opcda_monitor.addSession(opcda_session) while True: opcda_monitor.Monitor() opcda_monitor.destroySessions() _logger.warning("opcda driver exiting...") return
retDict['LightSwitch'] = self.light.isOn return 0, retDict def setProperties(self, input_value): if 'LightSwitch' in input_value: value = input_value['LightSwitch'] if value != self.light.isOn: self.light.isOn = value if (self._client): properties = {'LightSwitch': value} self._client.reportProperties(properties) return 0, {} else: return 100001, {} infos = lethingaccesssdk.Config().getThingInfos() for info in infos: print(info) try: light = Light() connector = Connector(info, light) connector.connect() except Exception as e: logging.error(e) # don't remove this function def handler(event, context): return 'hello world'