Ignore vacuum entities that properly deprecate battery (#150043)

This commit is contained in:
Joost Lekkerkerker
2025-08-05 15:22:21 +02:00
committed by GitHub
parent 9d8e253ad3
commit ffb2a693f4
2 changed files with 16 additions and 3 deletions

View File

@@ -79,6 +79,8 @@ DEFAULT_NAME = "Vacuum cleaner robot"
_DEPRECATED_STATE_IDLE = DeprecatedConstantEnum(VacuumActivity.IDLE, "2026.1")
_DEPRECATED_STATE_PAUSED = DeprecatedConstantEnum(VacuumActivity.PAUSED, "2026.1")
_BATTERY_DEPRECATION_IGNORED_PLATFORMS = ("template",)
class VacuumEntityFeature(IntFlag):
"""Supported features of the vacuum entity."""
@@ -321,7 +323,11 @@ class StateVacuumEntity(
Integrations should implement a sensor instead.
"""
if self.platform:
if (
self.platform
and self.platform.platform_name
not in _BATTERY_DEPRECATION_IGNORED_PLATFORMS
):
# Don't report usage until after entity added to hass, after init
report_usage(
f"is setting the {property} which has been deprecated."
@@ -341,7 +347,11 @@ class StateVacuumEntity(
Integrations should remove the battery supported feature when migrating
battery level and icon to a sensor.
"""
if self.platform:
if (
self.platform
and self.platform.platform_name
not in _BATTERY_DEPRECATION_IGNORED_PLATFORMS
):
# Don't report usage until after entity added to hass, after init
report_usage(
f"is setting the battery supported feature which has been deprecated."

View File

@@ -603,7 +603,9 @@ async def test_battery_level_template(
)
@pytest.mark.usefixtures("setup_single_attribute_state_vacuum")
async def test_battery_level_template_repair(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
hass: HomeAssistant,
issue_registry: ir.IssueRegistry,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test battery_level template raises issue."""
# Ensure trigger entity templates are rendered
@@ -618,6 +620,7 @@ async def test_battery_level_template_repair(
assert issue.severity == ir.IssueSeverity.WARNING
assert issue.translation_placeholders["entity_name"] == TEST_OBJECT_ID
assert issue.translation_placeholders["entity_id"] == TEST_ENTITY_ID
assert "Detected that integration 'template' is setting the" not in caplog.text
@pytest.mark.parametrize(