mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Enforce ClimateEntityFeature (#82329)
This commit is contained in:
parent
8b54a0679f
commit
48cc3071bb
@ -225,7 +225,7 @@ class ClimateEntity(Entity):
|
|||||||
_attr_precision: float
|
_attr_precision: float
|
||||||
_attr_preset_mode: str | None
|
_attr_preset_mode: str | None
|
||||||
_attr_preset_modes: list[str] | None
|
_attr_preset_modes: list[str] | None
|
||||||
_attr_supported_features: ClimateEntityFeature | int = 0
|
_attr_supported_features: ClimateEntityFeature = ClimateEntityFeature(0)
|
||||||
_attr_swing_mode: str | None
|
_attr_swing_mode: str | None
|
||||||
_attr_swing_modes: list[str] | None
|
_attr_swing_modes: list[str] | None
|
||||||
_attr_target_humidity: int | None = None
|
_attr_target_humidity: int | None = None
|
||||||
@ -552,7 +552,7 @@ class ClimateEntity(Entity):
|
|||||||
await self.async_set_hvac_mode(HVACMode.OFF)
|
await self.async_set_hvac_mode(HVACMode.OFF)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
|
|
||||||
SUPPORT_FLAGS = 0
|
SUPPORT_FLAGS = ClimateEntityFeature(0)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
|
@ -197,9 +197,9 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
|
|||||||
return self._static_info.visual_max_temperature
|
return self._static_info.visual_max_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = 0
|
features = ClimateEntityFeature(0)
|
||||||
if self._static_info.supports_two_point_target_temperature:
|
if self._static_info.supports_two_point_target_temperature:
|
||||||
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
else:
|
else:
|
||||||
|
@ -148,9 +148,9 @@ class HomeKitBaseClimateEntity(HomeKitEntity, ClimateEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = 0
|
features = ClimateEntityFeature(0)
|
||||||
|
|
||||||
if self.service.has(CharacteristicsTypes.FAN_STATE_TARGET):
|
if self.service.has(CharacteristicsTypes.FAN_STATE_TARGET):
|
||||||
features |= ClimateEntityFeature.FAN_MODE
|
features |= ClimateEntityFeature.FAN_MODE
|
||||||
@ -368,7 +368,7 @@ class HomeKitHeaterCoolerEntity(HomeKitBaseClimateEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = super().supported_features
|
features = super().supported_features
|
||||||
|
|
||||||
@ -602,7 +602,7 @@ class HomeKitClimateEntity(HomeKitBaseClimateEntity):
|
|||||||
return [MODE_HOMEKIT_TO_HASS[mode] for mode in valid_values]
|
return [MODE_HOMEKIT_TO_HASS[mode] for mode in valid_values]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = super().supported_features
|
features = super().supported_features
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ class ZoneDevice(ClimateEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@_return_on_connection_error(0)
|
@_return_on_connection_error(0)
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
if self._zone.mode == Zone.Mode.AUTO:
|
if self._zone.mode == Zone.Mode.AUTO:
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
@ -456,7 +456,7 @@ class MqttClimate(MqttEntity, ClimateEntity):
|
|||||||
config.get(key), entity=self
|
config.get(key), entity=self
|
||||||
).async_render
|
).async_render
|
||||||
|
|
||||||
support: ClimateEntityFeature | int = 0
|
support = ClimateEntityFeature(0)
|
||||||
if (self._topic[CONF_TEMP_STATE_TOPIC] is not None) or (
|
if (self._topic[CONF_TEMP_STATE_TOPIC] is not None) or (
|
||||||
self._topic[CONF_TEMP_COMMAND_TOPIC] is not None
|
self._topic[CONF_TEMP_COMMAND_TOPIC] is not None
|
||||||
):
|
):
|
||||||
|
@ -77,9 +77,9 @@ class MySensorsHVAC(mysensors.device.MySensorsEntity, ClimateEntity):
|
|||||||
_attr_hvac_modes = OPERATION_LIST
|
_attr_hvac_modes = OPERATION_LIST
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> ClimateEntityFeature | int:
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = 0
|
features = ClimateEntityFeature(0)
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
if set_req.V_HVAC_SPEED in self._values:
|
if set_req.V_HVAC_SPEED in self._values:
|
||||||
features = features | ClimateEntityFeature.FAN_MODE
|
features = features | ClimateEntityFeature.FAN_MODE
|
||||||
|
@ -104,7 +104,6 @@ class ThermostatEntity(ClimateEntity):
|
|||||||
"""Initialize ThermostatEntity."""
|
"""Initialize ThermostatEntity."""
|
||||||
self._device = device
|
self._device = device
|
||||||
self._device_info = NestDeviceInfo(device)
|
self._device_info = NestDeviceInfo(device)
|
||||||
self._attr_supported_features = 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str | None:
|
def unique_id(self) -> str | None:
|
||||||
@ -266,9 +265,9 @@ class ThermostatEntity(ClimateEntity):
|
|||||||
return FAN_INV_MODES
|
return FAN_INV_MODES
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_supported_features(self) -> int:
|
def _get_supported_features(self) -> ClimateEntityFeature:
|
||||||
"""Compute the bitmap of supported features from the current state."""
|
"""Compute the bitmap of supported features from the current state."""
|
||||||
features = 0
|
features = ClimateEntityFeature(0)
|
||||||
if HVACMode.HEAT_COOL in self.hvac_modes:
|
if HVACMode.HEAT_COOL in self.hvac_modes:
|
||||||
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
if HVACMode.HEAT in self.hvac_modes or HVACMode.COOL in self.hvac_modes:
|
if HVACMode.HEAT in self.hvac_modes or HVACMode.COOL in self.hvac_modes:
|
||||||
|
@ -176,9 +176,9 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
self._attr_supported_features = self.get_features()
|
self._attr_supported_features = self.get_features()
|
||||||
self._attr_precision = PRECISION_TENTHS
|
self._attr_precision = PRECISION_TENTHS
|
||||||
|
|
||||||
def get_features(self) -> ClimateEntityFeature | int:
|
def get_features(self) -> ClimateEntityFeature:
|
||||||
"""Get supported features."""
|
"""Get supported features."""
|
||||||
features = 0
|
features = ClimateEntityFeature(0)
|
||||||
for key in self.device_data.full_features:
|
for key in self.device_data.full_features:
|
||||||
if key in FIELD_TO_FLAG:
|
if key in FIELD_TO_FLAG:
|
||||||
features |= FIELD_TO_FLAG[key]
|
features |= FIELD_TO_FLAG[key]
|
||||||
|
@ -1055,7 +1055,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="supported_features",
|
function_name="supported_features",
|
||||||
return_type=["ClimateEntityFeature", "int"],
|
return_type="ClimateEntityFeature",
|
||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="min_temp",
|
function_name="min_temp",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user