How to use the alexapy.AlexaLogin function in AlexaPy

To help you get started, we’ve selected a few AlexaPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github custom-components / alexa_media_player / custom_components / alexa_media / config_flow.py View on Github external
else:
            self.config[CONF_INCLUDE_DEVICES] = user_input[CONF_INCLUDE_DEVICES]
        if isinstance(user_input[CONF_EXCLUDE_DEVICES], str):
            self.config[CONF_EXCLUDE_DEVICES] = (
                user_input[CONF_EXCLUDE_DEVICES].split(",")
                if CONF_EXCLUDE_DEVICES in user_input and
                user_input[CONF_EXCLUDE_DEVICES] != ""
                else []
            )
        else:
            self.config[CONF_EXCLUDE_DEVICES] = user_input[CONF_EXCLUDE_DEVICES]

        if not self.login:
            _LOGGER.debug("Creating new login")
            try:
                self.login = AlexaLogin(
                    self.config[CONF_URL],
                    self.config[CONF_EMAIL],
                    self.config[CONF_PASSWORD],
                    self.hass.config.path,
                    self.config[CONF_DEBUG],
                )
                await self.login.login_with_cookie()
                return await self._test_login()
            except BaseException:
                raise
                return await self._show_form(errors={"base": "invalid_credentials"})
        else:
            _LOGGER.debug("Using existing login")
            await self.login.login(data=user_input)
            return await self._test_login()
github eliseomartelli / ParentsHomeAutomation / homeassistant / custom_components / alexa_media / config_flow.py View on Github external
)
        else:
            self.config[CONF_INCLUDE_DEVICES] = user_input[CONF_INCLUDE_DEVICES]
        if isinstance(user_input[CONF_EXCLUDE_DEVICES], str):
            self.config[CONF_EXCLUDE_DEVICES] = (
                user_input[CONF_EXCLUDE_DEVICES].split(",")
                if CONF_EXCLUDE_DEVICES in user_input
                and user_input[CONF_EXCLUDE_DEVICES] != ""
                else []
            )
        else:
            self.config[CONF_EXCLUDE_DEVICES] = user_input[CONF_EXCLUDE_DEVICES]
        try:
            if not self.login:
                _LOGGER.debug("Creating new login")
                self.login = AlexaLogin(
                    self.config[CONF_URL],
                    self.config[CONF_EMAIL],
                    self.config[CONF_PASSWORD],
                    self.hass.config.path,
                    self.config[CONF_DEBUG],
                )
                await self.login.login_with_cookie()
                return await self._test_login()
            else:
                _LOGGER.debug("Using existing login")
                await self.login.login(data=user_input)
                return await self._test_login()
        except AlexapyConnectionError:
            return await self._show_form(errors={"base": "connection_error"})
        except BaseException as ex:
            _LOGGER.warning("Unknown error: %s", ex)
github aneisch / home-assistant-config / custom_components / alexa_media / config_flow.py View on Github external
)
        else:
            self.config[CONF_INCLUDE_DEVICES] = user_input[CONF_INCLUDE_DEVICES]
        if isinstance(user_input[CONF_EXCLUDE_DEVICES], str):
            self.config[CONF_EXCLUDE_DEVICES] = (
                user_input[CONF_EXCLUDE_DEVICES].split(",")
                if CONF_EXCLUDE_DEVICES in user_input and
                user_input[CONF_EXCLUDE_DEVICES] != ""
                else []
            )
        else:
            self.config[CONF_EXCLUDE_DEVICES] = user_input[CONF_EXCLUDE_DEVICES]
        try:
            if not self.login:
                _LOGGER.debug("Creating new login")
                self.login = AlexaLogin(
                    self.config[CONF_URL],
                    self.config[CONF_EMAIL],
                    self.config[CONF_PASSWORD],
                    self.hass.config.path,
                    self.config[CONF_DEBUG],
                )
                await self.login.login_with_cookie()
                return await self._test_login()
            else:
                _LOGGER.debug("Using existing login")
                await self.login.login(data=user_input)
                return await self._test_login()
        except AlexapyConnectionError:
            return await self._show_form(errors={"base": "connection_error"})
        except BaseException as ex:
            _LOGGER.warning("Unknown error: %s", ex)
github eifinger / homeassistant-config / custom_components / alexa_media / __init__.py View on Github external
"websocket_commands": {},
            "websocket_activity": {"serials": {}, "refreshed": {}},
            "websocket": None,
            "auth_info": None,
            "configurator": [],
            "options": {
                CONF_QUEUE_DELAY: config_entry.options.get(
                    CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY
                )
            },
            DATA_LISTENER: [config_entry.add_update_listener(update_listener)],
        },
    )
    login = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get(
        "login_obj",
        AlexaLogin(url, email, password, hass.config.path, account.get(CONF_DEBUG)),
    )
    await login.login_with_cookie()
    if await test_login_status(hass, config_entry, login, setup_alexa):
        return True
    return False
github ikifar2012 / Home-AssistantConfig / custom_components / alexa_media / __init__.py View on Github external
"websocket_commands": {},
            "websocket_activity": {"serials": {}, "refreshed": {}},
            "websocket": None,
            "auth_info": None,
            "configurator": [],
            "options": {
                CONF_QUEUE_DELAY: config_entry.options.get(
                    CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY
                )
            },
            DATA_LISTENER: [config_entry.add_update_listener(update_listener)],
        },
    )
    login = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get(
        "login_obj",
        AlexaLogin(url, email, password, hass.config.path, account.get(CONF_DEBUG)),
    )
    await login.login_with_cookie()
    if await test_login_status(hass, config_entry, login, setup_alexa):
        return True
    return False
github scottsweb / ham / homeassistant / custom_components / alexa_media / __init__.py View on Github external
hass.data[DATA_ALEXAMEDIA] = {}
        hass.data[DATA_ALEXAMEDIA]['accounts'] = {}
    from alexapy import AlexaLogin, __version__ as alexapy_version
    _LOGGER.info(STARTUP)
    _LOGGER.info("Loaded alexapy==%s", alexapy_version)
    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, close_alexa_media)
    domainconfig = config.get(DOMAIN)
    for account in domainconfig[CONF_ACCOUNTS]:
        # if account[CONF_EMAIL] in configured_instances(hass):
        #     continue

        email = account.get(CONF_EMAIL)
        password = account.get(CONF_PASSWORD)
        url = account.get(CONF_URL)
        hass.data[DATA_ALEXAMEDIA]['accounts'][email] = {"config": []}
        login = AlexaLogin(url, email, password, hass.config.path,
                           account.get(CONF_DEBUG))
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]['login_obj']) = login
        await login.login_with_cookie()
        await test_login_status(hass, account, login,
                                setup_platform_callback)
    return True
github custom-components / alexa_media_player / alexa_media / __init__.py View on Github external
"""Set up the Alexa domain."""
    if DATA_ALEXAMEDIA not in hass.data:
        hass.data[DATA_ALEXAMEDIA] = {}
        hass.data[DATA_ALEXAMEDIA]['accounts'] = {}
    from alexapy import AlexaLogin

    config = config.get(DOMAIN)
    for account in config[CONF_ACCOUNTS]:
        # if account[CONF_EMAIL] in configured_instances(hass):
        #     continue

        email = account.get(CONF_EMAIL)
        password = account.get(CONF_PASSWORD)
        url = account.get(CONF_URL)
        hass.data[DATA_ALEXAMEDIA]['accounts'][email] = {"config": []}
        login = AlexaLogin(url, email, password, hass.config.path,
                           account.get(CONF_DEBUG))

        test_login_status(hass, account, login,
                          setup_platform_callback)
    return True
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
hass.data[DATA_ALEXAMEDIA] = {}
        hass.data[DATA_ALEXAMEDIA]['accounts'] = {}
    from alexapy import AlexaLogin, __version__ as alexapy_version
    _LOGGER.info(STARTUP)
    _LOGGER.info("Loaded alexapy==%s", alexapy_version)
    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, close_alexa_media)
    account = config_entry.data
    email = account.get(CONF_EMAIL)
    password = account.get(CONF_PASSWORD)
    url = account.get(CONF_URL)
    if email not in hass.data[DATA_ALEXAMEDIA]['accounts']:
        hass.data[DATA_ALEXAMEDIA]['accounts'][email] = {}
    if 'login_obj' in hass.data[DATA_ALEXAMEDIA]['accounts'][email]:
        login = hass.data[DATA_ALEXAMEDIA]['accounts'][email]['login_obj']
    else:
        login = AlexaLogin(url, email, password, hass.config.path,
                           account.get(CONF_DEBUG))
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]['login_obj']) = login
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]
                  ['config_entry']) = config_entry
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]
                  ['setup_platform_callback']) = setup_platform_callback
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]
                  ['test_login_status']) = test_login_status
    await login.login_with_cookie()
    await test_login_status(hass, config_entry, login,
                            setup_platform_callback)
    return True
github aneisch / home-assistant-config / custom_components / alexa_media / __init__.py View on Github external
hass.data[DATA_ALEXAMEDIA] = {}
        hass.data[DATA_ALEXAMEDIA]['accounts'] = {}
    from alexapy import AlexaLogin, __version__ as alexapy_version
    _LOGGER.info(STARTUP)
    _LOGGER.info("Loaded alexapy==%s", alexapy_version)
    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, close_alexa_media)
    account = config_entry.data
    email = account.get(CONF_EMAIL)
    password = account.get(CONF_PASSWORD)
    url = account.get(CONF_URL)
    if email not in hass.data[DATA_ALEXAMEDIA]['accounts']:
        hass.data[DATA_ALEXAMEDIA]['accounts'][email] = {}
    if 'login_obj' in hass.data[DATA_ALEXAMEDIA]['accounts'][email]:
        login = hass.data[DATA_ALEXAMEDIA]['accounts'][email]['login_obj']
    else:
        login = AlexaLogin(url, email, password, hass.config.path,
                           account.get(CONF_DEBUG))
        (hass.data[DATA_ALEXAMEDIA]['accounts'][email]['login_obj']) = login
    await login.login_with_cookie()
    await test_login_status(hass, config_entry, login,
                            setup_platform_callback)
    return True
github michaeldvinci / Home-AssistantConfig / custom_components / alexa_media / __init__.py View on Github external
if DATA_ALEXAMEDIA not in hass.data:
        hass.data[DATA_ALEXAMEDIA] = {}
        hass.data[DATA_ALEXAMEDIA]['accounts'] = {}
    from alexapy import AlexaLogin, __version__ as alexapy_version
    _LOGGER.info(STARTUP)
    _LOGGER.info("Loaded alexapy==%s", alexapy_version)
    config = config.get(DOMAIN)
    for account in config[CONF_ACCOUNTS]:
        # if account[CONF_EMAIL] in configured_instances(hass):
        #     continue

        email = account.get(CONF_EMAIL)
        password = account.get(CONF_PASSWORD)
        url = account.get(CONF_URL)
        hass.data[DATA_ALEXAMEDIA]['accounts'][email] = {"config": []}
        login = AlexaLogin(url, email, password, hass.config.path,
                           account.get(CONF_DEBUG))

        test_login_status(hass, account, login,
                          setup_platform_callback)
    return True