{"record":{"id":"a92bab9bfcba37dc","repo":"home-assistant/core","slug":"unable-to-deactivate-the-owner","errorCode":null,"errorMessage":"Unable to deactivate the owner","messagePattern":"Unable to deactivate the owner","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"homeassistant/auth/__init__.py","lineNumber":401,"sourceCode":"                await self.async_deactivate_user(user)\n\n        self.hass.bus.async_fire(EVENT_USER_UPDATED, {\"user_id\": user.id})\n\n    @callback\n    def async_update_user_credentials_data(\n        self, credentials: models.Credentials, data: dict[str, Any]\n    ) -> None:\n        \"\"\"Update credentials data.\"\"\"\n        self._store.async_update_user_credentials_data(credentials, data=data)\n\n    async def async_activate_user(self, user: models.User) -> None:\n        \"\"\"Activate a user.\"\"\"\n        await self._store.async_activate_user(user)\n\n    async def async_deactivate_user(self, user: models.User) -> None:\n        \"\"\"Deactivate a user.\"\"\"\n        if user.is_owner:\n            raise ValueError(\"Unable to deactivate the owner\")\n        await self._store.async_deactivate_user(user)\n        for refresh_token in list(user.refresh_tokens.values()):\n            self.async_remove_refresh_token(refresh_token)\n\n    async def async_remove_credentials(self, credentials: models.Credentials) -> None:\n        \"\"\"Remove credentials.\"\"\"\n        provider = self._async_get_auth_provider(credentials)\n\n        if provider is not None and hasattr(provider, \"async_will_remove_credentials\"):\n            await provider.async_will_remove_credentials(credentials)\n\n        await self._store.async_remove_credentials(credentials)\n\n    async def async_enable_user_mfa(\n        self, user: models.User, mfa_module_id: str, data: Any\n    ) -> None:\n        \"\"\"Enable a multi-factor auth module for user.\"\"\"\n        if user.system_generated:","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/auth/__init__.py#L383-L419","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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).","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.","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.","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).","Update the bravia_tv library/integration — auth API changes in TV firmware occasionally require a client-side fix."],"exampleFix":"// before: auth error during connect aborts the update\nexcept BraviaAuthError as err:\n    raise ConfigEntryAuthFailed from err\n// after: unchanged — the correct pattern. The 'fix' is user-side re-auth:\n// HA shows the entry as 'Failed to set up' with a re-authenticate button;\n// complete the reauth flow with a fresh PIN or corrected PSK.\n// In a custom coordinator you can also force it explicitly:\nraise ConfigEntryAuthFailed(\"Sony Bravia TV rejected the stored PIN/PSK\") from err","handlingStrategy":"validation","validationCode":"# Before connecting, cheaply verify the TV is on the network and reachable\nfrom asyncio import open_connection\n\nasync def tv_reachable(host: str, port: int = 8443) -> bool:\n    try:\n        _, w = await open_connection(host, port)\n        w.close()\n        return True\n    except OSError:\n        return False","typeGuard":"from bravia_tv import BraviaAuthError\n\ndef is_auth_failure(err: BaseException) -> bool:\n    \"\"\"Narrow an exception to an auth failure worth a reauth flow.\"\"\"\n    return isinstance(err, BraviaAuthError)","tryCatchPattern":"try:\n    await self.client.connect(psk=self.pin)  # or pin/clientid/nickname\nexcept BraviaAuthError as err:\n    raise ConfigEntryAuthFailed from err  # HA opens the reauth flow\nexcept (asyncio.TimeoutError, aiohttp.ClientError) as err:\n    raise ConfigEntryNotReady from err    # network issue -> retry later, do NOT reauth","preventionTips":["Prefer PSK auth over PIN for headless setups — PSKs do not expire like one-time registration PINs.","Keep 'Remote Start' and 'IP Control' enabled on the TV; disabling either breaks auth on next connect.","Record which auth mode (PSK vs PIN) an entry uses, as the source does with use_psk, so you never send a PIN where a PSK is expected.","After a TV factory reset, proactively re-run the integration's reauth instead of waiting for the first failed poll."],"tags":["home-assistant","authentication","bravia-tv","psk","reauth"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}