Use EntityFeature enum in components (d**) (#69358)

This commit is contained in:
epenet 2022-04-06 00:00:37 +02:00 committed by GitHub
parent 9e2198fa47
commit c8df2656b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 114 additions and 170 deletions

View file

@ -5,7 +5,11 @@ import logging
import voluptuous as vol
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate import (
PLATFORM_SCHEMA,
ClimateEntity,
ClimateEntityFeature,
)
from homeassistant.components.climate.const import (
ATTR_FAN_MODE,
ATTR_HVAC_MODE,
@ -25,10 +29,6 @@ from homeassistant.components.climate.const import (
PRESET_BOOST,
PRESET_ECO,
PRESET_NONE,
SUPPORT_FAN_MODE,
SUPPORT_PRESET_MODE,
SUPPORT_SWING_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, TEMP_CELSIUS
@ -130,19 +130,19 @@ class DaikinClimate(ClimateEntity):
ATTR_SWING_MODE: self._api.device.swing_modes,
}
self._supported_features = SUPPORT_TARGET_TEMPERATURE
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
if (
self._api.device.support_away_mode
or self._api.device.support_advanced_modes
):
self._supported_features |= SUPPORT_PRESET_MODE
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
if self._api.device.support_fan_rate:
self._supported_features |= SUPPORT_FAN_MODE
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
if self._api.device.support_swing_mode:
self._supported_features |= SUPPORT_SWING_MODE
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
async def _set(self, settings):
"""Set device settings using API."""
@ -172,11 +172,6 @@ class DaikinClimate(ClimateEntity):
if values:
await self._api.device.set(values)
@property
def supported_features(self):
"""Return the list of supported features."""
return self._supported_features
@property
def name(self):
"""Return the name of the thermostat, if any."""