mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
parent
d375dca1f1
commit
0704c3ccb9
@ -23,7 +23,7 @@ from google_nest_sdm.exceptions import (
|
|||||||
from google_nest_sdm.structure import Structure
|
from google_nest_sdm.structure import Structure
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlowResult
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
from homeassistant.util import get_random_string
|
from homeassistant.util import get_random_string
|
||||||
|
|
||||||
@ -96,21 +96,6 @@ class NestFlowHandler(
|
|||||||
# Possible name to use for config entry based on the Google Home name
|
# Possible name to use for config entry based on the Google Home name
|
||||||
self._structure_config_title: str | None = None
|
self._structure_config_title: str | None = None
|
||||||
|
|
||||||
def _async_reauth_entry(self) -> ConfigEntry | None:
|
|
||||||
"""Return existing entry for reauth."""
|
|
||||||
if self.source != SOURCE_REAUTH or not (
|
|
||||||
entry_id := self.context.get("entry_id")
|
|
||||||
):
|
|
||||||
return None
|
|
||||||
return next(
|
|
||||||
(
|
|
||||||
entry
|
|
||||||
for entry in self._async_current_entries()
|
|
||||||
if entry.entry_id == entry_id
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def logger(self) -> logging.Logger:
|
def logger(self) -> logging.Logger:
|
||||||
"""Return logger."""
|
"""Return logger."""
|
||||||
@ -140,7 +125,7 @@ class NestFlowHandler(
|
|||||||
self._data.update(data)
|
self._data.update(data)
|
||||||
if self.source == SOURCE_REAUTH:
|
if self.source == SOURCE_REAUTH:
|
||||||
_LOGGER.debug("Skipping Pub/Sub configuration")
|
_LOGGER.debug("Skipping Pub/Sub configuration")
|
||||||
return await self.async_step_finish()
|
return await self._async_finish()
|
||||||
return await self.async_step_pubsub()
|
return await self.async_step_pubsub()
|
||||||
|
|
||||||
async def async_step_reauth(
|
async def async_step_reauth(
|
||||||
@ -303,7 +288,7 @@ class NestFlowHandler(
|
|||||||
CONF_CLOUD_PROJECT_ID: cloud_project_id,
|
CONF_CLOUD_PROJECT_ID: cloud_project_id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return await self.async_step_finish()
|
return await self._async_finish()
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="pubsub",
|
step_id="pubsub",
|
||||||
@ -316,19 +301,15 @@ class NestFlowHandler(
|
|||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_finish(
|
async def _async_finish(self) -> ConfigFlowResult:
|
||||||
self, data: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Create an entry for the SDM flow."""
|
"""Create an entry for the SDM flow."""
|
||||||
_LOGGER.debug("Creating/updating configuration entry")
|
_LOGGER.debug("Creating/updating configuration entry")
|
||||||
# Update existing config entry when in the reauth flow.
|
# Update existing config entry when in the reauth flow.
|
||||||
if entry := self._async_reauth_entry():
|
if self.source == SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
entry,
|
self._get_reauth_entry(),
|
||||||
data=self._data,
|
data=self._data,
|
||||||
)
|
)
|
||||||
await self.hass.config_entries.async_reload(entry.entry_id)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
title = self.flow_impl.name
|
title = self.flow_impl.name
|
||||||
if self._structure_config_title:
|
if self._structure_config_title:
|
||||||
title = self._structure_config_title
|
title = self._structure_config_title
|
||||||
|
Loading…
x
Reference in New Issue
Block a user