How to use the aiounifi.AiounifiException 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_unknown_error(hass):
    """Check that get_controller can handle unkown errors."""
    result = None
    with patch("aiounifi.Controller.login", side_effect=aiounifi.AiounifiException):
        try:
            result = await unifi.controller.get_controller(hass, **CONTROLLER_DATA)
        except unifi.errors.AuthenticationRequired:
            pass
        assert result is None
github home-assistant / home-assistant / tests / components / unifi / test_controller.py View on Github external
async def test_failed_update_failed_login(hass):
    """Running update can handle a failed login."""
    controller = await setup_unifi_integration(
        hass,
        ENTRY_CONFIG,
        options={},
        sites=SITES,
        clients_response=[],
        devices_response=[],
        clients_all_response=[],
    )

    with patch.object(
        controller.api.clients, "update", side_effect=aiounifi.LoginRequired
    ), patch.object(controller.api, "login", side_effect=aiounifi.AiounifiException):
        await controller.async_update()
    await hass.async_block_till_done()

    assert controller.available is False
github home-assistant / home-assistant / homeassistant / components / unifi / controller.py View on Github external
await self.api.devices.update()
                if self.option_block_clients:
                    await self.api.clients_all.update()

        except aiounifi.LoginRequired:
            try:
                with async_timeout.timeout(5):
                    await self.api.login()

            except (asyncio.TimeoutError, aiounifi.AiounifiException):
                failed = True
                if self.available:
                    LOGGER.error("Unable to reach controller %s", self.host)
                    self.available = False

        except (asyncio.TimeoutError, aiounifi.AiounifiException):
            failed = True
            if self.available:
                LOGGER.error("Unable to reach controller %s", self.host)
                self.available = False

        if not failed and not self.available:
            LOGGER.info("Reconnected to controller %s", self.host)
            self.available = True

        self.update_wireless_clients()

        async_dispatcher_send(self.hass, self.signal_update)

aiounifi

Python library for communicating with UniFi Network Controller API

MIT
Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages