home-assistant/core · error · HomeAssistantError

error_while_turn_on

error_while_turn_on

Error message

An error occurred while turning on AdGuard Home switch.

What it means

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.

Source

Thrown at homeassistant/components/adguard/switch.py:135

    async def async_turn_off(self, **kwargs: Any) -> None:
        """Turn off the switch."""
        try:
            await self.entity_description.turn_off_fn(self.adguard)()
        except AdGuardHomeError as err:
            self._attr_available = False
            raise HomeAssistantError(
                translation_domain=DOMAIN,
                translation_key="error_while_turn_off",
            ) from err

    @override
    async def async_turn_on(self, **kwargs: Any) -> None:
        """Turn on the switch."""
        try:
            await self.entity_description.turn_on_fn(self.adguard)()
        except AdGuardHomeError as err:
            self._attr_available = False
            raise HomeAssistantError(
                translation_domain=DOMAIN,
                translation_key="error_while_turn_on",
            ) from err

    @override
    async def _adguard_update(self) -> None:
        """Update AdGuard Home entity."""
        self._attr_is_on = await self.entity_description.is_on_fn(self.adguard)()

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Confirm the AdGuard Home server is up and responding to API calls (open the UI, run a manual API request).
  2. Reload the integration entry to refresh the client session and retry.
  3. Inspect the chained AdGuardHomeError in logs to distinguish auth failure (fix credentials) from connectivity (fix host/port/VPN/DNS).
  4. Once the server responds, the next coordinator poll restores availability — no manual entity repair needed.
Defensive patterns

Strategy: retry

Try / catch

from homeassistant.exceptions import HomeAssistantError

try:
    await switch.async_turn_on()
except HomeAssistantError as err:
    _LOGGER.warning("AdGuard switch on failed (will be retried on next poll): %s", err)
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/191921adacc3db25. Report an issue: GitHub.