def main(arguments): """Execute primary loop.""" logging.basicConfig(format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT, level=LOG_LEVEL) # Test the connection to ISY controller. try: Connection( address=ADDRESS, port=PORT, username=USERNAME, password=PASSWORD, use_https=USE_HTTPS, tls_ver=TLS_VER, log=_LOGGER, webroot=WEBROOT, ) except ValueError as err: _LOGGER.error( "Failed to connect to the ISY, " "please adjust settings and try again. Error: \n%s", err.args[0], ) return _LOGGER.info("ISY connected! Connection properties valid, continuing.") # Actually connect to the ISY and download full configuration. isy = ISY( address=ADDRESS, port=PORT, username=USERNAME, password=PASSWORD, use_https=USE_HTTPS, tls_ver=TLS_VER, log=_LOGGER, webroot=WEBROOT, ) _LOGGER.info("ISY connected: %s", isy.connected) if not isy.connected: _LOGGER.error( "Failed to connect to the ISY, please adjust settings and try again." ) return # Print a representation of all the Nodes _LOGGER.debug(repr(isy.nodes)) # Get the rest of the detailed status information from the ISY # not originally reported. This includes statuses for all NodeServer nodes. isy.nodes.update() # Connect to the Event Stream and print events in the Debug Log. isy.auto_update = True try: while True: sleep(10) except KeyboardInterrupt: _LOGGER.warning("KeyboardInterrupt received. Disconnecting!") if isy.connected and isy.auto_update: isy.auto_update = False
def main(arguments): """Execute primary loop.""" fmt = "%(asctime)s %(levelname)s [%(name)s] %(message)s" datefmt = "%Y-%m-%d %H:%M:%S" logging.basicConfig(format=fmt, datefmt=datefmt, level=logging.DEBUG) # Test the connection to ISY controller. try: Connection( address=ADDRESS, port=PORT, username=USERNAME, password=PASSWORD, use_https=USE_HTTPS, tls_ver=TLS_VER, log=_LOGGER, webroot=WEBROOT, ) except ValueError as err: _LOGGER.error( "Failed to connect to the ISY, " "please adjust settings and try again. Error: \n%s", err.args[0], ) return _LOGGER.info("ISY connected! Connection properties valid, continuing.") # Actually connect to the ISY and download full configuration. isy = ISY( address=ADDRESS, port=PORT, username=USERNAME, password=PASSWORD, use_https=USE_HTTPS, tls_ver=TLS_VER, log=_LOGGER, webroot=WEBROOT, ) _LOGGER.info("ISY connected: %s", isy.connected) # Print a representation of all the Nodes _LOGGER.debug(repr(isy.nodes)) if isy.connected: # Connect to the Event Stream and print events in the Debug Log. isy.auto_update = True else: _LOGGER.error( "Failed to connect to the ISY, please adjust settings and try again." ) return try: while True: sleep(10) except KeyboardInterrupt: _LOGGER.warning("KeyboardInterrupt received. Disconnecting!") if isy.connected and isy.auto_update: isy.auto_update = False