Use reauth helpers in co2signal (#128566)
Do not cache reauth entry in co2signal
This commit is contained in:
parent
9037421a85
commit
0e667dfe36
1 changed files with 4 additions and 10 deletions
|
@ -13,7 +13,7 @@ from aioelectricitymaps import (
|
|||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_COUNTRY_CODE,
|
||||
|
@ -42,7 +42,6 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
_data: dict | None
|
||||
_reauth_entry: ConfigEntry | None = None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
@ -128,9 +127,6 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the reauth step."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
)
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
|
@ -165,12 +161,10 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
except ElectricityMapsError:
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
if self._reauth_entry:
|
||||
if self.source == SOURCE_REAUTH:
|
||||
return self.async_update_reload_and_abort(
|
||||
self._reauth_entry,
|
||||
data={
|
||||
CONF_API_KEY: data[CONF_API_KEY],
|
||||
},
|
||||
self._get_reauth_entry(),
|
||||
data_updates={CONF_API_KEY: data[CONF_API_KEY]},
|
||||
)
|
||||
|
||||
return self.async_create_entry(
|
||||
|
|
Loading…
Add table
Reference in a new issue