def setup(hass, config): """ Setup the Verisure component. """ if not validate_config(config, {DOMAIN: [CONF_USERNAME, CONF_PASSWORD]}, _LOGGER): return False from verisure import MyPages, LoginError, Error global SHOW_THERMOMETERS, SHOW_HYGROMETERS,\ SHOW_ALARM, SHOW_SMARTPLUGS, SHOW_LOCKS, CODE_DIGITS SHOW_THERMOMETERS = int(config[DOMAIN].get('thermometers', '1')) SHOW_HYGROMETERS = int(config[DOMAIN].get('hygrometers', '1')) SHOW_ALARM = int(config[DOMAIN].get('alarm', '1')) SHOW_SMARTPLUGS = int(config[DOMAIN].get('smartplugs', '1')) SHOW_LOCKS = int(config[DOMAIN].get('locks', '1')) CODE_DIGITS = int(config[DOMAIN].get('code_digits', '4')) global MY_PAGES MY_PAGES = MyPages( config[DOMAIN][CONF_USERNAME], config[DOMAIN][CONF_PASSWORD]) global VERISURE_LOGIN_ERROR, VERISURE_ERROR VERISURE_LOGIN_ERROR = LoginError VERISURE_ERROR = Error try: MY_PAGES.login() except (ConnectionError, Error) as ex: _LOGGER.error('Could not log in to verisure mypages, %s', ex) return False update_alarm() update_climate() update_smartplug() update_lock() # Load components for the devices in the ISY controller that we support for comp_name, discovery in ((('sensor', DISCOVER_SENSORS), ('switch', DISCOVER_SWITCHES), ('alarm_control_panel', DISCOVER_ALARMS), ('lock', DISCOVER_LOCKS))): component = get_component(comp_name) _LOGGER.info(config[DOMAIN]) bootstrap.setup_component(hass, component.DOMAIN, config) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, {ATTR_SERVICE: discovery, ATTR_DISCOVERED: {}}) return True
def setup(hass, config): """ Setup the Verisure component. """ if not validate_config(config, {DOMAIN: [CONF_USERNAME, CONF_PASSWORD]}, _LOGGER): return False from verisure import MyPages, LoginError, Error global SHOW_THERMOMETERS, SHOW_HYGROMETERS,\ SHOW_ALARM, SHOW_SMARTPLUGS, SHOW_LOCKS, CODE_DIGITS SHOW_THERMOMETERS = int(config[DOMAIN].get('thermometers', '1')) SHOW_HYGROMETERS = int(config[DOMAIN].get('hygrometers', '1')) SHOW_ALARM = int(config[DOMAIN].get('alarm', '1')) SHOW_SMARTPLUGS = int(config[DOMAIN].get('smartplugs', '1')) SHOW_LOCKS = int(config[DOMAIN].get('locks', '1')) CODE_DIGITS = int(config[DOMAIN].get('code_digits', '4')) global MY_PAGES MY_PAGES = MyPages(config[DOMAIN][CONF_USERNAME], config[DOMAIN][CONF_PASSWORD]) global VERISURE_LOGIN_ERROR, VERISURE_ERROR VERISURE_LOGIN_ERROR = LoginError VERISURE_ERROR = Error try: MY_PAGES.login() except (ConnectionError, Error) as ex: _LOGGER.error('Could not log in to verisure mypages, %s', ex) return False update_alarm() update_climate() update_smartplug() update_lock() # Load components for the devices in the ISY controller that we support for comp_name, discovery in ((('sensor', DISCOVER_SENSORS), ('switch', DISCOVER_SWITCHES), ('alarm_control_panel', DISCOVER_ALARMS), ('lock', DISCOVER_LOCKS))): component = get_component(comp_name) _LOGGER.info(config[DOMAIN]) bootstrap.setup_component(hass, component.DOMAIN, config) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, { ATTR_SERVICE: discovery, ATTR_DISCOVERED: {} }) return True
set_alarm.add_argument('code', help='alarm code') set_alarm.add_argument('new_status', choices=['ARMED_HOME', 'ARMED_AWAY', 'DISARMED'], help='new status') # Set lock set_lock = set_device.add_parser('lock', help='set lock status') set_lock.add_argument('code', help='alarm code') set_lock.add_argument('serial_number', help='serial number') set_lock.add_argument('new_status', choices=['LOCKED', 'UNLOCKED'], help='new status') args = parser.parse_args() with MyPages(args.username, args.password) as verisure: if args.command == COMMAND_GET: if 'all' in args.devices: print_overviews(verisure.get_overviews()) else: for dev in args.devices: print_overviews(verisure.__dict__[dev].get()) if args.command == COMMAND_SET: if args.device == 'smartplug': print( verisure.smartplug.set(args.serial_number, args.new_value)) if args.device == 'alarm': print(verisure.alarm.set(args.code, args.new_status)) if args.device == 'lock': print( verisure.lock.set(args.code, args.serial_number,