From 1e95f54d837c7f1a4d4b9e59034c16187b219e25 Mon Sep 17 00:00:00 2001 From: GT <788449+gtgt@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:34:53 +0100 Subject: [PATCH] perf(climate): Heuristic Action and fix heating (#468) related #502 --------- Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com> --- custom_components/localtuya/climate.py | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/custom_components/localtuya/climate.py b/custom_components/localtuya/climate.py index be7f3a174..3d79ce258 100644 --- a/custom_components/localtuya/climate.py +++ b/custom_components/localtuya/climate.py @@ -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