1 """Platform for climate integration."""
3 from __future__
import annotations
8 from aiohttp
import ClientSession
9 from whirlpool.aircon
import Aircon, FanSpeed
as AirconFanSpeed, Mode
as AirconMode
10 from whirlpool.auth
import Auth
11 from whirlpool.backendselector
import BackendSelector
34 from .
import WhirlpoolData
35 from .const
import DOMAIN
37 _LOGGER = logging.getLogger(__name__)
41 AirconMode.Cool: HVACMode.COOL,
42 AirconMode.Heat: HVACMode.HEAT,
43 AirconMode.Fan: HVACMode.FAN_ONLY,
46 HVAC_MODE_TO_AIRCON_MODE = {v: k
for k, v
in AIRCON_MODE_MAP.items()}
48 AIRCON_FANSPEED_MAP = {
49 AirconFanSpeed.Off: FAN_OFF,
50 AirconFanSpeed.Auto: FAN_AUTO,
51 AirconFanSpeed.Low: FAN_LOW,
52 AirconFanSpeed.Medium: FAN_MEDIUM,
53 AirconFanSpeed.High: FAN_HIGH,
56 FAN_MODE_TO_AIRCON_FANSPEED = {v: k
for k, v
in AIRCON_FANSPEED_MAP.items()}
58 SUPPORTED_FAN_MODES = [FAN_AUTO, FAN_HIGH, FAN_MEDIUM, FAN_LOW, FAN_OFF]
59 SUPPORTED_HVAC_MODES = [
65 SUPPORTED_MAX_TEMP = 30
66 SUPPORTED_MIN_TEMP = 16
67 SUPPORTED_SWING_MODES = [SWING_HORIZONTAL, SWING_OFF]
68 SUPPORTED_TARGET_TEMPERATURE_STEP = 1
73 config_entry: ConfigEntry,
74 async_add_entities: AddEntitiesCallback,
77 whirlpool_data: WhirlpoolData = hass.data[DOMAIN][config_entry.entry_id]
84 whirlpool_data.backend_selector,
88 for ac_data
in whirlpool_data.appliances_manager.aircons
94 """Representation of an air conditioner."""
96 _attr_fan_modes = SUPPORTED_FAN_MODES
97 _attr_has_entity_name =
True
99 _attr_hvac_modes = SUPPORTED_HVAC_MODES
100 _attr_max_temp = SUPPORTED_MAX_TEMP
101 _attr_min_temp = SUPPORTED_MIN_TEMP
102 _attr_should_poll =
False
103 _attr_supported_features = (
104 ClimateEntityFeature.TARGET_TEMPERATURE
105 | ClimateEntityFeature.FAN_MODE
106 | ClimateEntityFeature.SWING_MODE
107 | ClimateEntityFeature.TURN_OFF
108 | ClimateEntityFeature.TURN_ON
110 _attr_swing_modes = SUPPORTED_SWING_MODES
111 _attr_target_temperature_step = SUPPORTED_TARGET_TEMPERATURE_STEP
112 _attr_temperature_unit = UnitOfTemperature.CELSIUS
113 _enable_turn_on_off_backwards_compatibility =
False
120 backend_selector: BackendSelector,
122 session: ClientSession,
124 """Initialize the entity."""
125 self.
_aircon_aircon = Aircon(backend_selector, auth, said, session)
130 identifiers={(DOMAIN, said)},
131 name=name
if name
is not None else said,
132 manufacturer=
"Whirlpool",
137 """Connect aircon to the cloud."""
139 await self.
_aircon_aircon.connect()
142 """Close Whrilpool Appliance sockets before removing."""
144 await self.
_aircon_aircon.disconnect()
148 """Return True if entity is available."""
149 return self.
_aircon_aircon.get_online()
153 """Return the current temperature."""
154 return self.
_aircon_aircon.get_current_temp()
158 """Return the temperature we try to reach."""
159 return self.
_aircon_aircon.get_temp()
162 """Set new target temperature."""
163 await self.
_aircon_aircon.set_temp(kwargs.get(ATTR_TEMPERATURE))
167 """Return the current humidity."""
168 return self.
_aircon_aircon.get_current_humidity()
172 """Return the humidity we try to reach."""
173 return self.
_aircon_aircon.get_humidity()
176 """Set new target humidity."""
181 """Return current operation ie. heat, cool, fan."""
182 if not self.
_aircon_aircon.get_power_on():
185 mode: AirconMode = self.
_aircon_aircon.get_mode()
186 return AIRCON_MODE_MAP.get(mode)
190 if hvac_mode == HVACMode.OFF:
191 await self.
_aircon_aircon.set_power_on(
False)
194 if not (mode := HVAC_MODE_TO_AIRCON_MODE.get(hvac_mode)):
195 raise ValueError(f
"Invalid hvac mode {hvac_mode}")
197 await self.
_aircon_aircon.set_mode(mode)
198 if not self.
_aircon_aircon.get_power_on():
199 await self.
_aircon_aircon.set_power_on(
True)
203 """Return the fan setting."""
204 fanspeed = self.
_aircon_aircon.get_fanspeed()
205 return AIRCON_FANSPEED_MAP.get(fanspeed, FAN_OFF)
209 if not (fanspeed := FAN_MODE_TO_AIRCON_FANSPEED.get(fan_mode)):
210 raise ValueError(f
"Invalid fan mode {fan_mode}")
211 await self.
_aircon_aircon.set_fanspeed(fanspeed)
215 """Return the swing setting."""
216 return SWING_HORIZONTAL
if self.
_aircon_aircon.get_h_louver_swing()
else SWING_OFF
219 """Set new target temperature."""
220 await self.
_aircon_aircon.set_h_louver_swing(swing_mode == SWING_HORIZONTAL)
223 """Turn device on."""
224 await self.
_aircon_aircon.set_power_on(
True)
227 """Turn device off."""
228 await self.
_aircon_aircon.set_power_on(
False)
None set_humidity(self, int humidity)
None async_will_remove_from_hass(self)
None async_set_temperature(self, **Any kwargs)
int current_humidity(self)
float target_temperature(self)
None async_set_fan_mode(self, str fan_mode)
None async_turn_off(self)
None async_added_to_hass(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
int target_humidity(self)
None async_set_swing_mode(self, str swing_mode)
None async_set_humidity(self, int humidity)
None __init__(self, HomeAssistant hass, str said, str|None name, BackendSelector backend_selector, Auth auth, ClientSession session)
float current_temperature(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)
str generate_entity_id(str entity_id_format, str|None name, list[str]|None current_ids=None, HomeAssistant|None hass=None)