fashberg / WThermostatBeca

Open Source firmware replacement for Tuya Wifi Thermostate from Beca and Moes with Home Assistant Autodiscovery
344 stars 71 forks source link

PID workaround #218

Closed Funkenschuhster closed 7 months ago

Funkenschuhster commented 10 months ago

I'm still testing but may I found a workaround, to make PWM PID happen. The trick is to set the temperature higher or lower than the actual value to trigger the hysteresis.

Here is how I did it in node-red:

  1. I set up a standard PID controller with analog input from BHT-002 and analog out 0.0...1.0
  2. The analog output goes to a PWM node converting the analog to pulse pause at very slow frequency e. g. 200s on / 800s off = 0.25 = 25%
  3. The pulse goes to a converter which is generating a dynamic setpoint for BHT-002 based on the actual room temperature. See codebox below.
  4. The dynamic setpoint is calculated and sent every two minutes to make sure it always +-1K off even if the actual temperature just flipped while calculation.
// Open thermostat: set setpoint temperature higher than actual
if (msg.pulseOut == 1) {
    msg.becaSetpoint = msg.becaTemperature + 1K;
}

// Open thermostat: set setpoint temperature lower than actual
if (msg.pulseOut == 0) {
    msg.becaSetpoint = msg.becaTemperature - 1K;
}

return msg;

Used Nodes: PID: node-red-contrib-pid PWM: node-red-contrib-timeprop

I wonder if you could implement a PID workaround directly in the thermostat. Recommended features:

EDIT: changed hysteresis to 1K. +-0.5K does not trigger the relay safely.

github-actions[bot] commented 7 months ago

Message to comment on stale issues. If none provided, will not mark issues stale