From 792d85bc528c5a40d790318ce6d230672acdeb57 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 6 Apr 2022 11:58:20 +0000 Subject: [PATCH] Use EntityFeature in melcloud --- homeassistant/components/melcloud/climate.py | 11 +++++------ homeassistant/components/melcloud/water_heater.py | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/melcloud/climate.py b/homeassistant/components/melcloud/climate.py index 4e8c56b3a67..4c085821ee7 100644 --- a/homeassistant/components/melcloud/climate.py +++ b/homeassistant/components/melcloud/climate.py @@ -14,7 +14,7 @@ from pymelcloud.atw_device import ( ) import voluptuous as vol -from homeassistant.components.climate import ClimateEntity +from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature from homeassistant.components.climate.const import ( ATTR_HVAC_MODE, DEFAULT_MAX_TEMP, @@ -25,9 +25,6 @@ from homeassistant.components.climate.const import ( HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, - SUPPORT_FAN_MODE, - SUPPORT_SWING_MODE, - SUPPORT_TARGET_TEMPERATURE, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS @@ -128,7 +125,9 @@ class AtaDeviceClimate(MelCloudClimate): """Air-to-Air climate device.""" _attr_supported_features = ( - SUPPORT_FAN_MODE | SUPPORT_TARGET_TEMPERATURE | SUPPORT_SWING_MODE + ClimateEntityFeature.FAN_MODE + | ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.SWING_MODE ) def __init__(self, device: MelCloudDevice, ata_device: AtaDevice) -> None: @@ -296,7 +295,7 @@ class AtwDeviceZoneClimate(MelCloudClimate): _attr_max_temp = 30 _attr_min_temp = 10 - _attr_supported_features = SUPPORT_TARGET_TEMPERATURE + _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE def __init__( self, device: MelCloudDevice, atw_device: AtwDevice, atw_zone: Zone diff --git a/homeassistant/components/melcloud/water_heater.py b/homeassistant/components/melcloud/water_heater.py index 84bc5d36110..c9075abb008 100644 --- a/homeassistant/components/melcloud/water_heater.py +++ b/homeassistant/components/melcloud/water_heater.py @@ -9,9 +9,8 @@ from pymelcloud.atw_device import ( from pymelcloud.device import PROPERTY_POWER from homeassistant.components.water_heater import ( - SUPPORT_OPERATION_MODE, - SUPPORT_TARGET_TEMPERATURE, WaterHeaterEntity, + WaterHeaterEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS @@ -39,6 +38,11 @@ async def async_setup_entry( class AtwWaterHeater(WaterHeaterEntity): """Air-to-Water water heater.""" + _attr_supported_features = ( + WaterHeaterEntityFeature.TARGET_TEMPERATURE + | WaterHeaterEntityFeature.OPERATION_MODE + ) + def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None: """Initialize water heater device.""" self._api = api @@ -117,11 +121,6 @@ class AtwWaterHeater(WaterHeaterEntity): """Set new target operation mode.""" await self._device.set({PROPERTY_OPERATION_MODE: operation_mode}) - @property - def supported_features(self): - """Return the list of supported features.""" - return SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE - @property def min_temp(self) -> float | None: """Return the minimum temperature."""