mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Don't log deprecation warning in vacuum until after entity added to hass (#147959)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
parent
8007bf1c31
commit
a46cc82916
@ -321,6 +321,8 @@ class StateVacuumEntity(
|
||||
|
||||
Integrations should implement a sensor instead.
|
||||
"""
|
||||
if self.platform:
|
||||
# Don't report usage until after entity added to hass, after init
|
||||
report_usage(
|
||||
f"is setting the {property} which has been deprecated."
|
||||
f" Integration {self.platform.platform_name} should implement a sensor"
|
||||
@ -328,7 +330,7 @@ class StateVacuumEntity(
|
||||
core_integration_behavior=ReportBehavior.LOG,
|
||||
custom_integration_behavior=ReportBehavior.LOG,
|
||||
breaks_in_ha_version="2026.8",
|
||||
integration_domain=self.platform.platform_name if self.platform else None,
|
||||
integration_domain=self.platform.platform_name,
|
||||
exclude_integrations={DOMAIN},
|
||||
)
|
||||
|
||||
@ -339,6 +341,8 @@ class StateVacuumEntity(
|
||||
Integrations should remove the battery supported feature when migrating
|
||||
battery level and icon to a sensor.
|
||||
"""
|
||||
if self.platform:
|
||||
# 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."
|
||||
f" Integration {self.platform.platform_name} should remove this as part of migrating"
|
||||
@ -347,7 +351,7 @@ class StateVacuumEntity(
|
||||
core_integration_behavior=ReportBehavior.LOG,
|
||||
custom_integration_behavior=ReportBehavior.LOG,
|
||||
breaks_in_ha_version="2026.8",
|
||||
integration_domain=self.platform.platform_name if self.platform else None,
|
||||
integration_domain=self.platform.platform_name,
|
||||
exclude_integrations={DOMAIN},
|
||||
)
|
||||
|
||||
|
@ -562,16 +562,10 @@ async def test_vacuum_log_deprecated_battery_properties_using_attr(
|
||||
# Test we only log once
|
||||
assert (
|
||||
"Detected that custom integration 'test' is setting the battery_level which has been deprecated."
|
||||
" Integration test should implement a sensor instead with a correct device class and link it to"
|
||||
" the same device. This will stop working in Home Assistant 2026.8,"
|
||||
" please report it to the author of the 'test' custom integration"
|
||||
not in caplog.text
|
||||
)
|
||||
assert (
|
||||
"Detected that custom integration 'test' is setting the battery_icon which has been deprecated."
|
||||
" Integration test should implement a sensor instead with a correct device class and link it to"
|
||||
" the same device. This will stop working in Home Assistant 2026.8,"
|
||||
" please report it to the author of the 'test' custom integration"
|
||||
not in caplog.text
|
||||
)
|
||||
|
||||
@ -613,3 +607,34 @@ async def test_vacuum_log_deprecated_battery_supported_feature(
|
||||
", please report it to the author of the 'test' custom integration"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
async def test_vacuum_not_log_deprecated_battery_properties_during_init(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test not logging deprecation until after added to hass."""
|
||||
|
||||
class MockLegacyVacuum(MockVacuum):
|
||||
"""Mocked vacuum entity."""
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
"""Initialize a mock vacuum entity."""
|
||||
super().__init__(**kwargs)
|
||||
self._attr_battery_level = 50
|
||||
|
||||
@property
|
||||
def activity(self) -> str:
|
||||
"""Return the state of the entity."""
|
||||
return VacuumActivity.CLEANING
|
||||
|
||||
entity = MockLegacyVacuum(
|
||||
name="Testing",
|
||||
entity_id="vacuum.test",
|
||||
)
|
||||
assert entity.battery_level == 50
|
||||
|
||||
assert (
|
||||
"Detected that custom integration 'test' is setting the battery_level which has been deprecated."
|
||||
not in caplog.text
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user