From 15915680b581177b33a1645c5c12c4c1c2e8d871 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 20 May 2025 10:42:41 +0200 Subject: [PATCH] Use shorthand attributes in xs1 climate (#145298) * Use shorthand attributes in xs1 climate * Improve --- homeassistant/components/xs1/climate.py | 29 +++++++++---------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/xs1/climate.py b/homeassistant/components/xs1/climate.py index 3f44cb1504d..0747b2130bd 100644 --- a/homeassistant/components/xs1/climate.py +++ b/homeassistant/components/xs1/climate.py @@ -5,6 +5,8 @@ from __future__ import annotations from typing import Any from xs1_api_client.api_constants import ActuatorType +from xs1_api_client.device.actuator import XS1Actuator +from xs1_api_client.device.sensor import XS1Sensor from homeassistant.components.climate import ( ClimateEntity, @@ -19,9 +21,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import ACTUATORS, DOMAIN, SENSORS from .entity import XS1DeviceEntity -MIN_TEMP = 8 -MAX_TEMP = 25 - def setup_platform( hass: HomeAssistant, @@ -30,8 +29,8 @@ def setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the XS1 thermostat platform.""" - actuators = hass.data[DOMAIN][ACTUATORS] - sensors = hass.data[DOMAIN][SENSORS] + actuators: list[XS1Actuator] = hass.data[DOMAIN][ACTUATORS] + sensors: list[XS1Sensor] = hass.data[DOMAIN][SENSORS] thermostat_entities = [] for actuator in actuators: @@ -56,19 +55,21 @@ class XS1ThermostatEntity(XS1DeviceEntity, ClimateEntity): _attr_hvac_mode = HVACMode.HEAT _attr_hvac_modes = [HVACMode.HEAT] _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE + _attr_min_temp = 8 + _attr_max_temp = 25 - def __init__(self, device, sensor): + def __init__(self, device: XS1Actuator, sensor: XS1Sensor) -> None: """Initialize the actuator.""" super().__init__(device) self.sensor = sensor @property - def name(self): + def name(self) -> str: """Return the name of the device if any.""" return self.device.name() @property - def current_temperature(self): + def current_temperature(self) -> float | None: """Return the current temperature.""" if self.sensor is None: return None @@ -81,20 +82,10 @@ class XS1ThermostatEntity(XS1DeviceEntity, ClimateEntity): return self.device.unit() @property - def target_temperature(self): + def target_temperature(self) -> float | None: """Return the current target temperature.""" return self.device.new_value() - @property - def min_temp(self): - """Return the minimum temperature.""" - return MIN_TEMP - - @property - def max_temp(self): - """Return the maximum temperature.""" - return MAX_TEMP - def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" temp = kwargs.get(ATTR_TEMPERATURE)