Use EntityFeature in melcloud

This commit is contained in:
epenet 2022-04-06 11:58:20 +00:00
parent 4a65e54665
commit 792d85bc52
2 changed files with 11 additions and 13 deletions

View file

@ -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

View file

@ -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."""