Use _attr_supported_features in demo climate (#82216)

pull/82259/head
epenet 2022-11-16 21:28:23 +01:00 committed by GitHub
parent 39ac2c1101
commit e37211ad42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 18 deletions

View File

@ -128,26 +128,22 @@ class DemoClimate(ClimateEntity):
"""Initialize the climate device."""
self._unique_id = unique_id
self._attr_name = name
self._support_flags = SUPPORT_FLAGS
self._attr_supported_features = SUPPORT_FLAGS
if target_temperature is not None:
self._support_flags = (
self._support_flags | ClimateEntityFeature.TARGET_TEMPERATURE
)
self._attr_supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
if preset is not None:
self._support_flags = self._support_flags | ClimateEntityFeature.PRESET_MODE
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
if fan_mode is not None:
self._support_flags = self._support_flags | ClimateEntityFeature.FAN_MODE
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
if target_humidity is not None:
self._support_flags = (
self._support_flags | ClimateEntityFeature.TARGET_HUMIDITY
)
self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
if swing_mode is not None:
self._support_flags = self._support_flags | ClimateEntityFeature.SWING_MODE
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
if aux is not None:
self._support_flags = self._support_flags | ClimateEntityFeature.AUX_HEAT
self._attr_supported_features |= ClimateEntityFeature.AUX_HEAT
if HVACMode.HEAT_COOL in hvac_modes or HVACMode.AUTO in hvac_modes:
self._support_flags = (
self._support_flags | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
self._attr_supported_features |= (
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
)
self._target_temperature = target_temperature
self._target_humidity = target_humidity
@ -183,11 +179,6 @@ class DemoClimate(ClimateEntity):
"""Return the unique id."""
return self._unique_id
@property
def supported_features(self) -> int:
"""Return the list of supported features."""
return self._support_flags
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement."""