Use EntityFeature enum in components (t**) (#69457)

This commit is contained in:
epenet 2022-04-07 14:07:27 +02:00 committed by GitHub
parent 889e1f4442
commit bbf19582bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 102 additions and 127 deletions

View file

@ -6,7 +6,11 @@ from typing import Any
from tuya_iot import TuyaDevice, TuyaDeviceManager
from homeassistant.components.climate import ClimateEntity, ClimateEntityDescription
from homeassistant.components.climate import (
ClimateEntity,
ClimateEntityDescription,
ClimateEntityFeature,
)
from homeassistant.components.climate.const import (
HVAC_MODE_COOL,
HVAC_MODE_DRY,
@ -14,10 +18,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_HUMIDITY,
SUPPORT_TARGET_TEMPERATURE,
SWING_BOTH,
SWING_HORIZONTAL,
SWING_OFF,
@ -201,7 +201,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
# Get integer type data for the dpcode to set temperature, use
# it to define min, max & step temperatures
if self._set_temperature:
self._attr_supported_features |= SUPPORT_TARGET_TEMPERATURE
self._attr_supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
self._attr_max_temp = self._set_temperature.max_scaled
self._attr_min_temp = self._set_temperature.min_scaled
self._attr_target_temperature_step = self._set_temperature.step_scaled
@ -227,7 +227,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
if int_type := self.find_dpcode(
DPCode.HUMIDITY_SET, dptype=DPType.INTEGER, prefer_function=True
):
self._attr_supported_features |= SUPPORT_TARGET_HUMIDITY
self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
self._set_humidity = int_type
self._attr_min_humidity = int(int_type.min_scaled)
self._attr_max_humidity = int(int_type.max_scaled)
@ -243,7 +243,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
dptype=DPType.ENUM,
prefer_function=True,
):
self._attr_supported_features |= SUPPORT_FAN_MODE
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
self._attr_fan_modes = enum_type.range
# Determine swing modes
@ -256,7 +256,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
),
prefer_function=True,
):
self._attr_supported_features |= SUPPORT_SWING_MODE
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
self._attr_swing_modes = [SWING_OFF]
if self.find_dpcode((DPCode.SHAKE, DPCode.SWING), prefer_function=True):
self._attr_swing_modes.append(SWING_ON)