mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Adjust deprecation in water heater (#136577)
This commit is contained in:
parent
653ff47171
commit
83b34c6faf
@ -25,7 +25,12 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import deprecated_class
|
from homeassistant.helpers.deprecation import (
|
||||||
|
DeprecatedConstant,
|
||||||
|
all_with_deprecated_constants,
|
||||||
|
check_if_deprecated_constant,
|
||||||
|
dir_with_deprecated_constants,
|
||||||
|
)
|
||||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.temperature import display_temp as show_temp
|
from homeassistant.helpers.temperature import display_temp as show_temp
|
||||||
@ -134,11 +139,11 @@ class WaterHeaterEntityDescription(EntityDescription, frozen_or_thawed=True):
|
|||||||
"""A class that describes water heater entities."""
|
"""A class that describes water heater entities."""
|
||||||
|
|
||||||
|
|
||||||
@deprecated_class("WaterHeaterEntityDescription", breaks_in_ha_version="2026.1")
|
_DEPRECATED_WaterHeaterEntityEntityDescription = DeprecatedConstant(
|
||||||
class WaterHeaterEntityEntityDescription(
|
WaterHeaterEntityDescription,
|
||||||
WaterHeaterEntityDescription, frozen_or_thawed=True
|
"WaterHeaterEntityDescription",
|
||||||
):
|
breaks_in_ha_version="2026.1",
|
||||||
"""A (deprecated) class that describes water heater entities."""
|
)
|
||||||
|
|
||||||
|
|
||||||
CACHED_PROPERTIES_WITH_ATTR_ = {
|
CACHED_PROPERTIES_WITH_ATTR_ = {
|
||||||
@ -414,3 +419,11 @@ async def async_service_temperature_set(
|
|||||||
kwargs[value] = temp
|
kwargs[value] = temp
|
||||||
|
|
||||||
await entity.async_set_temperature(**kwargs)
|
await entity.async_set_temperature(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
# These can be removed if no deprecated constant are in this module anymore
|
||||||
|
__getattr__ = ft.partial(check_if_deprecated_constant, module_globals=globals())
|
||||||
|
__dir__ = ft.partial(
|
||||||
|
dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
|
||||||
|
)
|
||||||
|
__all__ = all_with_deprecated_constants(globals())
|
||||||
|
@ -2,19 +2,20 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import AsyncMock, MagicMock
|
from unittest.mock import AsyncMock, MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components import water_heater
|
||||||
from homeassistant.components.water_heater import (
|
from homeassistant.components.water_heater import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_OPERATION_MODE,
|
SERVICE_SET_OPERATION_MODE,
|
||||||
SET_TEMPERATURE_SCHEMA,
|
SET_TEMPERATURE_SCHEMA,
|
||||||
WaterHeaterEntity,
|
WaterHeaterEntity,
|
||||||
WaterHeaterEntityDescription,
|
WaterHeaterEntityDescription,
|
||||||
WaterHeaterEntityEntityDescription,
|
|
||||||
WaterHeaterEntityFeature,
|
WaterHeaterEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -29,6 +30,7 @@ from tests.common import (
|
|||||||
MockModule,
|
MockModule,
|
||||||
MockPlatform,
|
MockPlatform,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
import_and_test_deprecated_constant,
|
||||||
mock_integration,
|
mock_integration,
|
||||||
mock_platform,
|
mock_platform,
|
||||||
)
|
)
|
||||||
@ -209,12 +211,27 @@ async def test_operation_mode_validation(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("class_name", "expected_log"),
|
("constant_name", "replacement_name", "replacement"),
|
||||||
[(WaterHeaterEntityDescription, False), (WaterHeaterEntityEntityDescription, True)],
|
[
|
||||||
|
(
|
||||||
|
"WaterHeaterEntityEntityDescription",
|
||||||
|
"WaterHeaterEntityDescription",
|
||||||
|
WaterHeaterEntityDescription,
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
async def test_deprecated_entity_description(
|
def test_deprecated_constants(
|
||||||
caplog: pytest.LogCaptureFixture, class_name: type, expected_log: bool
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
constant_name: str,
|
||||||
|
replacement_name: str,
|
||||||
|
replacement: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test deprecated WaterHeaterEntityEntityDescription logs warning."""
|
"""Test deprecated automation constants."""
|
||||||
class_name(key="test")
|
import_and_test_deprecated_constant(
|
||||||
assert ("is a deprecated class" in caplog.text) is expected_log
|
caplog,
|
||||||
|
water_heater,
|
||||||
|
constant_name,
|
||||||
|
replacement_name,
|
||||||
|
replacement,
|
||||||
|
"2026.1",
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user