How to use the aiohue.AiohueException function in aiohue

To help you get started, we’ve selected a few aiohue 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 / homeassistant / components / hue / bridge.py View on Github external
# Create username if we don't have one
            if not username:
                device_name = unicode_slug.slugify(
                    hass.config.location_name, max_length=19
                )
                await bridge.create_user(f"home-assistant#{device_name}")

            # Initialize bridge (and validate our username)
            await bridge.initialize()

        return bridge
    except (aiohue.LinkButtonNotPressed, aiohue.Unauthorized):
        raise AuthenticationRequired
    except (asyncio.TimeoutError, aiohue.RequestError):
        raise CannotConnect
    except aiohue.AiohueException:
        LOGGER.exception("Unknown Hue linking error occurred")
        raise AuthenticationRequired
github robmarkcole / Hue-sensors-HASS / custom_components / huesensor / device_tracker.py View on Github external
async def update_api(api):
    import aiohue

    try:
        with async_timeout.timeout(10):
            await api.update()
    except (asyncio.TimeoutError, aiohue.AiohueException) as err:
        _LOGGER.debug("Failed to fetch sensors: %s", err)
        return False
    return True
github home-assistant / home-assistant / homeassistant / components / hue / sensor_base.py View on Github external
async def async_update_items(self):
        """Update sensors from the bridge."""
        api = self.bridge.api.sensors

        try:
            start = monotonic()
            with async_timeout.timeout(4):
                await self.bridge.async_request_call(api.update())
        except Unauthorized:
            await self.bridge.handle_unauthorized_error()
            return
        except (asyncio.TimeoutError, AiohueException) as err:
            _LOGGER.debug("Failed to fetch sensor: %s", err)

            if not self.bridge.available:
                return

            _LOGGER.error("Unable to reach bridge %s (%s)", self.bridge.host, err)
            self.bridge.available = False

            return

        finally:
            _LOGGER.debug(
                "Finished sensor request in %.3f seconds", monotonic() - start
            )

        if not self.bridge.available:
github home-assistant / home-assistant / homeassistant / components / hue / light.py View on Github external
if is_group:
        api_type = "group"
        api = bridge.api.groups
    else:
        api_type = "light"
        api = bridge.api.lights

    try:
        start = monotonic()
        with async_timeout.timeout(4):
            await bridge.async_request_call(api.update())
    except aiohue.Unauthorized:
        await bridge.handle_unauthorized_error()
        return
    except (asyncio.TimeoutError, aiohue.AiohueException) as err:
        _LOGGER.debug("Failed to fetch %s: %s", api_type, err)

        if not bridge.available:
            return

        _LOGGER.error("Unable to reach bridge %s (%s)", bridge.host, err)
        bridge.available = False

        for item_id, item in current.items():
            if item_id not in progress_waiting:
                item.async_schedule_update_ha_state()

        return

    finally:
        _LOGGER.debug(
github ZinkNotTheMetal / HomeAssistant / custom_components / hue_custom / sensor.py View on Github external
async def update_api(api):
    import aiohue

    try:
        with async_timeout.timeout(10):
            await api.update()
    except (asyncio.TimeoutError, aiohue.AiohueException) as err:
        _LOGGER.debug("Failed to fetch sensors: %s", err)
        return False
    return True
github robmarkcole / Hue-sensors-HASS / custom_components / huesensor / binary_sensor.py View on Github external
async def update_api(api):
    import aiohue

    try:
        with async_timeout.timeout(10):
            await api.update()
    except (asyncio.TimeoutError, aiohue.AiohueException) as err:
        _LOGGER.debug("Failed to fetch sensors: %s", err)
        return False
    return True
github robmarkcole / Hue-sensors-HASS / custom_components / huesensor / sensor.py View on Github external
async def update_api(api):
    import aiohue

    try:
        with async_timeout.timeout(10):
            await api.update()
    except (asyncio.TimeoutError, aiohue.AiohueException) as err:
        _LOGGER.debug("Failed to fetch sensors: %s", err)
        return False
    return True