def __init__( self, address=None, username=None, password=None, homie_settings=HOMIE_SETTINGS, mqtt_settings=None, log_settings=LOG_SETTINGS, ): if log_settings is not None and log_settings['enable'] is True: logging.basicConfig(level=log_settings['level'], handlers=[file_handler, console_handler]) logger.info("ISY Homie MQTT {}".format(mqtt_settings)) self.homie_settings = homie_settings self.mqtt_settings = mqtt_settings self.controller = Controller( address=address, port=None, username=username, password=password, use_https=False, event_handler=self._isy_event_handler, )
def __init__(self, address=None, username=None, password=None, homie_settings=HOMIE_SETTINGS, mqtt_settings=None): logger.debug('ISY Homie MQTT {}'.format (mqtt_settings)) self.homie_settings = homie_settings self.mqtt_settings = mqtt_settings self.controller = Controller(address=address,port=None,username=username,password=password,use_https=False,event_handler=self._isy_event_handler)
dimmer = None def isy_event_handler(container, item, event, *args): print('Event {} from {}: {} {}'.format(event, container.container_type, item.name, *args)) if container.container_type == 'Device' and event == 'add' and item.address == dimmer_address: global dimmer #dimmer = item try: c = Controller(url, username='******', password='******', use_https=False, event_handler=isy_event_handler) while True: if dimmer is not None: dimmer.set_level(0) time.sleep(2) if dimmer is not None: dimmer.set_level(100) except KeyboardInterrupt: print("KeyboardInterrupt has been caught.")