mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Improve type hints in homematic climate (#145283)
This commit is contained in:
parent
f9000ae08c
commit
072bf75d71
@ -63,6 +63,11 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
| ClimateEntityFeature.TURN_ON
|
| ClimateEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
_attr_min_temp = 4.5
|
||||||
|
_attr_max_temp = 30.5
|
||||||
|
_attr_target_temperature_step = 0.5
|
||||||
|
|
||||||
|
_state: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> HVACMode:
|
def hvac_mode(self) -> HVACMode:
|
||||||
@ -93,7 +98,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
return [HVACMode.HEAT, HVACMode.OFF]
|
return [HVACMode.HEAT, HVACMode.OFF]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self) -> str:
|
||||||
"""Return the current preset mode, e.g., home, away, temp."""
|
"""Return the current preset mode, e.g., home, away, temp."""
|
||||||
if self._data.get("BOOST_MODE", False):
|
if self._data.get("BOOST_MODE", False):
|
||||||
return "boost"
|
return "boost"
|
||||||
@ -110,7 +115,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
return mode
|
return mode
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self):
|
def preset_modes(self) -> list[str]:
|
||||||
"""Return a list of available preset modes."""
|
"""Return a list of available preset modes."""
|
||||||
return [
|
return [
|
||||||
HM_PRESET_MAP[mode]
|
HM_PRESET_MAP[mode]
|
||||||
@ -119,7 +124,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_humidity(self):
|
def current_humidity(self) -> float | None:
|
||||||
"""Return the current humidity."""
|
"""Return the current humidity."""
|
||||||
for node in HM_HUMI_MAP:
|
for node in HM_HUMI_MAP:
|
||||||
if node in self._data:
|
if node in self._data:
|
||||||
@ -127,7 +132,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
for node in HM_TEMP_MAP:
|
for node in HM_TEMP_MAP:
|
||||||
if node in self._data:
|
if node in self._data:
|
||||||
@ -135,7 +140,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the target temperature."""
|
"""Return the target temperature."""
|
||||||
return self._data.get(self._state)
|
return self._data.get(self._state)
|
||||||
|
|
||||||
@ -164,21 +169,6 @@ class HMThermostat(HMDevice, ClimateEntity):
|
|||||||
elif preset_mode == PRESET_ECO:
|
elif preset_mode == PRESET_ECO:
|
||||||
self._hmdevice.MODE = self._hmdevice.LOWERING_MODE
|
self._hmdevice.MODE = self._hmdevice.LOWERING_MODE
|
||||||
|
|
||||||
@property
|
|
||||||
def min_temp(self):
|
|
||||||
"""Return the minimum temperature."""
|
|
||||||
return 4.5
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_temp(self):
|
|
||||||
"""Return the maximum temperature."""
|
|
||||||
return 30.5
|
|
||||||
|
|
||||||
@property
|
|
||||||
def target_temperature_step(self):
|
|
||||||
"""Return the supported step of target temperature."""
|
|
||||||
return 0.5
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _hm_control_mode(self):
|
def _hm_control_mode(self):
|
||||||
"""Return Control mode."""
|
"""Return Control mode."""
|
||||||
|
@ -215,31 +215,31 @@ HM_IGNORE_DISCOVERY_NODE_EXCEPTIONS = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
HM_ATTRIBUTE_SUPPORT = {
|
HM_ATTRIBUTE_SUPPORT: dict[str, tuple[str, dict[int, str]]] = {
|
||||||
"LOWBAT": ["battery", {0: "High", 1: "Low"}],
|
"LOWBAT": ("battery", {0: "High", 1: "Low"}),
|
||||||
"LOW_BAT": ["battery", {0: "High", 1: "Low"}],
|
"LOW_BAT": ("battery", {0: "High", 1: "Low"}),
|
||||||
"ERROR": ["error", {0: "No"}],
|
"ERROR": ("error", {0: "No"}),
|
||||||
"ERROR_SABOTAGE": ["sabotage", {0: "No", 1: "Yes"}],
|
"ERROR_SABOTAGE": ("sabotage", {0: "No", 1: "Yes"}),
|
||||||
"SABOTAGE": ["sabotage", {0: "No", 1: "Yes"}],
|
"SABOTAGE": ("sabotage", {0: "No", 1: "Yes"}),
|
||||||
"RSSI_PEER": ["rssi_peer", {}],
|
"RSSI_PEER": ("rssi_peer", {}),
|
||||||
"RSSI_DEVICE": ["rssi_device", {}],
|
"RSSI_DEVICE": ("rssi_device", {}),
|
||||||
"VALVE_STATE": ["valve", {}],
|
"VALVE_STATE": ("valve", {}),
|
||||||
"LEVEL": ["level", {}],
|
"LEVEL": ("level", {}),
|
||||||
"BATTERY_STATE": ["battery", {}],
|
"BATTERY_STATE": ("battery", {}),
|
||||||
"CONTROL_MODE": [
|
"CONTROL_MODE": (
|
||||||
"mode",
|
"mode",
|
||||||
{0: "Auto", 1: "Manual", 2: "Away", 3: "Boost", 4: "Comfort", 5: "Lowering"},
|
{0: "Auto", 1: "Manual", 2: "Away", 3: "Boost", 4: "Comfort", 5: "Lowering"},
|
||||||
],
|
),
|
||||||
"POWER": ["power", {}],
|
"POWER": ("power", {}),
|
||||||
"CURRENT": ["current", {}],
|
"CURRENT": ("current", {}),
|
||||||
"VOLTAGE": ["voltage", {}],
|
"VOLTAGE": ("voltage", {}),
|
||||||
"OPERATING_VOLTAGE": ["voltage", {}],
|
"OPERATING_VOLTAGE": ("voltage", {}),
|
||||||
"WORKING": ["working", {0: "No", 1: "Yes"}],
|
"WORKING": ("working", {0: "No", 1: "Yes"}),
|
||||||
"STATE_UNCERTAIN": ["state_uncertain", {}],
|
"STATE_UNCERTAIN": ("state_uncertain", {}),
|
||||||
"SENDERID": ["last_senderid", {}],
|
"SENDERID": ("last_senderid", {}),
|
||||||
"SENDERADDRESS": ["last_senderaddress", {}],
|
"SENDERADDRESS": ("last_senderaddress", {}),
|
||||||
"ERROR_ALARM_TEST": ["error_alarm_test", {0: "No", 1: "Yes"}],
|
"ERROR_ALARM_TEST": ("error_alarm_test", {0: "No", 1: "Yes"}),
|
||||||
"ERROR_SMOKE_CHAMBER": ["error_smoke_chamber", {0: "No", 1: "Yes"}],
|
"ERROR_SMOKE_CHAMBER": ("error_smoke_chamber", {0: "No", 1: "Yes"}),
|
||||||
}
|
}
|
||||||
|
|
||||||
HM_PRESS_EVENTS = [
|
HM_PRESS_EVENTS = [
|
||||||
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pyhomematic import HMConnection
|
from pyhomematic import HMConnection
|
||||||
from pyhomematic.devicetypes.generic import HMGeneric
|
from pyhomematic.devicetypes.generic import HMGeneric
|
||||||
@ -50,7 +51,7 @@ class HMDevice(Entity):
|
|||||||
self._channel = config.get(ATTR_CHANNEL)
|
self._channel = config.get(ATTR_CHANNEL)
|
||||||
self._state = config.get(ATTR_PARAM)
|
self._state = config.get(ATTR_PARAM)
|
||||||
self._unique_id = config.get(ATTR_UNIQUE_ID)
|
self._unique_id = config.get(ATTR_UNIQUE_ID)
|
||||||
self._data: dict[str, str] = {}
|
self._data: dict[str, Any] = {}
|
||||||
self._connected = False
|
self._connected = False
|
||||||
self._available = False
|
self._available = False
|
||||||
self._channel_map: dict[str, str] = {}
|
self._channel_map: dict[str, str] = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user