def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the MyQ component.""" from pymyq import MyQAPI as pymyq username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) brand = config.get(CONF_TYPE) myq = pymyq(username, password, brand) try: if not myq.is_supported_brand(): raise ValueError("Unsupported type. See documentation") if not myq.is_login_valid(): raise ValueError("Username or Password is incorrect") add_devices(MyQDevice(myq, door) for door in myq.get_garage_doors()) return True except (TypeError, KeyError, NameError, ValueError) as ex: _LOGGER.error("%s", ex) hass.components.persistent_notification.create( 'Error: {}<br />' 'You will need to restart hass after fixing.' ''.format(ex), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID) return False
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the MyQ component.""" from pymyq import MyQAPI as pymyq username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) brand = config.get(CONF_TYPE) myq = pymyq(username, password, brand) try: if not myq.is_supported_brand(): raise ValueError("Unsupported type. See documentation") if not myq.is_login_valid(): raise ValueError("Username or Password is incorrect") add_entities(MyQDevice(myq, door) for door in myq.get_garage_doors()) return True except (TypeError, KeyError, NameError, ValueError) as ex: _LOGGER.error("%s", ex) hass.components.persistent_notification.create( 'Error: {}<br />' 'You will need to restart hass after fixing.' ''.format(ex), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID) return False
def start(self): if 'debug' not in self.polyConfig['customParams']: LOGGER.setLevel(logging.INFO) LOGGER.info('Started MyQ Controller') if not 'username' in self.polyConfig['customParams']: LOGGER.error( 'Please specify username parameter in the NodeServer configuration' ) return if not 'password' in self.polyConfig['customParams']: LOGGER.error( 'Please specify password parameter in the NodeServer configuration' ) return if not 'brand' in self.polyConfig['customParams']: brand = pymyq.CHAMBERLAIN LOGGER.info( 'Please specify brand parameter in the NodeServer configuration, default to {}' .format(brand)) else: brand = self.polyConfig['customParams']['brand'] if not brand in pymyq.SUPPORTED_BRANDS: LOGGER.error( 'Invalid brand specified: {}, valid options are: '.format( brand, pymyq.SUPPORTED_BRANDS)) return username = self.polyConfig['customParams']['username'] password = self.polyConfig['customParams']['password'] self.myq = pymyq(username, password, brand) if not self.myq.is_login_valid(): LOGGER.error('Unable to login to MyQ cloud') return LOGGER.info('Login successful...') self.discover()
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the MyQ component.""" from pymyq import MyQAPI as pymyq username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) brand = config.get(CONF_TYPE) logger = logging.getLogger(__name__) myq = pymyq(username, password, brand) if not myq.is_supported_brand(): logger.error('MyQ Cover - Unsupported Type. See documentation') return if not myq.is_login_valid(): logger.error('MyQ Cover - Username or Password is incorrect') return try: add_devices(MyQDevice(myq, door) for door in myq.get_garage_doors()) except (TypeError, KeyError, NameError) as ex: logger.error("MyQ Cover - %s", ex)
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the MyQ component.""" from pymyq import MyQAPI as pymyq username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) brand = config.get(CONF_TYPE) logger = logging.getLogger(__name__) myq = pymyq(username, password, brand) if not myq.is_supported_brand(): logger.error('MyQ Cover - Unsupported Type. See documentation') return if not myq.is_login_valid(): logger.error('MyQ Cover - Username or Password is incorrect') return try: add_devices(MyQDevice(myq, door) for door in myq.get_garage_doors()) except (TypeError, KeyError, NameError) as ex: logger.error("MyQ Cover - %s", ex)