Toggle multiple pins for reversing valve (v1.2)

I’ve upgraded to v1.2 with the new rule layout and I’m trying to figure out how to modify the pinout to match my needs. I see in openhab2/automation/lib/hestia/defaults.js the gpio pins are mapped like so:

PIN_MAP.put("US_HeatingPin", "Pin12");
PIN_MAP.put("US_Heating2Pin", "Pin16");
PIN_MAP.put("US_CoolingPin", "Pin23");
PIN_MAP.put("US_FanPin", "Pin18");

The issue for me is I need to energize two different Pins for cooling (Y and O). Theoretically I can change the script that toggles “US_CoolingPin” (Y) to also toggle “US_HeatingPin” (O) but I don’t know where to find that script. @rlkoshak you mentioned something to me about this before but I can’t find the topic. :slightly_smiling_face:

First I need a little bit more info. Under what circumstances do you need to do this? Only for cooling and during heating you only activate the heating pin? The reason I ask is there are some checks in place in a couple of places and what needs to be changed where depends on the answer.

First, let me show an activity diagram for how the rules interact.


The flow is from top to bottom. The rounded rectangles are separate rules which you can find in PaperUI under Rules.

When a sensor reading changes, the setpoint changes, or the mode changes the Heating/Cooling Check rule gets kicked off. This Rule determines whether the current temp, setpoints, and mode indicate that the cooling should be ON or OFF. Depending on what it determines it may trigger the Cooling Control rule. This rule does the actual work of turning on/off the heating/cooling pins.

NOTE: I drew this before implementing the two setpoints so some of the little notes and conditions on the lines are not quite right, but it should be obvious what they mean when you look at the code.

So at a minimum you will need to modify the Cooling Control rule to turn on/off both HeatingPin and CoolingPin. Where it gets complicated is that in the “but only if…” clause of that rule and I also think the Heating/Cooling Check rule there are some checks in place that prevent the heating and cooling pins from being on at the same time. You will need to remove those checks as well.

Luckily everything you need is in just those two rules.

I don’t have easy access to my HestiasPi at the moment but when I do I’ll comeback and add more detail.

I’m back at my desk and can look at the rules. It looks like there is nothing at all that needs to change in Heating/Cooling Check so all you need to look at is Cooling Control.

  • In the “but only if…” clause there is a condition named “Prevent the Heating and Cooling from being ON at the same time”. Remove that condition.
  • In the “then…” clause add a line to commandIfDifferent to HeatingPin where ever you see a command being sent to CoolingPin. There are only two but they are inside of Timers (the actual heating/cooling is turned ON/OFF 10 seconds after the Fan).

That appears to be all you need to do.

Have a look at How to customize a Rule for a way to backup the default rule before you customize it so you have a nice backup to review in the future.

Let me know if you have any questions or problems.


It occurs to me another approach would be to create another Pin Item, maybe Cooling2Pin. Add an entry in defaults.js to map Cooling2Pin to the same Pin12 as the HeatingPin in the PIN_MAP. Then you can keep the “but only if…” condition in place and all you have to do is add the two commandIfDifferent lines to command Cooling2Pin.

This might be slightly safer as there might be interactions and implications I’m not thinking of when HeatingPin and CoolingPin are both ON as these two Items represent to OH the actual state of the devices.

A third approach which is a bit hacky would be to modify the Map Pin to GPIO rule to also command Pin12 when ever CoolingPin is commanded. Logically though, that sort of stuff really belongs in Cooling Control as that’s the whole reason I separated that out into it’s own rule.

I had thought of defining a "O / Reversing Valve " Pin, but regardless heating/cooling still share the same GPIO pin for turning on the heat pump: “Y” (er “W” technically since it activates heat when energized by itself and the heat pump is in its default state). so I don’t see one option as being necessarily safer than the other. Furthermore, if you activate heating (W) and cooling (W+O) at the same time in software somehow, nothing changes physically on the thermostat if your cooling is already on (W was already energized.) It just means you get cold air if you intended to get hot air.
Anyways, I have saved the changes to my rule file and will report back if anything goes wrong. Otherwise, here is the change I made in case others in the future here have a reversing valve and need a similar fix. Keep in mind the direction of your valve as on some heat pumps and controller boards energizing “O” effectively heats instead of cools and you will need to make this same modification but in the “Heating Control” rule instead.

var OPENHAB_CONF = Java.type('java.lang.System').getenv('OPENHAB_CONF');
load(OPENHAB_CONF + '/automation/lib/hestia/utils.js');

logInfo("cooling", "Turning " + command + " the cooling: curr temp = " + items["MyTemp"] +
                 " setpoint = " + items["MaxTempSetpoint"] +
                 " mode = " + items["CoolingMode"]);

if(command == ON){
  commandIfDifferent("MainSwitch", ON);
  commandIfDifferent("FanMode", "AUTO");
  commandIfDifferent("FanCtrl", OFF);
  createTimerSecs(10, function(){
    // "O" - reversing valve pin
    commandIfDifferent("CoolingPin", ON);
    // "W/Y" - heating pin
    commandIfDifferent("HeatingPin", ON);
  });
  events.sendCommand("CoolingMode", items["CoolingMode"]); // update the LCD
}
else {
  commandIfDifferent("HeatingPin", OFF);
  commandIfDifferent("CoolingPin", OFF);
  createTimerSecs(10, function(){
    events.sendCommand("FanMode", (items["FanPrevMode"] != "ON") ? "OFF" : "ON");
    events.sendCommand("FanCtrl", ON);
  });
}

Thanks for the well-written and timely response, @rlkoshak.

By safer I was mainly referring to the openHJAB rules. There might be some check that may change the behavior of certain modes (e.g. boost mode) where having both HeatPin on and CoolingPin on at the same time might change how those rules work. I figure that any user of HestiaPi is knowledgeable enough about their own HVAC system to know what’s safe in that regard. By adding a new pin Item the rules should continue to operate normally and as expected. That’s what I meant by safer.

Good call. I’ll update the thread if issues arise. :+1:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.