From 725b337b8729f360a0e3a3db02e87c208b9c6409 Mon Sep 17 00:00:00 2001 From: Jimmy Everling Date: Sat, 22 Aug 2026 21:33:23 +0200 Subject: [PATCH] fix: force fresh login on reauth instead of reusing cached session When the user re-enters credentials during reauth, _async_try_login was still calling start_session(), which silently kept reusing the cached (possibly stale) session from the settings file. Pass the flow origin through and call reauthenticate() for the "reauth_confirm" origin so the entered credentials are actually used. Also bump aio-panasonic-comfort-cloud to 2026.8.8 and release 2026.8.6. --- custom_components/panasonic_cc/config_flow.py | 15 ++++++++++++--- custom_components/panasonic_cc/manifest.json | 4 ++-- requirements.txt | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/custom_components/panasonic_cc/config_flow.py b/custom_components/panasonic_cc/config_flow.py index 8630136..7443770 100644 --- a/custom_components/panasonic_cc/config_flow.py +++ b/custom_components/panasonic_cc/config_flow.py @@ -135,7 +135,7 @@ async def _async_handle_login( otp_code = user_input.get(CONF_OTP_CODE) try: errors = await self._async_try_login( - user_input[CONF_USERNAME], user_input[CONF_PASSWORD], otp_code + user_input[CONF_USERNAME], user_input[CONF_PASSWORD], otp_code, origin ) except MFARequiredError: _LOGGER.debug("Account requires a 2FA code, asking the user for one") @@ -179,7 +179,7 @@ async def _async_handle_login( return await self._async_create_entry(user_input) async def _async_try_login( - self, username: str, password: str, otp_code: str | None = None + self, username: str, password: str, otp_code: str | None = None, origin: str = "user" ) -> dict[str, str]: """Attempt to authenticate and fetch the account's devices. @@ -188,12 +188,21 @@ async def _async_try_login( supplied, or AgreementNotAcceptedError if Panasonic requires acceptance of updated agreements — the caller is expected to prompt for the missing input and retry. + + For a "reauth_confirm" origin this forces a completely fresh login + via reauthenticate() rather than start_session(), which would + otherwise silently keep reusing a cached (and possibly stale/stuck) + session from the settings file instead of the credentials the user + just entered. """ client = async_get_clientsession(self.hass) api = ApiClient(username, password, client) errors: dict[str, str] = {} try: - await api.start_session(otp_code) + if origin == "reauth_confirm": + await api.reauthenticate(otp_code) + else: + await api.start_session(otp_code) if not api.has_devices: errors["base"] = "no_devices" diff --git a/custom_components/panasonic_cc/manifest.json b/custom_components/panasonic_cc/manifest.json index f4ef204..05a4623 100644 --- a/custom_components/panasonic_cc/manifest.json +++ b/custom_components/panasonic_cc/manifest.json @@ -13,8 +13,8 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/sockless-coding/panasonic_cc/issues", "requirements": [ - "aio-panasonic-comfort-cloud==2026.8.7" + "aio-panasonic-comfort-cloud==2026.8.8" ], "quality_scale": "silver", - "version": "2026.8.5" + "version": "2026.8.6" } diff --git a/requirements.txt b/requirements.txt index 12577e6..3d4b4ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ aiohttp -aio-panasonic-comfort-cloud==2026.8.7 +aio-panasonic-comfort-cloud==2026.8.8