Skip to content

Commit

Permalink
perf(climate): Heuristic Action and fix heating (#468)
Browse files Browse the repository at this point in the history
related #502

---------

Co-authored-by: Bander <[email protected]>
  • Loading branch information
gtgt and xZetsubou authored Jan 21, 2025
1 parent c6787db commit 1e95f54
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions custom_components/localtuya/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,45 @@ def hvac_action(self):
self._hvac_action = HVACAction.HEATING
if self._hvac_mode == HVACMode.DRY:
self._hvac_action = HVACAction.DRYING
if self._hvac_mode == HVACMode.FAN_ONLY:
self._hvac_action = HVACAction.FAN

# This exists from upstream, not sure the use case of this.
if self._config.get(CONF_HEURISTIC_ACTION, False):
if self._hvac_mode == HVACMode.HEAT:
if self._current_temperature < (
self._target_temperature - self._precision
):
self._hvac_action = HVACMode.HEAT
self._hvac_action = HVACAction.HEATING
if (
self._current_temperature + self._precision
) > self._target_temperature:
self._hvac_action = HVACAction.IDLE
if self._hvac_mode == HVACMode.COOL:
if self._current_temperature > (
self._target_temperature - self._precision
):
self._hvac_action = HVACAction.COOLING
if (
self._current_temperature + self._precision
) < self._target_temperature:
self._hvac_action = HVACAction.IDLE
if self._hvac_mode == HVACMode.HEAT_COOL:
if self._current_temperature < (
self._target_temperature - self._precision
):
self._hvac_action = HVACAction.HEATING
if self._current_temperature == (
self._target_temperature - self._precision
):
if self._hvac_action == HVACMode.HEAT:
self._hvac_action = HVACMode.HEAT
if self._hvac_action == HVACAction.IDLE:
self._hvac_action = HVACAction.IDLE
self._hvac_action = HVACAction.IDLE
if (
self._current_temperature + self._precision
) > self._target_temperature:
self._hvac_action = HVACAction.IDLE
self._hvac_action = HVACAction.COOLING
if self._hvac_mode == HVACMode.DRY:
self._hvac_action = HVACAction.DRYING
if self._hvac_mode == HVACMode.FAN_ONLY:
self._hvac_action = HVACAction.FAN
return self._hvac_action
return self._hvac_action

Expand Down

0 comments on commit 1e95f54

Please sign in to comment.