diff --git a/homeassistant/components/google/__init__.py b/homeassistant/components/google/__init__.py index 3ab50cc0a56..f35f79a5f92 100644 --- a/homeassistant/components/google/__init__.py +++ b/homeassistant/components/google/__init__.py @@ -1,4 +1,6 @@ """Support for Google - Calendar Event Devices.""" +from __future__ import annotations + from collections.abc import Mapping from datetime import datetime, timedelta, timezone from enum import Enum @@ -28,7 +30,7 @@ from homeassistant.const import ( CONF_OFFSET, Platform, ) -from homeassistant.core import HomeAssistant, ServiceCall +from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import generate_entity_id @@ -196,6 +198,8 @@ def do_authentication( notification_id=NOTIFICATION_ID, ) + listener: CALLBACK_TYPE | None = None + def step2_exchange(now: datetime) -> None: """Keep trying to validate the user_code until it expires.""" _LOGGER.debug("Attempting to validate user code") @@ -212,6 +216,7 @@ def do_authentication( title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, ) + assert listener listener() return @@ -224,6 +229,7 @@ def do_authentication( storage = Storage(hass.config.path(TOKEN_FILE)) storage.put(credentials) do_setup(hass, hass_config, config) + assert listener listener() persistent_notification.create( hass, @@ -236,7 +242,7 @@ def do_authentication( ) listener = track_utc_time_change( - hass, step2_exchange, second=range(0, 60, dev_flow.interval) + hass, step2_exchange, second=range(1, 60, dev_flow.interval) ) return True