swingerman / ha-dual-smart-thermostat

The `dual_smart_thermostat` is an enhaced verion of generic thermostat implemented in Home Assistant. It uses several sensors and dedicated switches connected to a heater and air conditioning under the hood.
https://github.com/swingerman/ha-dual-thermostat
Apache License 2.0
128 stars 21 forks source link

Tolerance / precision behavior seems wrong #10

Open rvdbijl opened 2 years ago

rvdbijl commented 2 years ago

In heating mode, if I have the tolerance set to 1F and the precision to 0.1F, and the setpoint to 68F, it turns on at 66.9F, but turns off right away when it gets to 67.1F. I would expect it to turn on at 66.9F, and turn off at 68F.

KixAss commented 2 years ago

Same issue here.

KixAss commented 2 years ago

@rvdbijl You can fix it by changing 2 lines in climate.py:

Line 988: return target_temp >= (self._cur_temp + (0 if self._is_heter_active else self._cold_tolerance))

Line 993: return self._cur_temp >= (target_temp + (0 if self._is_cooler_active else self._hot_tolerance))

swingerman commented 2 years ago

Could you guys please post your configuration here? I cannot reproduce the problem

micksam7 commented 2 years ago

Same problem here. This seems to only occur when in dual Heat/Cool mode. In normal Heat or normal Cool mode, it behaves as expected.

climate:
  - platform: dual_smart_thermostat
    name: Adv Basement Heatpump
    heater: input_boolean.basement_heatpump_heat
    cooler: input_boolean.basement_heatpump_cool
    target_sensor: sensor.average_basement_temperature
    target_temp: 70
    target_temp_high: 71
    target_temp_low: 69
    cold_tolerance: .5
    hot_tolerance: .5
    min_cycle_duration:
      seconds: 60
    keep_alive:
      minutes: 3
    precision: 0.1

image

Changing the climate.py lines as referenced in KixAss's comment partly fixes, but heats/cools only to the set point instead of using the upper/lower tolerances.

A proper fix may be changing _async_control_heat_cool: from

            too_cold = self._is_too_cold("_target_temp_low")
            too_hot = self._is_too_hot("_target_temp_high")

to

            too_cold = self._is_too_cold("_target_temp_low")
            # keep heater on until set point
            if self._is_heter_active and not self._is_too_hot("_target_temp_low"):
                too_cold = True

            too_hot = self._is_too_hot("_target_temp_high")
            # keep cooler on until set point
            if self._is_cooler_active and not self._is_too_cold("_target_temp_high"):
                too_hot = True

or perhaps changing the logic of async_heater_cooler_toggle