Skip to content

Improve API login in the init file #28

@danielgospodinow

Description

@danielgospodinow

In the init file, the login flow should be improved.

    try:
        await api_client.login(email, password)
        await api_client.get_devices()  # NOTE: This is needed since currently the login API does not throw an error if the credentials are invalid: https://github.com/qbaware/homeassistant-eldom/issues/27
        _LOGGER.info("Successfully authenticated with Eldom API")
    except Exception as e:
        _LOGGER.error("Unexpected exception while authenticating with Eldom API: %s", e)
        raise ConfigEntryNotReady(
            f"Unexpected exception while authenticating with Eldom API: {e}"
        ) from e
  • Throw a ConfigEntryAuthFailed exception in case the creds are funny.
  • Throw a ConfigEntryNotReady exception in case something unexpected happens.

Also, remove the get_devices call.

This is related to qbaware/pyeldom#4.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions