Remove deprecated supported features warning in WaterHeater (#132668)
parent
57d5d7d2f2
commit
5e8012f3f5
|
@ -194,7 +194,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||
),
|
||||
}
|
||||
|
||||
if WaterHeaterEntityFeature.OPERATION_MODE in self.supported_features_compat:
|
||||
if WaterHeaterEntityFeature.OPERATION_MODE in self.supported_features:
|
||||
data[ATTR_OPERATION_LIST] = self.operation_list
|
||||
|
||||
return data
|
||||
|
@ -230,7 +230,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||
),
|
||||
}
|
||||
|
||||
supported_features = self.supported_features_compat
|
||||
supported_features = self.supported_features
|
||||
|
||||
if WaterHeaterEntityFeature.OPERATION_MODE in supported_features:
|
||||
data[ATTR_OPERATION_MODE] = self.current_operation
|
||||
|
@ -379,19 +379,6 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||
"""Return the list of supported features."""
|
||||
return self._attr_supported_features
|
||||
|
||||
@property
|
||||
def supported_features_compat(self) -> WaterHeaterEntityFeature:
|
||||
"""Return the supported features as WaterHeaterEntityFeature.
|
||||
|
||||
Remove this compatibility shim in 2025.1 or later.
|
||||
"""
|
||||
features = self.supported_features
|
||||
if type(features) is int: # noqa: E721
|
||||
new_features = WaterHeaterEntityFeature(features)
|
||||
self._report_deprecated_supported_features_values(new_features)
|
||||
return new_features
|
||||
return features
|
||||
|
||||
|
||||
async def async_service_away_mode(
|
||||
entity: WaterHeaterEntity, service: ServiceCall
|
||||
|
|
|
@ -9,8 +9,6 @@ import pytest
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
ATTR_OPERATION_LIST,
|
||||
ATTR_OPERATION_MODE,
|
||||
DOMAIN,
|
||||
SERVICE_SET_OPERATION_MODE,
|
||||
SET_TEMPERATURE_SCHEMA,
|
||||
|
@ -206,28 +204,3 @@ async def test_operation_mode_validation(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
water_heater_entity.set_operation_mode.assert_has_calls([mock.call("eco")])
|
||||
|
||||
|
||||
def test_deprecated_supported_features_ints(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test deprecated supported features ints."""
|
||||
|
||||
class MockWaterHeaterEntity(WaterHeaterEntity):
|
||||
_attr_operation_list = ["mode1", "mode2"]
|
||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
_attr_current_operation = "mode1"
|
||||
_attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE.value
|
||||
|
||||
entity = MockWaterHeaterEntity()
|
||||
entity.hass = hass
|
||||
assert entity.supported_features_compat is WaterHeaterEntityFeature(2)
|
||||
assert "MockWaterHeaterEntity" in caplog.text
|
||||
assert "is using deprecated supported features values" in caplog.text
|
||||
assert "Instead it should use" in caplog.text
|
||||
assert "WaterHeaterEntityFeature.OPERATION_MODE" in caplog.text
|
||||
caplog.clear()
|
||||
assert entity.supported_features_compat is WaterHeaterEntityFeature(2)
|
||||
assert "is using deprecated supported features values" not in caplog.text
|
||||
assert entity.state_attributes[ATTR_OPERATION_MODE] == "mode1"
|
||||
assert entity.capability_attributes[ATTR_OPERATION_LIST] == ["mode1", "mode2"]
|
||||
|
|
Loading…
Reference in New Issue