Update cloud integration to 0.38.0 (#43314)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
e73d2c65cd
commit
b358103b58
6 changed files with 46 additions and 12 deletions
|
@ -2,7 +2,7 @@
|
|||
"domain": "cloud",
|
||||
"name": "Home Assistant Cloud",
|
||||
"documentation": "https://www.home-assistant.io/integrations/cloud",
|
||||
"requirements": ["hass-nabucasa==0.37.2"],
|
||||
"requirements": ["hass-nabucasa==0.38.0"],
|
||||
"dependencies": ["http", "webhook", "alexa"],
|
||||
"after_dependencies": ["google_assistant"],
|
||||
"codeowners": ["@home-assistant/cloud"]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for the cloud for text to speech service."""
|
||||
|
||||
from hass_nabucasa import Cloud
|
||||
from hass_nabucasa.voice import VoiceError
|
||||
from hass_nabucasa.voice import MAP_VOICE, VoiceError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
||||
|
@ -10,17 +10,36 @@ from .const import DOMAIN
|
|||
|
||||
CONF_GENDER = "gender"
|
||||
|
||||
SUPPORT_LANGUAGES = ["en-US", "de-DE", "es-ES"]
|
||||
SUPPORT_GENDER = ["male", "female"]
|
||||
SUPPORT_LANGUAGES = list({key[0] for key in MAP_VOICE})
|
||||
|
||||
DEFAULT_LANG = "en-US"
|
||||
DEFAULT_GENDER = "female"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
|
||||
vol.Optional(CONF_GENDER, default=DEFAULT_GENDER): vol.In(SUPPORT_GENDER),
|
||||
}
|
||||
|
||||
def validate_lang(value):
|
||||
"""Validate chosen gender or language."""
|
||||
lang = value[CONF_LANG]
|
||||
gender = value.get(CONF_GENDER)
|
||||
|
||||
if gender is None:
|
||||
gender = value[CONF_GENDER] = next(
|
||||
(chk_gender for chk_lang, chk_gender in MAP_VOICE if chk_lang == lang), None
|
||||
)
|
||||
|
||||
if (lang, gender) not in MAP_VOICE:
|
||||
raise vol.Invalid("Unsupported language and gender specified.")
|
||||
|
||||
return value
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_LANG, default=DEFAULT_LANG): str,
|
||||
vol.Optional(CONF_GENDER): str,
|
||||
}
|
||||
),
|
||||
validate_lang,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ cryptography==3.2
|
|||
defusedxml==0.6.0
|
||||
distro==1.5.0
|
||||
emoji==0.5.4
|
||||
hass-nabucasa==0.37.2
|
||||
hass-nabucasa==0.38.0
|
||||
home-assistant-frontend==20201111.1
|
||||
httpx==0.16.1
|
||||
importlib-metadata==1.6.0;python_version<'3.8'
|
||||
|
|
|
@ -735,7 +735,7 @@ habitipy==0.2.0
|
|||
hangups==0.4.11
|
||||
|
||||
# homeassistant.components.cloud
|
||||
hass-nabucasa==0.37.2
|
||||
hass-nabucasa==0.38.0
|
||||
|
||||
# homeassistant.components.splunk
|
||||
hass_splunk==0.1.1
|
||||
|
|
|
@ -376,7 +376,7 @@ ha-ffmpeg==2.0
|
|||
hangups==0.4.11
|
||||
|
||||
# homeassistant.components.cloud
|
||||
hass-nabucasa==0.37.2
|
||||
hass-nabucasa==0.38.0
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.0.30
|
||||
|
|
15
tests/components/cloud/test_tts.py
Normal file
15
tests/components/cloud/test_tts.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
"""Tests for cloud tts."""
|
||||
from homeassistant.components.cloud import tts
|
||||
|
||||
|
||||
def test_schema():
|
||||
"""Test schema."""
|
||||
assert "nl-NL" in tts.SUPPORT_LANGUAGES
|
||||
|
||||
processed = tts.PLATFORM_SCHEMA({"platform": "cloud", "language": "nl-NL"})
|
||||
assert processed["gender"] == "female"
|
||||
|
||||
# Should not raise
|
||||
processed = tts.PLATFORM_SCHEMA(
|
||||
{"platform": "cloud", "language": "nl-NL", "gender": "female"}
|
||||
)
|
Loading…
Add table
Reference in a new issue