mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 06:15:47 -04:00
Somewhat stable id
This commit is contained in:
@@ -119,10 +119,16 @@ async def yaml_deprecation_notice(hass: HomeAssistant, config: ConfigType) -> No
|
||||
yaml_config = yaml_util.dump(platform_config)
|
||||
yaml_config = yaml_config.replace("\n", "\n ")
|
||||
yaml_config = "```yaml\nsensor:\n - platform: group\n " + yaml_config + "\n```"
|
||||
|
||||
issue_id = "yaml_deprecated-"
|
||||
if platform_config.get(CONF_UNIQUE_ID):
|
||||
issue_id += f"{platform_config[CONF_UNIQUE_ID]}"
|
||||
else:
|
||||
issue_id += ulid_util.ulid()
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
ulid_util.ulid(),
|
||||
issue_id,
|
||||
breaks_in_ha_version="2026.12.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
|
||||
@@ -47,22 +47,35 @@ async def test_deprecation_warning(
|
||||
) -> None:
|
||||
"""Test the min sensor with a default name."""
|
||||
config = {
|
||||
"sensor": {
|
||||
"platform": "min_max",
|
||||
"type": "min",
|
||||
"entity_ids": ["sensor.test_1", "sensor.test_2", "sensor.test_3"],
|
||||
}
|
||||
"sensor": [
|
||||
{
|
||||
"platform": "min_max",
|
||||
"type": "min",
|
||||
"entity_ids": ["sensor.test_1", "sensor.test_2", "sensor.test_3"],
|
||||
},
|
||||
{
|
||||
"platform": "min_max",
|
||||
"type": "min",
|
||||
"entity_ids": ["sensor.test_1", "sensor.test_2", "sensor.test_3"],
|
||||
"unique_id": "my_unique_id",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
with patch("homeassistant.util.ulid.ulid", return_value="1234"):
|
||||
assert await async_setup_component(hass, "sensor", config)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "1234")
|
||||
# Use ulid for issue id when unique_id is not set
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "yaml_deprecated-1234")
|
||||
assert issue is not None
|
||||
assert issue.severity == ir.IssueSeverity.WARNING
|
||||
assert issue.translation_key == "yaml_deprecated"
|
||||
|
||||
# Use unique_id for issue id if exist
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "yaml_deprecated-my_unique_id")
|
||||
assert issue is not None
|
||||
|
||||
|
||||
async def test_default_name_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the min sensor with a default name."""
|
||||
|
||||
Reference in New Issue
Block a user