HestiaPi / hestia-touch-openhab

OpenHAB2 files for HestiaPi Touch model
GNU General Public License v3.0
60 stars 17 forks source link

Added controls to keep the fan on when heating or cooling is on no matter what #34

Closed rkoshak closed 4 years ago

rkoshak commented 4 years ago

Added controls to prevent the fan from being turned off if heating or cooling is on.

Signed-off-by: Richard Koshak rlkoshak@gmail.com

gulliverrr commented 4 years ago

@rkoshak Fan's previous state is not restored when AUTO ends like when temperature is reached during heating/cooling, so fan always 'returns' to ON. Can I also say that I timed a boot and it is really improved!!! I think we got the LCD UI (but empty) after 10 minutes and fully functional (relays, LCD UI, Web UI and phone App) after about 15-18 minutes (in total!). From 25-28 minutes that it used to be, this is HUGE and I have to thank you @rkoshak for this enormous interest and help over the last month or so (that I haven't been able to keep up with). On the other hand the rules are much harder for me to follow now :) but I haven't got the chance to spend enough time with them due to my other non-coding commitments with the project.

rkoshak commented 4 years ago

@rkoshak Fan's previous state is not restored when AUTO ends like when temperature is reached during heating/cooling, so fan always 'returns' to ON.

That's how it was in the original code too. When the heat or cooling turns on, the Fan mode goes to AUTO and the fan turns ON. When heating/cooling ends, the Fan mode turns OFF too:

rule "FanControl"
when
  Item HeatingPin changed or
  Item CoolingPin changed or
  Item FanMode changed
then
    if (FanMode.state == "AUTO") {
      if ((HeatingPin.state == ON) || (CoolingPin.state == ON)) {
        FanPin.sendCommand(ON)
      }
      else {
        FanPin.sendCommand(OFF)
      }
    } else if (FanMode.state == "ON") {
        FanPin.sendCommand(ON)
    } else { //FanMode.state == "OFF"
      FanPin.sendCommand(OFF)
    }
end

FanMode will be AUTO when the HeatingPin or CoolingPin turn OFF so FanPin is set to OFF.

If someone happened to change the FanMode to ON or OFF while the heating was running, which shouldn't have been allowed per previous issues with trying to run the heating or cooling without the fan than it would remain ON or turn OFF.

With the new code, the Fan cannot be changed while heating or cooling is running.

I can easily add code to restore the fan to the previous mode after heating or cooling ends, which really only is meaningful if the FanMode was ON before heating/cooling started. It will make the logic a little more challenging though.


I'm really happy to hear I've made that much of a difference in the boot time. It felt like I've made progress but I failed to take a before measurement to compare against. I mostly restart OH instead of rebooting the whole machine (who wants to wait around that long?). I bet I can shave at least another 5 minutes or so from that boot time.

The limiting factor appears to be CPU so anything we can do to reduce the CPU load like switching to JSONDB should have a significant improvement.

I am happy to answer any questions you may have on the Rules. It might help to review some of the design pattern postings on the OH forum which I applied in order to make the Rules more generic.

For some background see:

rkoshak commented 4 years ago

PR #36 addresses the FanMode issue mentioned above as well as a bug with the BoostTime Items.

gulliverrr commented 4 years ago

That's how it was in the original code too. When the heat or cooling turns on, the Fan mode goes to AUTO and the fan turns ON.

It switched to AUTO only if it was OFF. If it was ON the FanMode would stay unchanged. if (FanMode.state == "OFF") FanMode.sendCommand("AUTO");

When heating/cooling ends, the Fan mode turns OFF too:

When heating/cooling ends, HeatingPin or CoolingPin would change triggering this rule that would force FanPin to follow HeatingPin or CoolingPin if (FanMode.state == "AUTO") otherwise FanPin would follow FanMode.

rule "FanControl"
when
  Item HeatingPin changed or
  Item CoolingPin changed or
  Item FanMode changed
then
    if (FanMode.state == "AUTO") {
      if ((HeatingPin.state == ON) || (CoolingPin.state == ON)) {
        FanPin.sendCommand(ON)
      }
      else {
        FanPin.sendCommand(OFF)
      }
    } else if (FanMode.state == "ON") {
        FanPin.sendCommand(ON)
    } else { //FanMode.state == "OFF"
      FanPin.sendCommand(OFF)
    }
end

merging #36 as it seems to produce the same result...