1- """Climate object """
2-
3- from typing import Union , cast
1+ """Climate object. """
2+ from __future__ import annotations
3+ from typing import Any , cast
44
55from pyhilo import API
66from pyhilo .const import LOG
77from pyhilo .device import HiloDevice
88
99
1010class Climate (HiloDevice ):
11- def __init__ (self , api : API , ** kwargs : dict [str , Union [str , int ]]):
12- super ().__init__ (api , ** kwargs ) # type: ignore
13- LOG .debug (f"Setting up Climate device: { self .name } " )
11+ """
12+ Represents a climate device within the Hilo ecosystem.
13+
14+ This class provides methods to interact with and control climate-related
15+ devices such as thermostats.
16+ """
17+
18+ def __init__ (self , api : API , ** kwargs : dict [str , str | int | dict [Any , Any ]]) -> None :
19+ """Initialize the Climate object.
20+
21+ Args:
22+ api: The Hilo API instance.
23+ **kwargs: Keyword arguments containing device data.
24+ """
25+ super ().__init__ (api , ** kwargs )
26+ LOG .debug ("Setting up Climate device: %s" , self .name )
1427
1528 @property
1629 def current_temperature (self ) -> float :
30+ """
31+ Gets the current temperature reported by the device.
32+
33+ Returns:
34+ float: The current temperature.
35+ """
1736 return cast (float , self .get_value ("current_temperature" , 0 ))
1837
1938 @property
2039 def target_temperature (self ) -> float :
40+ """
41+ Gets the target temperature set for the device.
42+
43+ Returns:
44+ float: The target temperature.
45+ """
2146 return cast (float , self .get_value ("target_temperature" , 0 ))
2247
2348 @property
2449 def max_temp (self ) -> float :
50+ """
51+ Gets the maximum temperature setpoint allowed for the device.
52+
53+ Returns:
54+ float: The maximum temperature. Defaults to 36.0 if not defined.
55+ """
2556 value = self .get_value ("max_temp_setpoint" , 0 )
2657
2758 if value is None or value == 0 :
@@ -30,6 +61,12 @@ def max_temp(self) -> float:
3061
3162 @property
3263 def min_temp (self ) -> float :
64+ """
65+ Gets the minimum temperature setpoint allowed for the device.
66+
67+ Returns:
68+ float: The minimum temperature. Defaults to 5.0 if not defined.
69+ """
3370 value = self .get_value ("min_temp_setpoint" , 0 )
3471
3572 if value is None or value == 0 :
@@ -38,11 +75,22 @@ def min_temp(self) -> float:
3875
3976 @property
4077 def hvac_action (self ) -> str :
78+ """
79+ Gets the current HVAC action of the device.
80+
81+ Returns:
82+ str: 'heating' if heating is active, 'idle' otherwise.
83+ """
4184 attr = self .get_value ("heating" , 0 )
4285 return "heating" if attr > 0 else "idle"
4386
44- async def async_set_temperature (self , ** kwargs : dict [str , int ]) -> None :
45- temperature = kwargs .get ("temperature" , 0 )
46- if temperature :
47- LOG .info (f"{ self ._tag } Setting temperature to { temperature } " )
48- await self .set_attribute ("target_temperature" , temperature ) # type: ignore
87+ async def async_set_temperature (self , temperature : float ) -> None :
88+ """
89+ Sets the target temperature of the device.
90+
91+ Args:
92+ temperature: The desired target temperature.
93+ """
94+ if temperature != self .target_temperature :
95+ LOG .info ("%s Setting temperature to %s" , self ._tag , temperature )
96+ await self .set_attribute ("target_temperature" , str (temperature ))
0 commit comments