parent
60f067b68f
commit
516c2b0cdb
|
@ -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):
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"config_flow": true,
|
||||
"dependencies": ["application_credentials"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/google_assistant_sdk/",
|
||||
"requirements": ["gassist-text==0.0.5"],
|
||||
"requirements": ["gassist-text==0.0.7"],
|
||||
"codeowners": ["@tronikos"],
|
||||
"iot_class": "cloud_polling",
|
||||
"integration_type": "service"
|
||||
|
|
|
@ -741,7 +741,7 @@ fritzconnection==1.10.3
|
|||
gTTS==2.2.4
|
||||
|
||||
# homeassistant.components.google_assistant_sdk
|
||||
gassist-text==0.0.5
|
||||
gassist-text==0.0.7
|
||||
|
||||
# homeassistant.components.google
|
||||
gcal-sync==4.1.0
|
||||
|
|
|
@ -557,7 +557,7 @@ fritzconnection==1.10.3
|
|||
gTTS==2.2.4
|
||||
|
||||
# homeassistant.components.google_assistant_sdk
|
||||
gassist-text==0.0.5
|
||||
gassist-text==0.0.7
|
||||
|
||||
# homeassistant.components.google
|
||||
gcal-sync==4.1.0
|
||||
|
|
|
@ -41,7 +41,8 @@ async def test_broadcast_one_target(
|
|||
target = "basement"
|
||||
expected_command = "broadcast to basement time for dinner"
|
||||
with patch(
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist"
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist",
|
||||
return_value=["text_response", None],
|
||||
) as mock_assist_call:
|
||||
await hass.services.async_call(
|
||||
notify.DOMAIN,
|
||||
|
@ -64,7 +65,8 @@ async def test_broadcast_two_targets(
|
|||
expected_command1 = "broadcast to basement time for dinner"
|
||||
expected_command2 = "broadcast to master bedroom time for dinner"
|
||||
with patch(
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist"
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist",
|
||||
return_value=["text_response", None],
|
||||
) as mock_assist_call:
|
||||
await hass.services.async_call(
|
||||
notify.DOMAIN,
|
||||
|
@ -84,7 +86,8 @@ async def test_broadcast_empty_message(
|
|||
await setup_integration()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist"
|
||||
"homeassistant.components.google_assistant_sdk.helpers.TextAssistant.assist",
|
||||
return_value=["text_response", None],
|
||||
) as mock_assist_call:
|
||||
await hass.services.async_call(
|
||||
notify.DOMAIN,
|
||||
|
|
Loading…
Reference in New Issue