{"record":{"id":"191921adacc3db25","repo":"home-assistant/core","slug":"error-while-turn-on","errorCode":"error_while_turn_on","errorMessage":"An error occurred while turning on AdGuard Home switch.","messagePattern":"An error occurred while turning on AdGuard Home switch\\.","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/adguard/switch.py","lineNumber":135,"sourceCode":"    async def async_turn_off(self, **kwargs: Any) -> None:\n        \"\"\"Turn off the switch.\"\"\"\n        try:\n            await self.entity_description.turn_off_fn(self.adguard)()\n        except AdGuardHomeError as err:\n            self._attr_available = False\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"error_while_turn_off\",\n            ) from err\n\n    @override\n    async def async_turn_on(self, **kwargs: Any) -> None:\n        \"\"\"Turn on the switch.\"\"\"\n        try:\n            await self.entity_description.turn_on_fn(self.adguard)()\n        except AdGuardHomeError as err:\n            self._attr_available = False\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"error_while_turn_on\",\n            ) from err\n\n    @override\n    async def _adguard_update(self) -> None:\n        \"\"\"Update AdGuard Home entity.\"\"\"\n        self._attr_is_on = await self.entity_description.is_on_fn(self.adguard)()\n","sourceCodeStart":117,"sourceCodeEnd":144,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/adguard/switch.py#L117-L144","documentation":"HomeAssistantError with translation_key error_while_turn_on, raised by AdGuardSwitch.async_turn_on when entity_description.turn_on_fn(self.adguard)() raises AdGuardHomeError. Mirrors the turn_off path: the entity is marked unavailable and the original library exception is chained as the cause.","triggerScenarios":"Turning on any AdGuard switch entity while the underlying API setter fails: server unreachable, auth rejected, or the endpoint for that specific switch (protection, filtering, safebrowsing, parental, querylog) errors out.","commonSituations":"Same class as turn_off: AdGuard server down/restarting, credential rotation, reverse-proxy timeouts in front of AdGuard, version drift between the adguard aiohttp client and the AdGuard Home server API.","solutions":["Confirm the AdGuard Home server is up and responding to API calls (open the UI, run a manual API request).","Reload the integration entry to refresh the client session and retry.","Inspect the chained AdGuardHomeError in logs to distinguish auth failure (fix credentials) from connectivity (fix host/port/VPN/DNS).","Once the server responds, the next coordinator poll restores availability — no manual entity repair needed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from homeassistant.exceptions import HomeAssistantError\n\ntry:\n    await switch.async_turn_on()\nexcept HomeAssistantError as err:\n    _LOGGER.warning(\"AdGuard switch on failed (will be retried on next poll): %s\", err)\n    raise","preventionTips":["Verify AdGuard Home API credentials before bulk-toggling switches in automations.","Retry commands with a short backoff to cover AdGuard restart windows.","Treat switch unavailability as the signal to investigate the server, not the entity."],"tags":["homeassistant","adguard","switch","api-error"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}