mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Avoid custom template platform deprecations (#157415)
This commit is contained in:
@@ -46,6 +46,7 @@ from .const import (
|
||||
CONF_DEFAULT_ENTITY_ID,
|
||||
CONF_PICTURE,
|
||||
DOMAIN,
|
||||
PLATFORMS,
|
||||
)
|
||||
from .entity import AbstractTemplateEntity
|
||||
from .template_entity import TemplateEntity
|
||||
@@ -234,6 +235,8 @@ def create_legacy_template_issue(
|
||||
hass: HomeAssistant, config: ConfigType, domain: str
|
||||
) -> None:
|
||||
"""Create a repair for legacy template entities."""
|
||||
if domain not in PLATFORMS:
|
||||
return
|
||||
|
||||
breadcrumb = "Template Entity"
|
||||
# Default entity id should be in most legacy configuration because
|
||||
|
||||
@@ -13,6 +13,7 @@ from homeassistant.components.template.cover import LEGACY_FIELDS as COVER_LEGAC
|
||||
from homeassistant.components.template.fan import LEGACY_FIELDS as FAN_LEGACY_FIELDS
|
||||
from homeassistant.components.template.helpers import (
|
||||
async_setup_template_platform,
|
||||
create_legacy_template_issue,
|
||||
format_migration_config,
|
||||
rewrite_legacy_to_modern_config,
|
||||
rewrite_legacy_to_modern_configs,
|
||||
@@ -637,3 +638,40 @@ async def test_yaml_config_recursion_depth(hass: HomeAssistant) -> None:
|
||||
|
||||
with pytest.raises(RecursionError):
|
||||
format_migration_config({1: {2: {3: {4: {5: {6: [{7: {8: {9: {10: {}}}}}]}}}}}})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("domain", "config"),
|
||||
[
|
||||
(
|
||||
"media_player",
|
||||
{
|
||||
"media_player": {
|
||||
"platform": "template",
|
||||
"name": "My Media Player",
|
||||
"unique_id": "Foobar",
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
"climate",
|
||||
{
|
||||
"climate": {
|
||||
"platform": "template",
|
||||
"name": "My Climate",
|
||||
"unique_id": "Foobar",
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_custom_integration_deprecation(
|
||||
hass: HomeAssistant,
|
||||
domain: str,
|
||||
config: dict,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test that custom integrations do not create deprecations."""
|
||||
|
||||
create_legacy_template_issue(hass, config, domain)
|
||||
assert len(issue_registry.issues) == 0
|
||||
|
||||
Reference in New Issue
Block a user