def setup(self): # class definition of setup() just sets logger from poly object self.logger = self.poly.logger # get controller information from configuration file try: controllerSettings = self.poly.nodeserver_config["controller"] ip = controllerSettings["ipaddress"] username = controllerSettings["username"] password = controllerSettings["password"] except KeyError: self.logger.error( "Missing controller settings in config.yaml file") raise # get polling intervals and configuration settings from configuration file if "configuration" in self.poly.nodeserver_config: config = self.poly.nodeserver_config["configuration"] if "pollinginterval" in config: self.pollingInterval = config["pollinginterval"] if "ignoresolar" in config: self.ignoresolar = config["ignoresolar"] # create a object for the autelis interface self.autelis = autelisapi.AutelisInterface(ip, username, password, self.logger) # setup the nodes from the autelis pool controller self.update_node_states(True) # Report driver values self.lastPoll = time.time() # save config in case new devices were added self.update_config(True)
def start(self): _LOGGER.info("Started Autelis Nodeserver...") # get controller information from custom parameters try: customParams = self.poly.config["customParams"] ip = customParams["ipaddress"] username = customParams["username"] password = customParams["password"] except KeyError: _LOGGER.error("Missing controller settings in configuration.") raise # get polling intervals and configuration settings from custom parameters try: self.pollingInterval = int(customParams["pollinginterval"]) except (KeyError, ValueError): self.pollingInterval = 60 try: self.ignoresolar = bool(customParams["ignoresolar"]) except (KeyError, ValueError): self.ignoresolar = False # dump the self._nodes to the log #_LOGGER.debug("Current Node Configuration: %s", str(self._nodes)) # create a object for the autelis interface self.autelis = autelisapi.AutelisInterface(ip, username, password, _LOGGER) # setup the nodes from the autelis pool controller self.discover_nodes()
def _api_start(self): # create a object for the autelis interface self._logger.info("Starting Autelis api...") try: self.autelis = False # This means we are trying self.autelis = autelisapi.AutelisInterface(self.ip, self.username, self.password, _LOGGER) except (Exception) as err: self.autelis = None # We tried and failed self._logger.error('Unknown error starting api: {}'.format(err), exc_info=True) raise self._logger.info("Started Autelis api {}".format(self.autelis)) # setup the nodes from the autelis pool controller self.discover_nodes() self._monitor_thread()
def start(self): _LOGGER.info("Started Autelis Nodeserver...") # get controller information from custom parameters try: customParams = self.poly.config["customParams"] ip = customParams["ipaddress"] username = customParams["username"] password = customParams["password"] except KeyError: _LOGGER.error("Missing controller settings in configuration.") raise # get polling intervals and configuration settings from custom parameters try: self.pollingInterval = int(customParams["pollinginterval"]) except (KeyError, ValueError): self.pollingInterval = 60 try: self.ignoresolar = bool(customParams["ignoresolar"]) except (KeyError, ValueError): self.ignoresolar = False # create a object for the autelis interface self.autelis = autelisapi.AutelisInterface(ip, username, password, _LOGGER) # setup the nodes from the autelis pool controller self.discover_nodes() # setup a thread for monitoring status updates from the Pool Controller self.threadMonitor = threading.Thread( target=autelisapi.status_listener, args=(ip, self.set_node_state, _LOGGER)) self.threadMonitor.daemon = True self.threadMonitor.start()