Bump google-nest-sdm to 2.0.0 and cleanup nest auth implementation in config flow (#72770)

Cleanup nest auth implementaton in config flow
This commit is contained in:
Allen Porter 2022-05-31 08:53:36 -07:00 committed by GitHub
parent aab3fcad7b
commit d31e43b980
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 23 deletions

View file

@ -43,7 +43,6 @@ from google_nest_sdm.exceptions import (
from google_nest_sdm.structure import InfoTrait, Structure
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
@ -319,12 +318,11 @@ class NestFlowHandler(
if not (subscriber_id := data.get(CONF_SUBSCRIBER_ID, "")):
subscriber_id = _generate_subscription_id(cloud_project_id)
_LOGGER.debug("Creating subscriber id '%s'", subscriber_id)
# Create a placeholder ConfigEntry to use since with the auth we've already created.
entry = ConfigEntry(
version=1, domain=DOMAIN, title="", data=self._data, source=""
)
subscriber = await api.new_subscriber_with_impl(
self.hass, entry, subscriber_id, self.flow_impl
subscriber = api.new_subscriber_with_token(
self.hass,
self._data["token"]["access_token"],
config[CONF_PROJECT_ID],
subscriber_id,
)
try:
await subscriber.create_subscription()