Update typing 10 (#48071)
This commit is contained in:
parent
00dca88024
commit
25a13d1554
73 changed files with 412 additions and 333 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Platform for climate integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any
|
||||
|
||||
from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW, AtaDevice, AtwDevice
|
||||
import pymelcloud.ata_device as ata
|
||||
|
@ -114,7 +116,7 @@ class MelCloudClimate(ClimateEntity):
|
|||
return self.api.device_info
|
||||
|
||||
@property
|
||||
def target_temperature_step(self) -> Optional[float]:
|
||||
def target_temperature_step(self) -> float | None:
|
||||
"""Return the supported step of target temperature."""
|
||||
return self._base_device.temperature_increment
|
||||
|
||||
|
@ -128,7 +130,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
self._device = ata_device
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID."""
|
||||
return f"{self.api.device.serial}-{self.api.device.mac}"
|
||||
|
||||
|
@ -138,7 +140,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Optional[Dict[str, Any]]:
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the optional state attributes with device specific additions."""
|
||||
attr = {}
|
||||
|
||||
|
@ -190,19 +192,19 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
await self._device.set(props)
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> List[str]:
|
||||
def hvac_modes(self) -> list[str]:
|
||||
"""Return the list of available hvac operation modes."""
|
||||
return [HVAC_MODE_OFF] + [
|
||||
ATA_HVAC_MODE_LOOKUP.get(mode) for mode in self._device.operation_modes
|
||||
]
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> Optional[float]:
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
return self._device.room_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> Optional[float]:
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._device.target_temperature
|
||||
|
||||
|
@ -213,7 +215,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
)
|
||||
|
||||
@property
|
||||
def fan_mode(self) -> Optional[str]:
|
||||
def fan_mode(self) -> str | None:
|
||||
"""Return the fan setting."""
|
||||
return self._device.fan_speed
|
||||
|
||||
|
@ -222,7 +224,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
await self._device.set({"fan_speed": fan_mode})
|
||||
|
||||
@property
|
||||
def fan_modes(self) -> Optional[List[str]]:
|
||||
def fan_modes(self) -> list[str] | None:
|
||||
"""Return the list of available fan modes."""
|
||||
return self._device.fan_speeds
|
||||
|
||||
|
@ -243,7 +245,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
await self._device.set({ata.PROPERTY_VANE_VERTICAL: position})
|
||||
|
||||
@property
|
||||
def swing_mode(self) -> Optional[str]:
|
||||
def swing_mode(self) -> str | None:
|
||||
"""Return vertical vane position or mode."""
|
||||
return self._device.vane_vertical
|
||||
|
||||
|
@ -252,7 +254,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
await self.async_set_vane_vertical(swing_mode)
|
||||
|
||||
@property
|
||||
def swing_modes(self) -> Optional[str]:
|
||||
def swing_modes(self) -> str | None:
|
||||
"""Return a list of available vertical vane positions and modes."""
|
||||
return self._device.vane_vertical_positions
|
||||
|
||||
|
@ -300,7 +302,7 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
self._zone = atw_zone
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID."""
|
||||
return f"{self.api.device.serial}-{self._zone.zone_index}"
|
||||
|
||||
|
@ -310,7 +312,7 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
return f"{self._name} {self._zone.name}"
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Dict[str, Any]:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the optional state attributes with device specific additions."""
|
||||
data = {
|
||||
ATTR_STATUS: ATW_ZONE_HVAC_MODE_LOOKUP.get(
|
||||
|
@ -351,17 +353,17 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
await self._device.set(props)
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> List[str]:
|
||||
def hvac_modes(self) -> list[str]:
|
||||
"""Return the list of available hvac operation modes."""
|
||||
return [self.hvac_mode]
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> Optional[float]:
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
return self._zone.room_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> Optional[float]:
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._zone.target_temperature
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue