@@ -327,54 +327,49 @@ def hvac_action(self):
327
327
if not self ._is_on :
328
328
return HVACAction .OFF
329
329
330
+ hvac_action = self ._hvac_action
331
+ hvac_mode = self ._hvac_mode
330
332
if not self ._conf_hvac_action_dp :
331
- if self ._hvac_mode == HVACMode .COOL :
332
- self ._hvac_action = HVACAction .COOLING
333
- if self ._hvac_mode == HVACMode .HEAT :
334
- self ._hvac_action = HVACAction .HEATING
335
- if self ._hvac_mode == HVACMode .DRY :
336
- self ._hvac_action = HVACAction .DRYING
337
- if self ._hvac_mode == HVACMode .FAN_ONLY :
338
- self ._hvac_action = HVACAction .FAN
339
-
340
- if self ._config .get (CONF_HEURISTIC_ACTION , False ):
341
- if self ._hvac_mode == HVACMode .HEAT :
342
- if self ._current_temperature < (
343
- self ._target_temperature - self ._precision
344
- ):
345
- self ._hvac_action = HVACAction .HEATING
346
- if (
347
- self ._current_temperature + self ._precision
348
- ) > self ._target_temperature :
349
- self ._hvac_action = HVACAction .IDLE
350
- if self ._hvac_mode == HVACMode .COOL :
351
- if self ._current_temperature > (
352
- self ._target_temperature - self ._precision
353
- ):
354
- self ._hvac_action = HVACAction .COOLING
355
- if (
356
- self ._current_temperature + self ._precision
357
- ) < self ._target_temperature :
358
- self ._hvac_action = HVACAction .IDLE
359
- if self ._hvac_mode == HVACMode .HEAT_COOL :
360
- if self ._current_temperature < (
361
- self ._target_temperature - self ._precision
362
- ):
363
- self ._hvac_action = HVACAction .HEATING
364
- if self ._current_temperature == (
365
- self ._target_temperature - self ._precision
366
- ):
367
- self ._hvac_action = HVACAction .IDLE
368
- if (
369
- self ._current_temperature + self ._precision
370
- ) > self ._target_temperature :
371
- self ._hvac_action = HVACAction .COOLING
372
- if self ._hvac_mode == HVACMode .DRY :
373
- self ._hvac_action = HVACAction .DRYING
374
- if self ._hvac_mode == HVACMode .FAN_ONLY :
375
- self ._hvac_action = HVACAction .FAN
376
- return self ._hvac_action
377
- return self ._hvac_action
333
+ if hvac_mode == HVACMode .COOL :
334
+ hvac_action = HVACAction .COOLING
335
+ if hvac_mode == HVACMode .HEAT :
336
+ hvac_action = HVACAction .HEATING
337
+ if hvac_mode == HVACMode .DRY :
338
+ hvac_action = HVACAction .DRYING
339
+ if hvac_mode == HVACMode .FAN_ONLY :
340
+ hvac_action = HVACAction .FAN
341
+
342
+ if (
343
+ self ._config .get (CONF_HEURISTIC_ACTION )
344
+ and (target_temperature := self ._target_temperature ) is not None
345
+ and (current_temperature := self ._current_temperature ) is not None
346
+ ):
347
+ precision_target_diff = target_temperature - self ._precision
348
+ precision_current_diff = current_temperature + self ._precision
349
+
350
+ if hvac_mode == HVACMode .HEAT :
351
+ if current_temperature < precision_target_diff :
352
+ hvac_action = HVACAction .HEATING
353
+ if precision_current_diff > target_temperature :
354
+ hvac_action = HVACAction .IDLE
355
+ if hvac_mode == HVACMode .COOL :
356
+ if current_temperature > precision_target_diff :
357
+ hvac_action = HVACAction .COOLING
358
+ if precision_current_diff < target_temperature :
359
+ hvac_action = HVACAction .IDLE
360
+ if hvac_mode == HVACMode .HEAT_COOL :
361
+ if current_temperature < precision_target_diff :
362
+ hvac_action = HVACAction .HEATING
363
+ if current_temperature == precision_target_diff :
364
+ hvac_action = HVACAction .IDLE
365
+ if precision_current_diff > target_temperature :
366
+ hvac_action = HVACAction .COOLING
367
+ if hvac_mode == HVACMode .DRY :
368
+ hvac_action = HVACAction .DRYING
369
+ if hvac_mode == HVACMode .FAN_ONLY :
370
+ hvac_action = HVACAction .FAN
371
+
372
+ return hvac_action
378
373
379
374
@property
380
375
def preset_mode (self ):
0 commit comments