mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Adjust HumidifierEntity type hints (#82248)
This commit is contained in:
parent
38a8e86dde
commit
2453f95b24
@ -147,7 +147,6 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
|
|||||||
self._min_humidity = min_humidity
|
self._min_humidity = min_humidity
|
||||||
self._max_humidity = max_humidity
|
self._max_humidity = max_humidity
|
||||||
self._target_humidity = target_humidity
|
self._target_humidity = target_humidity
|
||||||
self._attr_supported_features = 0
|
|
||||||
if away_humidity:
|
if away_humidity:
|
||||||
self._attr_supported_features |= HumidifierEntityFeature.MODES
|
self._attr_supported_features |= HumidifierEntityFeature.MODES
|
||||||
self._away_humidity = away_humidity
|
self._away_humidity = away_humidity
|
||||||
|
@ -137,6 +137,7 @@ class HumidifierEntity(ToggleEntity):
|
|||||||
_attr_max_humidity: int = DEFAULT_MAX_HUMIDITY
|
_attr_max_humidity: int = DEFAULT_MAX_HUMIDITY
|
||||||
_attr_min_humidity: int = DEFAULT_MIN_HUMIDITY
|
_attr_min_humidity: int = DEFAULT_MIN_HUMIDITY
|
||||||
_attr_mode: str | None
|
_attr_mode: str | None
|
||||||
|
_attr_supported_features: HumidifierEntityFeature | int = 0
|
||||||
_attr_target_humidity: int | None = None
|
_attr_target_humidity: int | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -223,3 +224,8 @@ class HumidifierEntity(ToggleEntity):
|
|||||||
def max_humidity(self) -> int:
|
def max_humidity(self) -> int:
|
||||||
"""Return the maximum humidity."""
|
"""Return the maximum humidity."""
|
||||||
return self._attr_max_humidity
|
return self._attr_max_humidity
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self) -> HumidifierEntityFeature | int:
|
||||||
|
"""Return the list of supported features."""
|
||||||
|
return self._attr_supported_features
|
||||||
|
@ -271,8 +271,6 @@ class MqttHumidifier(MqttEntity, HumidifierEntity):
|
|||||||
self._attr_available_modes = []
|
self._attr_available_modes = []
|
||||||
if self._attr_available_modes:
|
if self._attr_available_modes:
|
||||||
self._attr_supported_features = HumidifierEntityFeature.MODES
|
self._attr_supported_features = HumidifierEntityFeature.MODES
|
||||||
else:
|
|
||||||
self._attr_supported_features = 0
|
|
||||||
|
|
||||||
optimistic: bool = config[CONF_OPTIMISTIC]
|
optimistic: bool = config[CONF_OPTIMISTIC]
|
||||||
self._optimistic = optimistic or self._topic[CONF_STATE_TOPIC] is None
|
self._optimistic = optimistic or self._topic[CONF_STATE_TOPIC] is None
|
||||||
|
@ -93,7 +93,6 @@ class TuyaHumidifierEntity(TuyaEntity, HumidifierEntity):
|
|||||||
super().__init__(device, device_manager)
|
super().__init__(device, device_manager)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
||||||
self._attr_supported_features = 0
|
|
||||||
|
|
||||||
# Determine main switch DPCode
|
# Determine main switch DPCode
|
||||||
self._switch_dpcode = self.find_dpcode(
|
self._switch_dpcode = self.find_dpcode(
|
||||||
|
@ -115,7 +115,6 @@ class XiaomiGenericHumidifier(XiaomiCoordinatedMiioEntity, HumidifierEntity):
|
|||||||
|
|
||||||
_attr_device_class = HumidifierDeviceClass.HUMIDIFIER
|
_attr_device_class = HumidifierDeviceClass.HUMIDIFIER
|
||||||
_attr_supported_features = HumidifierEntityFeature.MODES
|
_attr_supported_features = HumidifierEntityFeature.MODES
|
||||||
supported_features: int
|
|
||||||
|
|
||||||
def __init__(self, device, entry, unique_id, coordinator):
|
def __init__(self, device, entry, unique_id, coordinator):
|
||||||
"""Initialize the generic Xiaomi device."""
|
"""Initialize the generic Xiaomi device."""
|
||||||
|
@ -1395,6 +1395,61 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
"humidifier": [
|
||||||
|
ClassTypeHintMatch(
|
||||||
|
base_class="Entity",
|
||||||
|
matches=_ENTITY_MATCH,
|
||||||
|
),
|
||||||
|
ClassTypeHintMatch(
|
||||||
|
base_class="ToggleEntity",
|
||||||
|
matches=_TOGGLE_ENTITY_MATCH,
|
||||||
|
),
|
||||||
|
ClassTypeHintMatch(
|
||||||
|
base_class="HumidifierEntity",
|
||||||
|
matches=[
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="available_modes",
|
||||||
|
return_type=["list[str]", None],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="device_class",
|
||||||
|
return_type=["HumidifierDeviceClass", "str", None],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="min_humidity",
|
||||||
|
return_type=["int"],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="max_humidity",
|
||||||
|
return_type=["int"],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="mode",
|
||||||
|
return_type=["str", None],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="supported_features",
|
||||||
|
return_type=["HumidifierEntityFeature", "int"],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="target_humidity",
|
||||||
|
return_type=["int", None],
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="set_humidity",
|
||||||
|
arg_types={1: "str"},
|
||||||
|
return_type=None,
|
||||||
|
has_async_counterpart=True,
|
||||||
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="set_mode",
|
||||||
|
arg_types={1: "str"},
|
||||||
|
return_type=None,
|
||||||
|
has_async_counterpart=True,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
"light": [
|
"light": [
|
||||||
ClassTypeHintMatch(
|
ClassTypeHintMatch(
|
||||||
base_class="Entity",
|
base_class="Entity",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user