How to use the aiounifi.RequestError function in aiounifi

To help you get started, we’ve selected a few aiounifi 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 home-assistant / home-assistant / tests / components / unifi / test_controller.py View on Github external
async def test_get_controller_controller_unavailable(hass):
    """Check that get_controller can handle controller being unavailable."""
    result = None
    with patch("aiounifi.Controller.login", side_effect=aiounifi.RequestError):
        try:
            result = await unifi.controller.get_controller(hass, **CONTROLLER_DATA)
        except unifi.errors.CannotConnect:
            pass
        assert result is None
github home-assistant / home-assistant / homeassistant / components / unifi / controller.py View on Github external
port=port,
        site=site,
        websession=session,
        sslcontext=sslcontext,
    )

    try:
        with async_timeout.timeout(10):
            await controller.login()
        return controller

    except aiounifi.Unauthorized:
        LOGGER.warning("Connected to UniFi at %s but not registered.", host)
        raise AuthenticationRequired

    except (asyncio.TimeoutError, aiounifi.RequestError):
        LOGGER.error("Error connecting to the UniFi controller at %s", host)
        raise CannotConnect

    except aiounifi.AiounifiException:
        LOGGER.exception("Unknown UniFi communication error occurred")
        raise AuthenticationRequired

aiounifi

Python library for communicating with UniFi Network Controller API

MIT
Latest version published 6 days ago

Package Health Score

75 / 100
Full package analysis

Similar packages