1
0
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:
Petro31
2025-11-27 12:06:29 -05:00
committed by Franck Nijhof
parent e30707ad5e
commit 348c8bca7c
2 changed files with 41 additions and 0 deletions

View File

@@ -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

View File

@@ -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