mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Deprecate deprecated water_heater constants (#106226)
This commit is contained in:
parent
e18d2b8873
commit
06220849fc
@ -28,6 +28,11 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
|||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
PLATFORM_SCHEMA_BASE,
|
PLATFORM_SCHEMA_BASE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.deprecation import (
|
||||||
|
DeprecatedConstantEnum,
|
||||||
|
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
|
||||||
@ -65,9 +70,19 @@ class WaterHeaterEntityFeature(IntFlag):
|
|||||||
|
|
||||||
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
|
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
|
||||||
# Please use the WaterHeaterEntityFeature enum instead.
|
# Please use the WaterHeaterEntityFeature enum instead.
|
||||||
SUPPORT_TARGET_TEMPERATURE = 1
|
_DEPRECATED_SUPPORT_TARGET_TEMPERATURE = DeprecatedConstantEnum(
|
||||||
SUPPORT_OPERATION_MODE = 2
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE, "2025.1"
|
||||||
SUPPORT_AWAY_MODE = 4
|
)
|
||||||
|
_DEPRECATED_SUPPORT_OPERATION_MODE = DeprecatedConstantEnum(
|
||||||
|
WaterHeaterEntityFeature.OPERATION_MODE, "2025.1"
|
||||||
|
)
|
||||||
|
_DEPRECATED_SUPPORT_AWAY_MODE = DeprecatedConstantEnum(
|
||||||
|
WaterHeaterEntityFeature.AWAY_MODE, "2025.1"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Both 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=globals())
|
||||||
|
|
||||||
ATTR_MAX_TEMP = "max_temp"
|
ATTR_MAX_TEMP = "max_temp"
|
||||||
ATTR_MIN_TEMP = "min_temp"
|
ATTR_MIN_TEMP = "min_temp"
|
||||||
|
@ -6,6 +6,7 @@ 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 (
|
||||||
SET_TEMPERATURE_SCHEMA,
|
SET_TEMPERATURE_SCHEMA,
|
||||||
WaterHeaterEntity,
|
WaterHeaterEntity,
|
||||||
@ -13,7 +14,7 @@ from homeassistant.components.water_heater import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import async_mock_service
|
from tests.common import async_mock_service, import_and_test_deprecated_constant_enum
|
||||||
|
|
||||||
|
|
||||||
async def test_set_temp_schema_no_req(
|
async def test_set_temp_schema_no_req(
|
||||||
@ -96,3 +97,21 @@ async def test_sync_turn_off(hass: HomeAssistant) -> None:
|
|||||||
await water_heater.async_turn_off()
|
await water_heater.async_turn_off()
|
||||||
|
|
||||||
assert water_heater.async_turn_off.call_count == 1
|
assert water_heater.async_turn_off.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("enum"),
|
||||||
|
[
|
||||||
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE,
|
||||||
|
WaterHeaterEntityFeature.OPERATION_MODE,
|
||||||
|
WaterHeaterEntityFeature.AWAY_MODE,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_deprecated_constants(
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
enum: WaterHeaterEntityFeature,
|
||||||
|
) -> None:
|
||||||
|
"""Test deprecated constants."""
|
||||||
|
import_and_test_deprecated_constant_enum(
|
||||||
|
caplog, water_heater, enum, "SUPPORT_", "2025.1"
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user