ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
336 stars 48 forks source link

Lack of correspondence between heating time and output #94

Closed T81 closed 1 year ago

T81 commented 1 year ago

Describe the bug The percentage of calculated output does not reflect the time the heater remains on.

Config:

climate:
  - platform: smart_thermostat
    name: Smart PID Thermostat
    unique_id: smart_pid_thermostat
    heater: switch.thermostat_switch
    target_sensor: sensor.temperature_living_room
    outdoor_sensor: sensor.temperature_balcony
    keep_alive:
      seconds: 60
    kp: 25.5
    ki: 0.00125
    kd: 750
    ke: 0.3
    pwm: 00:15:00
   #min_off_cycle_duration: 00:10:00      (this is commented out and disabled)
    min_temp: 17.5
    max_temp: 22.5
    target_temp: 19
#  cold_tolerance: 0.2      (this is commented out and disabled)
#  hot_tolerance: 0       (this is commented out and disabled)
    sampling_period: 00:05:00
    ac_mode: False
    away_temp: 18.5
    eco_temp: 20.5
    comfort_temp: 21
    sleep_temp: 19.5
    output_safety: 0

For example, a calculated output of 2.8, should have to switch the thermostat on for 2.8/100*900 = 25.2 seconds Instead, the switch remains on for 60s, that is a pwm cycle of ~35.7 minutes.

To Reproduce Check the computed output and compare with the time the switch remains on

Expected behavior Calculated output e.g output: 10 should be 10% of pwm setting

T81 commented 1 year ago

It seems that 60s is the least time the controller stays on. Any confirmation?

ScratMan commented 1 year ago

It may be linked to the keep_alive parameter.

T81 commented 1 year ago

I think you are right. I thought that the timings (on/off) were respected regardless of the keep_alive setting, that only affects the time the controller retriggers. I set keep_alive to 1 second. Any implications doing that?

T81 commented 1 year ago

I have confirmed that this was the issue. I've tested that again while having set the keep_alive parameter at 1 second. The output of the controller is 1.4 Having set the pwm parameter to 00:15:00 (900 seconds) it should have been 1.4/100*900 = 12.6 that means 13 seconds heating, taking account the 1 second update interval from the keep_alive parameter. The heater stays on indeed for 13 seconds Out of curiosity, what happens when setting keep_alive parameter to 0?

T81 commented 1 year ago

Since keep_alive is a generic_thermostat configuration variable, I suppose setting it to 0 will render the control unusable