Skip to content

Commit

Permalink
Use reauth helpers in co2signal (home-assistant#128566)
Browse files Browse the repository at this point in the history
Do not cache reauth entry in co2signal
  • Loading branch information
epenet authored Oct 18, 2024
1 parent 9037421 commit 0e667df
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions homeassistant/components/co2signal/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -128,9 +127,6 @@ async def async_step_reauth(
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(
Expand Down Expand Up @@ -165,12 +161,10 @@ async def _validate_and_create(
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(
Expand Down

0 comments on commit 0e667df

Please sign in to comment.