33from __future__ import annotations
44
55from datetime import timedelta
6+ from typing import Any
67
78from homeassistant .components .humidifier import (
89 DEFAULT_MAX_HUMIDITY ,
910 DEFAULT_MIN_HUMIDITY ,
1011 MODE_AUTO ,
12+ HumidifierAction ,
1113 HumidifierDeviceClass ,
1214 HumidifierEntity ,
1315 HumidifierEntityFeature ,
@@ -41,6 +43,12 @@ async def async_setup_entry(
4143 async_add_entities (entities , True )
4244
4345
46+ ECOBEE_HUMIDIFIER_ACTION_TO_HASS = {
47+ "humidifier" : HumidifierAction .HUMIDIFYING ,
48+ "dehumidifier" : HumidifierAction .DRYING ,
49+ }
50+
51+
4452class EcobeeHumidifier (HumidifierEntity ):
4553 """A humidifier class for an ecobee thermostat with humidifier attached."""
4654
@@ -52,7 +60,7 @@ class EcobeeHumidifier(HumidifierEntity):
5260 _attr_has_entity_name = True
5361 _attr_name = None
5462
55- def __init__ (self , data , thermostat_index ):
63+ def __init__ (self , data , thermostat_index ) -> None :
5664 """Initialize ecobee humidifier platform."""
5765 self .data = data
5866 self .thermostat_index = thermostat_index
@@ -80,11 +88,11 @@ def device_info(self) -> DeviceInfo:
8088 )
8189
8290 @property
83- def available (self ):
91+ def available (self ) -> bool :
8492 """Return if device is available."""
8593 return self .thermostat ["runtime" ]["connected" ]
8694
87- async def async_update (self ):
95+ async def async_update (self ) -> None :
8896 """Get the latest state from the thermostat."""
8997 if self .update_without_throttle :
9098 await self .data .update (no_throttle = True )
@@ -96,12 +104,20 @@ async def async_update(self):
96104 self ._last_humidifier_on_mode = self .mode
97105
98106 @property
99- def is_on (self ):
107+ def action (self ) -> HumidifierAction :
108+ """Return the current action."""
109+ for status in self .thermostat ["equipmentStatus" ].split ("," ):
110+ if status in ECOBEE_HUMIDIFIER_ACTION_TO_HASS :
111+ return ECOBEE_HUMIDIFIER_ACTION_TO_HASS [status ]
112+ return HumidifierAction .IDLE if self .is_on else HumidifierAction .OFF
113+
114+ @property
115+ def is_on (self ) -> bool :
100116 """Return True if the humidifier is on."""
101117 return self .mode != MODE_OFF
102118
103119 @property
104- def mode (self ):
120+ def mode (self ) -> str :
105121 """Return the current mode, e.g., off, auto, manual."""
106122 return self .thermostat ["settings" ]["humidifierMode" ]
107123
@@ -118,9 +134,11 @@ def current_humidity(self) -> int | None:
118134 except KeyError :
119135 return None
120136
121- def set_mode (self , mode ) :
137+ def set_mode (self , mode : str ) -> None :
122138 """Set humidifier mode (auto, off, manual)."""
123- if mode .lower () not in (self .available_modes ):
139+ if self .available_modes is None :
140+ raise NotImplementedError ("Humidifier does not support modes." )
141+ if mode .lower () not in self .available_modes :
124142 raise ValueError (
125143 f"Invalid mode value: { mode } Valid values are"
126144 f" { ', ' .join (self .available_modes )} ."
@@ -134,10 +152,10 @@ def set_humidity(self, humidity: int) -> None:
134152 self .data .ecobee .set_humidity (self .thermostat_index , humidity )
135153 self .update_without_throttle = True
136154
137- def turn_off (self , ** kwargs ) :
155+ def turn_off (self , ** kwargs : Any ) -> None :
138156 """Set humidifier to off mode."""
139157 self .set_mode (MODE_OFF )
140158
141- def turn_on (self , ** kwargs ) :
159+ def turn_on (self , ** kwargs : Any ) -> None :
142160 """Set humidifier to on mode."""
143161 self .set_mode (self ._last_humidifier_on_mode )
0 commit comments