Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(climate): Heuristic Action and fix heating #468

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

gtgt
Copy link

@gtgt gtgt commented Jan 9, 2025

This feature calculates HVAC Action (from HVACMode and target/current temperatures) if the device is unable to do it.
Useful when you operate real device, like air-vales, heater, cooler, etc.

The upstream code contained some unnecessary lines and worked only with heating mode (as anything other climate stuff).

  1. However the CURRENT_* constants were converted to HVACMode, instead of HVACAction, so this should be corrected.
  2. The code is also updated to support Fan/Dry/HeatCool modes.

@xZetsubou
Copy link
Owner

I think heuristic requires current and target temp to process other wise the logic will break and rise an error not? can you check this cleaned and has temps check

        if self._config.get(CONF_HEURISTIC_ACTION) and (
            self._target_temperature and self._current_temperature
        ):
            precision_target_diff = self._target_temperature - self._precision
            precision_current_diff = self._current_temperature + self._precision

            if self._hvac_mode == HVACMode.HEAT:
                if self._current_temperature < precision_target_diff:
                    self._hvac_action = HVACAction.HEATING
                if precision_current_diff > self._target_temperature:
                    self._hvac_action = HVACAction.IDLE
            if self._hvac_mode == HVACMode.COOL:
                if self._current_temperature > precision_target_diff:
                    self._hvac_action = HVACAction.COOLING
                if precision_current_diff < self._target_temperature:
                    self._hvac_action = HVACAction.IDLE
            if self._hvac_mode == HVACMode.HEAT_COOL:
                if self._current_temperature < precision_target_diff:
                    self._hvac_action = HVACAction.HEATING
                if self._current_temperature == precision_target_diff:
                    self._hvac_action = HVACAction.IDLE
                if precision_current_diff > self._target_temperature:
                    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

@mmxxmm
Copy link

mmxxmm commented Jan 10, 2025

I think heuristic requires current and target temp to process other wise the logic will break and rise an error not? can you check this cleaned and has temps check

        if self._config.get(CONF_HEURISTIC_ACTION) and (
            self._target_temperature and self._current_temperature
        ):
            precision_target_diff = self._target_temperature - self._precision
            precision_current_diff = self._current_temperature + self._precision

            if self._hvac_mode == HVACMode.HEAT:
                if self._current_temperature < precision_target_diff:
                    self._hvac_action = HVACAction.HEATING
                if precision_current_diff > self._target_temperature:
                    self._hvac_action = HVACAction.IDLE
            if self._hvac_mode == HVACMode.COOL:
                if self._current_temperature > precision_target_diff:
                    self._hvac_action = HVACAction.COOLING
                if precision_current_diff < self._target_temperature:
                    self._hvac_action = HVACAction.IDLE
            if self._hvac_mode == HVACMode.HEAT_COOL:
                if self._current_temperature < precision_target_diff:
                    self._hvac_action = HVACAction.HEATING
                if self._current_temperature == precision_target_diff:
                    self._hvac_action = HVACAction.IDLE
                if precision_current_diff > self._target_temperature:
                    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

I have a heater device switch to heating mode when self._current_temperature < self._target_temperature - self._precision_target, not self._target_temperature - self._precision. It also has a weekly circulation programming mode which has self._hvac_mode == HVACMode.AUTO

@xZetsubou xZetsubou changed the title Fix Heuristic Action perf(climate): Heuristic Action and fix heating Jan 21, 2025
@xZetsubou xZetsubou merged commit 1e95f54 into xZetsubou:master Jan 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants