Remove google calendar configuration.yaml deprecated in 2022.6 (#77814)
This commit is contained in:
parent
6644f62ad2
commit
8280b8422c
5 changed files with 61 additions and 449 deletions
|
@ -10,20 +10,12 @@ import aiohttp
|
|||
from gcal_sync.api import GoogleCalendarService
|
||||
from gcal_sync.exceptions import ApiException, AuthException
|
||||
from gcal_sync.model import DateOrDatetime, Event
|
||||
from oauth2client.file import Storage
|
||||
import voluptuous as vol
|
||||
from voluptuous.error import Error as VoluptuousError
|
||||
import yaml
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.application_credentials import (
|
||||
ClientCredential,
|
||||
async_import_client_credential,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_DEVICE_ID,
|
||||
CONF_ENTITIES,
|
||||
CONF_NAME,
|
||||
|
@ -40,15 +32,10 @@ from homeassistant.helpers import config_entry_oauth2_flow
|
|||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .api import ApiAuthImpl, get_feature_access
|
||||
from .const import (
|
||||
CONF_CALENDAR_ACCESS,
|
||||
DATA_CONFIG,
|
||||
DATA_SERVICE,
|
||||
DEVICE_AUTH_IMPL,
|
||||
DOMAIN,
|
||||
EVENT_DESCRIPTION,
|
||||
EVENT_END_DATE,
|
||||
|
@ -79,37 +66,15 @@ DEFAULT_CONF_OFFSET = "!!"
|
|||
|
||||
EVENT_CALENDAR_ID = "calendar_id"
|
||||
|
||||
NOTIFICATION_ID = "google_calendar_notification"
|
||||
NOTIFICATION_TITLE = "Google Calendar Setup"
|
||||
GROUP_NAME_ALL_CALENDARS = "Google Calendar Sensors"
|
||||
|
||||
SERVICE_ADD_EVENT = "add_event"
|
||||
|
||||
YAML_DEVICES = f"{DOMAIN}_calendars.yaml"
|
||||
|
||||
TOKEN_FILE = f".{DOMAIN}.token"
|
||||
|
||||
PLATFORMS = [Platform.CALENDAR]
|
||||
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN),
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
||||
vol.Required(CONF_CLIENT_SECRET): cv.string,
|
||||
vol.Optional(CONF_TRACK_NEW, default=True): cv.boolean,
|
||||
vol.Optional(CONF_CALENDAR_ACCESS, default="read_write"): cv.enum(
|
||||
FeatureAccess
|
||||
),
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
CONFIG_SCHEMA = vol.Schema(cv.removed(DOMAIN), extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
_SINGLE_CALSEARCH_CONFIG = vol.All(
|
||||
cv.deprecated(CONF_MAX_RESULTS),
|
||||
|
@ -171,65 +136,6 @@ ADD_EVENT_SERVICE_SCHEMA = vol.All(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Google component."""
|
||||
if DOMAIN not in config:
|
||||
return True
|
||||
|
||||
conf = config.get(DOMAIN, {})
|
||||
hass.data[DOMAIN] = {DATA_CONFIG: conf}
|
||||
|
||||
if CONF_CLIENT_ID in conf and CONF_CLIENT_SECRET in conf:
|
||||
await async_import_client_credential(
|
||||
hass,
|
||||
DOMAIN,
|
||||
ClientCredential(
|
||||
conf[CONF_CLIENT_ID],
|
||||
conf[CONF_CLIENT_SECRET],
|
||||
),
|
||||
DEVICE_AUTH_IMPL,
|
||||
)
|
||||
|
||||
# Import credentials from the old token file into the new way as
|
||||
# a ConfigEntry managed by home assistant.
|
||||
storage = Storage(hass.config.path(TOKEN_FILE))
|
||||
creds = await hass.async_add_executor_job(storage.get)
|
||||
if creds and get_feature_access(hass).scope in creds.scopes:
|
||||
_LOGGER.debug("Importing configuration entry with credentials")
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={
|
||||
"creds": creds,
|
||||
},
|
||||
)
|
||||
)
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_yaml",
|
||||
breaks_in_ha_version="2022.9.0", # Warning first added in 2022.6.0
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
)
|
||||
if conf.get(CONF_TRACK_NEW) is False:
|
||||
# The track_new as False would previously result in new entries
|
||||
# in google_calendars.yaml with track set to False which is
|
||||
# handled at calendar entity creation time.
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"removed_track_new_yaml",
|
||||
breaks_in_ha_version="2022.6.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="removed_track_new_yaml",
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Google from a config entry."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
|
|
@ -41,15 +41,5 @@
|
|||
},
|
||||
"application_credentials": {
|
||||
"description": "Follow the [instructions]({more_info_url}) for [OAuth consent screen]({oauth_consent_url}) to give Home Assistant access to your Google Calendar. You also need to create Application Credentials linked to your Calendar:\n1. Go to [Credentials]({oauth_creds_url}) and click **Create Credentials**.\n1. From the drop-down list select **OAuth client ID**.\n1. Select **TV and Limited Input devices** for the Application Type.\n\n"
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_yaml": {
|
||||
"title": "The Google Calendar YAML configuration is being removed",
|
||||
"description": "Configuring the Google Calendar in configuration.yaml is being removed in Home Assistant 2022.9.\n\nYour existing OAuth Application Credentials and access settings have been imported into the UI automatically. Remove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
},
|
||||
"removed_track_new_yaml": {
|
||||
"title": "Google Calendar entity tracking has changed",
|
||||
"description": "You have disabled entity tracking for Google Calendar in configuration.yaml, which is no longer supported. You must manually change the integration System Options in the UI to disable newly discovered entities going forward. Remove the track_new setting from configuration.yaml and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue