Google Assistant SDK: Log command and response (#84904)

Log command and response
This commit is contained in:
tronikos 2022-12-31 12:07:31 -08:00 committed by GitHub
parent 82977a43d3
commit d90ec3ccca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 7 deletions

View file

@ -1,6 +1,8 @@
"""Helper classes for Google Assistant SDK integration."""
from __future__ import annotations
import logging
import aiohttp
from gassist_text import TextAssistant
from google.oauth2.credentials import Credentials
@ -12,6 +14,8 @@ from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
from .const import CONF_LANGUAGE_CODE, DOMAIN, SUPPORTED_LANGUAGE_CODES
_LOGGER = logging.getLogger(__name__)
DEFAULT_LANGUAGE_CODES = {
"de": "de-DE",
"en": "en-US",
@ -39,7 +43,8 @@ async def async_send_text_commands(commands: list[str], hass: HomeAssistant) ->
language_code = entry.options.get(CONF_LANGUAGE_CODE, default_language_code(hass))
with TextAssistant(credentials, language_code) as assistant:
for command in commands:
assistant.assist(command)
text_response = assistant.assist(command)[0]
_LOGGER.debug("command: %s\nresponse: %s", command, text_response)
def default_language_code(hass: HomeAssistant):