home-assistant/core · error · ValueError

Unable to deactivate the owner

Error message

Unable to deactivate the owner

What it means

ConfigEntryAuthFailed tells Home Assistant the stored credentials are no longer valid, so HA starts the re-authentication flow instead of retrying. braviatv raises it when the underlying bravia_tv library's connect() throws BraviaAuthError, i.e. authentication with the TV (PIN handshake or pre-shared key) failed.

Source

Thrown at homeassistant/auth/__init__.py:401

                await self.async_deactivate_user(user)

        self.hass.bus.async_fire(EVENT_USER_UPDATED, {"user_id": user.id})

    @callback
    def async_update_user_credentials_data(
        self, credentials: models.Credentials, data: dict[str, Any]
    ) -> None:
        """Update credentials data."""
        self._store.async_update_user_credentials_data(credentials, data=data)

    async def async_activate_user(self, user: models.User) -> None:
        """Activate a user."""
        await self._store.async_activate_user(user)

    async def async_deactivate_user(self, user: models.User) -> None:
        """Deactivate a user."""
        if user.is_owner:
            raise ValueError("Unable to deactivate the owner")
        await self._store.async_deactivate_user(user)
        for refresh_token in list(user.refresh_tokens.values()):
            self.async_remove_refresh_token(refresh_token)

    async def async_remove_credentials(self, credentials: models.Credentials) -> None:
        """Remove credentials."""
        provider = self._async_get_auth_provider(credentials)

        if provider is not None and hasattr(provider, "async_will_remove_credentials"):
            await provider.async_will_remove_credentials(credentials)

        await self._store.async_remove_credentials(credentials)

    async def async_enable_user_mfa(
        self, user: models.User, mfa_module_id: str, data: Any
    ) -> None:
        """Enable a multi-factor auth module for user."""
        if user.system_generated:

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Re-run authentication: in HA go to Settings > Devices & Services > the Bravia TV entry and follow the re-authenticate prompt (this is what ConfigEntryAuthFailed triggers).
  2. If using PIN auth, initiate a fresh registration so the TV displays a new PIN, and enter it promptly — PINs are single-use and short-lived.
  3. If using PSK auth, verify the pre-shared key configured on the TV (Settings > Network > Home Network Setup > IP Control / Pre-Shared Key) exactly matches the integration's setting — PSKs are case-sensitive.
  4. Check the TV still allows remote control: Home Network Setup > Remote Start and IP Control must be enabled, and 'IP registration' must not have been cleared (factory reset clears it).
  5. Update the bravia_tv library/integration — auth API changes in TV firmware occasionally require a client-side fix.

Example fix

// before: auth error during connect aborts the update
except BraviaAuthError as err:
    raise ConfigEntryAuthFailed from err
// after: unchanged — the correct pattern. The 'fix' is user-side re-auth:
// HA shows the entry as 'Failed to set up' with a re-authenticate button;
// complete the reauth flow with a fresh PIN or corrected PSK.
// In a custom coordinator you can also force it explicitly:
raise ConfigEntryAuthFailed("Sony Bravia TV rejected the stored PIN/PSK") from err
Defensive patterns

Strategy: validation

Validate before calling

# Before connecting, cheaply verify the TV is on the network and reachable
from asyncio import open_connection

async def tv_reachable(host: str, port: int = 8443) -> bool:
    try:
        _, w = await open_connection(host, port)
        w.close()
        return True
    except OSError:
        return False

Type guard

from bravia_tv import BraviaAuthError

def is_auth_failure(err: BaseException) -> bool:
    """Narrow an exception to an auth failure worth a reauth flow."""
    return isinstance(err, BraviaAuthError)

Try / catch

try:
    await self.client.connect(psk=self.pin)  # or pin/clientid/nickname
except BraviaAuthError as err:
    raise ConfigEntryAuthFailed from err  # HA opens the reauth flow
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
    raise ConfigEntryNotReady from err    # network issue -> retry later, do NOT reauth

Prevention

When it happens

Trigger: Awaiting self.client.connect(psk=self.pin) (PSK mode) or self.client.connect(pin=..., clientid=..., nickname=...) (PIN mode) throws BraviaAuthError — wrong PSK, wrong/expired PIN, the TV rejected the client registration, or the previously registered clientid/nickname was invalidated (e.g. TV factory reset or the registration was deleted).

Common situations: The 4-digit PIN shown on the TV was mistyped or expired during setup; the PSK set on the TV differs from the one stored in the integration; the TV was factory-reset or deauthorized 'Home Assistant' in its network remote control settings; a TV firmware update invalidated the stored credential.

Related errors


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