{"record":{"id":"4a7812a93ae4f29c","repo":"home-assistant/core","slug":"error-communicating-with-airpatrol-api-api-err","errorCode":null,"errorMessage":"Error communicating with AirPatrol API: {api_err}","messagePattern":"Error communicating with AirPatrol API: (.+?)","errorType":"exception","errorClass":"UpdateFailed","httpStatus":null,"severity":"error","filePath":"homeassistant/components/airpatrol/coordinator.py","lineNumber":41,"sourceCode":"    api: AirPatrolAPI\n\n    def __init__(self, hass: HomeAssistant, config_entry: AirPatrolConfigEntry) -> None:\n        \"\"\"Initialize.\"\"\"\n\n        super().__init__(\n            hass,\n            LOGGER,\n            name=f\"{DOMAIN.capitalize()} {config_entry.title}\",\n            update_interval=SCAN_INTERVAL,\n            config_entry=config_entry,\n        )\n\n    @override\n    async def _async_setup(self) -> None:\n        try:\n            await self._setup_client()\n        except AirPatrolError as api_err:\n            raise UpdateFailed(\n                f\"Error communicating with AirPatrol API: {api_err}\"\n            ) from api_err\n\n    @override\n    async def _async_update_data(self) -> dict[str, dict[str, Any]]:\n        \"\"\"Update unit data from AirPatrol API.\"\"\"\n        return {unit_data[\"unit_id\"]: unit_data for unit_data in await self._get_data()}\n\n    async def _get_data(self, retry: bool = False) -> list[dict[str, Any]]:\n        \"\"\"Fetch data from API.\"\"\"\n        try:\n            return await self.api.get_data()\n        except AirPatrolAuthenticationError as auth_err:\n            if retry:\n                raise ConfigEntryAuthFailed(\n                    \"Authentication with AirPatrol failed\"\n                ) from auth_err\n            await self._update_token()","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/airpatrol/coordinator.py#L23-L59","documentation":"UpdateFailed raised in AirPatrolDataUpdateCoordinator._async_setup when initial client setup (authentication/client construction) raises any AirPatrolError. It aborts config entry setup with 'Error communicating with AirPatrol API: <detail>' and Home Assistant will retry setup with backoff.","triggerScenarios":"_setup_client() raises AirPatrolError (but not AirPatrolAuthenticationError handling — any error during authenticate() or client construction), e.g. the AirPatrol cloud API being unreachable, returning malformed responses, or rate-limiting during setup.","commonSituations":"AirPatrol cloud outage, wrong email/password causing a non-auth-typed error, network/DNS issues from the Home Assistant host, or API endpoint changes in the airpatrol library.","solutions":["Verify AirPatrol cloud service status and that the app can log in.","Check Home Assistant outbound internet and DNS resolution.","Validate the email/password configured in the entry.","Update the airpatrol integration/library to the latest version.","Look at the wrapped api_err message in logs for the API-level cause."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def is_airpatrol_update_failed(err: Exception) -> bool:\n    return isinstance(err, UpdateFailed) and str(err).startswith(\"Error communicating with AirPatrol API\")","tryCatchPattern":"try:\n    await coordinator.async_config_entry_first_refresh()\nexcept ConfigEntryNotReady as err:\n    # setup-time AirPatrolError surfaces as NotReady; HA retries automatically\n    raise","preventionTips":["Confirm AirPatrol cloud credentials work in the vendor app before adding the integration.","Keep the airpatrol library updated to track API endpoint changes.","Monitor vendor status pages when setup failures cluster in time."],"tags":["home-assistant","airpatrol","cloud-api","coordinator"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}