mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix google assistant request sync service call (#17415)
* Update __init__.py * Add optional agent_user_id field to request_sync service * Update services.yaml
This commit is contained in:
parent
87507c4b6f
commit
4d5338a1b0
@ -33,8 +33,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['http']
|
||||
|
||||
DEFAULT_AGENT_USER_ID = 'home-assistant'
|
||||
|
||||
ENTITY_SCHEMA = vol.Schema({
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_EXPOSE): cv.boolean,
|
||||
@ -70,10 +68,12 @@ async def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
|
||||
websession = async_get_clientsession(hass)
|
||||
try:
|
||||
with async_timeout.timeout(5, loop=hass.loop):
|
||||
agent_user_id = call.data.get('agent_user_id') or \
|
||||
call.context.user_id
|
||||
res = await websession.post(
|
||||
REQUEST_SYNC_BASE_URL,
|
||||
params={'key': api_key},
|
||||
json={'agent_user_id': call.context.user_id})
|
||||
json={'agent_user_id': agent_user_id})
|
||||
_LOGGER.info("Submitted request_sync request to Google")
|
||||
res.raise_for_status()
|
||||
except aiohttp.ClientResponseError:
|
||||
|
@ -1,2 +1,5 @@
|
||||
request_sync:
|
||||
description: Send a request_sync command to Google.
|
||||
fields:
|
||||
agent_user_id:
|
||||
description: Optional. Only needed for automations. Specific Home Assistant user id to sync with Google Assistant. Do not need when you call this service through Home Assistant front end or API. Used in automation script or other place where context.user_id is missing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user