mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add type annotations to stiebel eltron component (#135228)
This commit is contained in:
parent
4690aef8b8
commit
3978c4cdb3
@ -3,6 +3,7 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pymodbus.client import ModbusTcpClient
|
||||||
from pystiebeleltron import pystiebeleltron
|
from pystiebeleltron import pystiebeleltron
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -55,13 +56,13 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
class StiebelEltronData:
|
class StiebelEltronData:
|
||||||
"""Get the latest data and update the states."""
|
"""Get the latest data and update the states."""
|
||||||
|
|
||||||
def __init__(self, name, modbus_client):
|
def __init__(self, name: str, modbus_client: ModbusTcpClient) -> None:
|
||||||
"""Init the STIEBEL ELTRON data object."""
|
"""Init the STIEBEL ELTRON data object."""
|
||||||
|
|
||||||
self.api = pystiebeleltron.StiebelEltronAPI(modbus_client, 1)
|
self.api = pystiebeleltron.StiebelEltronAPI(modbus_client, 1)
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update unit data."""
|
"""Update unit data."""
|
||||||
if not self.api.update():
|
if not self.api.update():
|
||||||
_LOGGER.warning("Modbus read failed")
|
_LOGGER.warning("Modbus read failed")
|
||||||
|
@ -16,7 +16,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import DOMAIN as STE_DOMAIN
|
from . import DOMAIN as STE_DOMAIN, StiebelEltronData
|
||||||
|
|
||||||
DEPENDENCIES = ["stiebel_eltron"]
|
DEPENDENCIES = ["stiebel_eltron"]
|
||||||
|
|
||||||
@ -81,15 +81,15 @@ class StiebelEltron(ClimateEntity):
|
|||||||
)
|
)
|
||||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
def __init__(self, name, ste_data):
|
def __init__(self, name: str, ste_data: StiebelEltronData) -> None:
|
||||||
"""Initialize the unit."""
|
"""Initialize the unit."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._target_temperature = None
|
self._target_temperature: float | int | None = None
|
||||||
self._current_temperature = None
|
self._current_temperature: float | int | None = None
|
||||||
self._current_humidity = None
|
self._current_humidity: float | int | None = None
|
||||||
self._operation = None
|
self._operation: str | None = None
|
||||||
self._filter_alarm = None
|
self._filter_alarm: bool | None = None
|
||||||
self._force_update = False
|
self._force_update: bool = False
|
||||||
self._ste_data = ste_data
|
self._ste_data = ste_data
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
@ -108,59 +108,59 @@ class StiebelEltron(ClimateEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self) -> dict[str, bool | None]:
|
||||||
"""Return device specific state attributes."""
|
"""Return device specific state attributes."""
|
||||||
return {"filter_alarm": self._filter_alarm}
|
return {"filter_alarm": self._filter_alarm}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self) -> str:
|
||||||
"""Return the name of the climate device."""
|
"""Return the name of the climate device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
# Handle ClimateEntityFeature.TARGET_TEMPERATURE
|
# Handle ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
return self._current_temperature
|
return self._current_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
return self._target_temperature
|
return self._target_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self):
|
def target_temperature_step(self) -> float:
|
||||||
"""Return the supported step of target temperature."""
|
"""Return the supported step of target temperature."""
|
||||||
return 0.1
|
return 0.1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self) -> float:
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
return 10.0
|
return 10.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self) -> float:
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
return 30.0
|
return 30.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_humidity(self):
|
def current_humidity(self) -> float | None:
|
||||||
"""Return the current humidity."""
|
"""Return the current humidity."""
|
||||||
return float(f"{self._current_humidity:.1f}")
|
return float(f"{self._current_humidity:.1f}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> HVACMode | None:
|
def hvac_mode(self) -> HVACMode | None:
|
||||||
"""Return current operation ie. heat, cool, idle."""
|
"""Return current operation ie. heat, cool, idle."""
|
||||||
return STE_TO_HA_HVAC.get(self._operation)
|
return STE_TO_HA_HVAC.get(self._operation) if self._operation else None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self) -> str | None:
|
||||||
"""Return the current preset mode, e.g., home, away, temp."""
|
"""Return the current preset mode, e.g., home, away, temp."""
|
||||||
return STE_TO_HA_PRESET.get(self._operation)
|
return STE_TO_HA_PRESET.get(self._operation) if self._operation else None
|
||||||
|
|
||||||
@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 SUPPORT_PRESET
|
return SUPPORT_PRESET
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user