Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f140c1a

Browse files
Deprecate cloud tts platform config (home-assistant#110461)
* Deprecate cloud tts platform config * Add test
1 parent 8fb04d7 commit f140c1a

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

‎homeassistant/components/cloud/strings.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
}
2525
},
2626
"issues": {
27+
"deprecated_tts_platform_config": {
28+
"title": "The Cloud text-to-speech platform configuration is deprecated",
29+
"description": "The whole `platform: cloud` entry under the `tts:` section in configuration.yaml is deprecated and should be removed. You can use the UI to change settings for the Cloud text-to-speech platform. Please adjust your configuration.yaml and restart Home Assistant to fix this issue."
30+
},
2731
"deprecated_voice": {
2832
"title": "A deprecated voice was used",
2933
"fix_flow": {

‎homeassistant/components/cloud/tts.py‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
Voice,
2121
)
2222
from homeassistant.config_entries import ConfigEntry
23-
from homeassistant.const import Platform
24-
from homeassistant.core import HomeAssistant, callback
23+
from homeassistant.const import CONF_PLATFORM, Platform
24+
from homeassistant.core import HomeAssistant, async_get_hass, callback
25+
import homeassistant.helpers.config_validation as cv
2526
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2627
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
2728
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@@ -39,6 +40,27 @@
3940
_LOGGER = logging.getLogger(__name__)
4041

4142

43+
def _deprecated_platform(value: str) -> str:
44+
"""Validate if platform is deprecated."""
45+
if value == DOMAIN:
46+
_LOGGER.warning(
47+
"The cloud tts platform configuration is deprecated, "
48+
"please remove it from your configuration "
49+
"and use the UI to change settings instead"
50+
)
51+
hass = async_get_hass()
52+
async_create_issue(
53+
hass,
54+
DOMAIN,
55+
"deprecated_tts_platform_config",
56+
breaks_in_ha_version="202490",
57+
is_fixable=False,
58+
severity=IssueSeverity.WARNING,
59+
translation_key="deprecated_tts_platform_config",
60+
)
61+
return value
62+
63+
4264
def validate_lang(value: dict[str, Any]) -> dict[str, Any]:
4365
"""Validate chosen gender or language."""
4466
if (lang := value.get(CONF_LANG)) is None:
@@ -58,6 +80,7 @@ def validate_lang(value: dict[str, Any]) -> dict[str, Any]:
5880
PLATFORM_SCHEMA = vol.All(
5981
TTS_PLATFORM_SCHEMA.extend(
6082
{
83+
vol.Required(CONF_PLATFORM): vol.All(cv.string, _deprecated_platform),
6184
vol.Optional(CONF_LANG): str,
6285
vol.Optional(ATTR_GENDER): str,
6386
}

‎tests/components/cloud/test_tts.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@ async def test_prefs_default_voice(
122122
assert engine.default_options == {"gender": "male", "audio_output": "mp3"}
123123

124124

125+
async def test_deprecated_platform_config(
126+
hass: HomeAssistant,
127+
issue_registry: IssueRegistry,
128+
cloud: MagicMock,
129+
) -> None:
130+
"""Test cloud provider uses the preferences."""
131+
assert await async_setup_component(
132+
hass, TTS_DOMAIN, {TTS_DOMAIN: {"platform": DOMAIN}}
133+
)
134+
await hass.async_block_till_done()
135+
136+
issue = issue_registry.async_get_issue(DOMAIN, "deprecated_tts_platform_config")
137+
assert issue is not None
138+
assert issue.breaks_in_ha_version == "202490"
139+
assert issue.is_fixable is False
140+
assert issue.is_persistent is False
141+
assert issue.severity == IssueSeverity.WARNING
142+
assert issue.translation_key == "deprecated_tts_platform_config"
143+
144+
125145
@pytest.mark.parametrize(
126146
"engine_id",
127147
[

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /