From 5a2830a6543dd12fe5cab7aa93dc7aeb79242570 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 19 Oct 2024 14:27:11 +0200 Subject: [PATCH] Use new reauth helpers in tuya (#128766) --- homeassistant/components/tuya/config_flow.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/tuya/config_flow.py b/homeassistant/components/tuya/config_flow.py index 104c3b7c9fa..30d04eb61e2 100644 --- a/homeassistant/components/tuya/config_flow.py +++ b/homeassistant/components/tuya/config_flow.py @@ -8,7 +8,7 @@ from typing import Any from tuya_sharing import LoginControl import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult +from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.helpers import selector from .const import ( @@ -32,7 +32,6 @@ class TuyaConfigFlow(ConfigFlow, domain=DOMAIN): __user_code: str __qr_code: str - __reauth_entry: ConfigEntry | None = None def __init__(self) -> None: """Initialize the config flow.""" @@ -135,9 +134,9 @@ class TuyaConfigFlow(ConfigFlow, domain=DOMAIN): CONF_ENDPOINT: info[CONF_ENDPOINT], } - if self.__reauth_entry: + if self.source == SOURCE_REAUTH: return self.async_update_reload_and_abort( - self.__reauth_entry, + self._get_reauth_entry(), data=entry_data, ) @@ -150,14 +149,8 @@ class TuyaConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle initiation of re-authentication with Tuya.""" - self.__reauth_entry = self.hass.config_entries.async_get_entry( - self.context["entry_id"] - ) - - if self.__reauth_entry and CONF_USER_CODE in self.__reauth_entry.data: - success, _ = await self.__async_get_qr_code( - self.__reauth_entry.data[CONF_USER_CODE] - ) + if CONF_USER_CODE in entry_data: + success, _ = await self.__async_get_qr_code(entry_data[CONF_USER_CODE]) if success: return await self.async_step_scan()