mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Remove deprecated supported features warning in Humidifier (#132641)
This commit is contained in:
parent
f7ce112653
commit
9ef9f2fafb
@ -170,7 +170,7 @@ class HumidifierEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_AT
|
|||||||
ATTR_MAX_HUMIDITY: self.max_humidity,
|
ATTR_MAX_HUMIDITY: self.max_humidity,
|
||||||
}
|
}
|
||||||
|
|
||||||
if HumidifierEntityFeature.MODES in self.supported_features_compat:
|
if HumidifierEntityFeature.MODES in self.supported_features:
|
||||||
data[ATTR_AVAILABLE_MODES] = self.available_modes
|
data[ATTR_AVAILABLE_MODES] = self.available_modes
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -199,7 +199,7 @@ class HumidifierEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_AT
|
|||||||
if self.target_humidity is not None:
|
if self.target_humidity is not None:
|
||||||
data[ATTR_HUMIDITY] = self.target_humidity
|
data[ATTR_HUMIDITY] = self.target_humidity
|
||||||
|
|
||||||
if HumidifierEntityFeature.MODES in self.supported_features_compat:
|
if HumidifierEntityFeature.MODES in self.supported_features:
|
||||||
data[ATTR_MODE] = self.mode
|
data[ATTR_MODE] = self.mode
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -266,19 +266,6 @@ class HumidifierEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_AT
|
|||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features_compat(self) -> HumidifierEntityFeature:
|
|
||||||
"""Return the supported features as HumidifierEntityFeature.
|
|
||||||
|
|
||||||
Remove this compatibility shim in 2025.1 or later.
|
|
||||||
"""
|
|
||||||
features = self.supported_features
|
|
||||||
if type(features) is int: # noqa: E721
|
|
||||||
new_features = HumidifierEntityFeature(features)
|
|
||||||
self._report_deprecated_supported_features_values(new_features)
|
|
||||||
return new_features
|
|
||||||
return features
|
|
||||||
|
|
||||||
|
|
||||||
async def async_service_humidity_set(
|
async def async_service_humidity_set(
|
||||||
entity: HumidifierEntity, service_call: ServiceCall
|
entity: HumidifierEntity, service_call: ServiceCall
|
||||||
|
@ -6,7 +6,6 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant.components.humidifier import (
|
from homeassistant.components.humidifier import (
|
||||||
ATTR_HUMIDITY,
|
ATTR_HUMIDITY,
|
||||||
ATTR_MODE,
|
|
||||||
DOMAIN as HUMIDIFIER_DOMAIN,
|
DOMAIN as HUMIDIFIER_DOMAIN,
|
||||||
MODE_ECO,
|
MODE_ECO,
|
||||||
MODE_NORMAL,
|
MODE_NORMAL,
|
||||||
@ -51,30 +50,6 @@ async def test_sync_turn_off(hass: HomeAssistant) -> None:
|
|||||||
assert humidifier.turn_off.called
|
assert humidifier.turn_off.called
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
|
|
||||||
"""Test deprecated supported features ints."""
|
|
||||||
|
|
||||||
class MockHumidifierEntity(HumidifierEntity):
|
|
||||||
_attr_mode = "mode1"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return supported features."""
|
|
||||||
return 1
|
|
||||||
|
|
||||||
entity = MockHumidifierEntity()
|
|
||||||
assert entity.supported_features_compat is HumidifierEntityFeature(1)
|
|
||||||
assert "MockHumidifierEntity" in caplog.text
|
|
||||||
assert "is using deprecated supported features values" in caplog.text
|
|
||||||
assert "Instead it should use" in caplog.text
|
|
||||||
assert "HumidifierEntityFeature.MODES" in caplog.text
|
|
||||||
caplog.clear()
|
|
||||||
assert entity.supported_features_compat is HumidifierEntityFeature(1)
|
|
||||||
assert "is using deprecated supported features values" not in caplog.text
|
|
||||||
|
|
||||||
assert entity.state_attributes[ATTR_MODE] == "mode1"
|
|
||||||
|
|
||||||
|
|
||||||
async def test_humidity_validation(
|
async def test_humidity_validation(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
register_test_integration: MockConfigEntry,
|
register_test_integration: MockConfigEntry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user