Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated CONF_ALLOW_UNLOCK, CONF_API_KEY from Google Assistant #44087

Merged
merged 3 commits into from Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions homeassistant/components/google_assistant/__init__.py
Expand Up @@ -11,8 +11,6 @@

from .const import (
CONF_ALIASES,
CONF_ALLOW_UNLOCK,
CONF_API_KEY,
CONF_CLIENT_EMAIL,
CONF_ENTITY_CONFIG,
CONF_EXPOSE,
Expand Down Expand Up @@ -61,8 +59,6 @@ def _check_report_state(data):


GOOGLE_ASSISTANT_SCHEMA = vol.All(
cv.deprecated(CONF_ALLOW_UNLOCK, invalidation_version="0.95"),
cv.deprecated(CONF_API_KEY, invalidation_version="0.105"),
hmmbob marked this conversation as resolved.
Show resolved Hide resolved
vol.Schema(
{
vol.Required(CONF_PROJECT_ID): cv.string,
Expand All @@ -72,13 +68,13 @@ def _check_report_state(data):
vol.Optional(
CONF_EXPOSED_DOMAINS, default=DEFAULT_EXPOSED_DOMAINS
): cv.ensure_list,
vol.Optional(CONF_API_KEY): cv.string,
vol.Optional(CONF_ENTITY_CONFIG): {cv.entity_id: ENTITY_SCHEMA},
vol.Optional(CONF_ALLOW_UNLOCK): cv.boolean,
# str on purpose, makes sure it is configured correctly.
vol.Optional(CONF_SECURE_DEVICES_PIN): str,
vol.Optional(CONF_REPORT_STATE, default=False): cv.boolean,
vol.Optional(CONF_SERVICE_ACCOUNT): GOOGLE_SERVICE_ACCOUNT,
vol.Remove("allow_unlock"): cv.boolean,
vol.Remove("api_key"): cv.string,
hmmbob marked this conversation as resolved.
Show resolved Hide resolved
},
extra=vol.PREVENT_EXTRA,
),
Expand Down Expand Up @@ -113,7 +109,7 @@ async def request_sync_service_handler(call: ServiceCall):
await google_config.async_sync_entities(agent_user_id)

# Register service only if key is provided
if CONF_API_KEY in config or CONF_SERVICE_ACCOUNT in config:
if CONF_SERVICE_ACCOUNT in config:
hass.services.async_register(
DOMAIN, SERVICE_REQUEST_SYNC, request_sync_service_handler
)
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/google_assistant/const.py
Expand Up @@ -30,9 +30,7 @@
CONF_EXPOSED_DOMAINS = "exposed_domains"
CONF_PROJECT_ID = "project_id"
CONF_ALIASES = "aliases"
CONF_API_KEY = "api_key"
CONF_ROOM_HINT = "room"
CONF_ALLOW_UNLOCK = "allow_unlock"
CONF_SECURE_DEVICES_PIN = "secure_devices_pin"
CONF_REPORT_STATE = "report_state"
CONF_SERVICE_ACCOUNT = "service_account"
Expand Down
26 changes: 1 addition & 25 deletions homeassistant/components/google_assistant/http.py
Expand Up @@ -19,7 +19,6 @@
from homeassistant.util import dt as dt_util

from .const import (
CONF_API_KEY,
CONF_CLIENT_EMAIL,
CONF_ENTITY_CONFIG,
CONF_EXPOSE,
Expand Down Expand Up @@ -135,11 +134,7 @@ def should_2fa(self, state):
return True

async def _async_request_sync_devices(self, agent_user_id: str):
if CONF_API_KEY in self._config:
await self.async_call_homegraph_api_key(
REQUEST_SYNC_BASE_URL, {"agentUserId": agent_user_id}
)
elif CONF_SERVICE_ACCOUNT in self._config:
if CONF_SERVICE_ACCOUNT in self._config:
await self.async_call_homegraph_api(
REQUEST_SYNC_BASE_URL, {"agentUserId": agent_user_id}
)
Expand All @@ -164,25 +159,6 @@ async def _async_update_token(self, force=False):
self._access_token = token["access_token"]
self._access_token_renew = now + timedelta(seconds=token["expires_in"])

async def async_call_homegraph_api_key(self, url, data):
"""Call a homegraph api with api key authentication."""
websession = async_get_clientsession(self.hass)
try:
res = await websession.post(
url, params={"key": self._config.get(CONF_API_KEY)}, json=data
)
_LOGGER.debug(
"Response on %s with data %s was %s", url, data, await res.text()
)
res.raise_for_status()
return res.status
except ClientResponseError as error:
_LOGGER.error("Request for %s failed: %d", url, error.status)
return error.status
except (asyncio.TimeoutError, ClientError):
_LOGGER.error("Could not contact %s", url)
return HTTP_INTERNAL_SERVER_ERROR

async def async_call_homegraph_api(self, url, data):
"""Call a homegraph api with authentication."""
session = async_get_clientsession(self.hass)
Expand Down