Help wanted to control Raspberry pi output with Maxcube thermostates and rules

Well I was thinking more about wrapping your main conditions into an if-if else, along with the actions, and not having the extra variable.

Thinking about it, I think you may need to tweak the logic a bit.

I guess the idea is that
If ANY rooms are too cold - turn on
If ALL rooms are hot enough - turn off
(which allows rooms to lie between hot and cold, and heating to carry on doing what its doing)
??

if   (cold condition A  ||  cold condition B || cold condition C) {
    // at least one room is cold
    turn things on
} else if (hot condition A  &&  hot condition B && hot condition C) {
    // ALL rooms too hot
    turn things off
}
// else nothing new happens

Sorry for the late reply, i have been making a PCB for my project so the PI can control my 12 V relays and everything is neat and reliable (Without me frying my PI).

I see what you mean with the else if code for the main part. This will make it easier to read and tidies things up.

Thanks for the tip!

Yesterday i soldered my output relay PCB and during the testing of my PCB i noticed that the rules had stopped working. The day before yesterday i have installed LG tv bindings (doesnā€™t work yet) and made some changes for this implementation. Maybe this has caused the rules to stop working???

So the next steps are:

  • Undo all changes related to the LG tv binding
  • test the rules and see if i can get everything working again
  • Learn about groups
  • rewrite code using groups and ifā€¦else ifā€¦ statements

Priority is to get everything working again and trying to work out why the rules stop working.

Removed LG tv binding and i got the rules to work again. Last weekend i did a test run and noticed that my heater was having a max. temp problem.
Because i now was controlling every room to its setpoint a radiator thermostatic valves were closed at one point. This caused the pressure/temperature to rise to its maximum.
Today i installed a max pressure bypass valve and i am testing again. First test looks promising, if this is successful i will start reading about groups.

This is a small overview of what i have done till now to get my house heating automated. I hope this is helpful to anyone.

I started with a Max! Radiator Thermostat in every room including the floor heating. I installed thermostatic valves in all floor heating groups so i can control these separately.

In every floor heated room i also added a Wall Thermostat to get the actual temperatures of these rooms.
Everything was connected via a Max! Cube and talking to my Raspberry Pi with Openhab. The control was more or less stand alone and Openhab was only reading temperatures and set-points and was controlling the Heater and also the pump for the floor heating.

Because i was now keeping the boiler on until all rooms had reach there set-points the pump was pumping against closed valves for all rooms which had reached the set-point and he was pumping against a almost closed valve for the last room which had not reached the set-point.

This caused the pressure to rise in the system, which was not good for the pump and i was wasting heat. To overcome this i installed a by-pass valve.
This solved the high pressure in the installation when valves close as they reach there set-point but the heating (especially the floor heating) was very slow to get to the desired set-point. This was caused by the thermostatic valves closing the hot water in the floor heating when they reach the set-point.

I realized that i needed on/off valves for the floor heating to heat these floors as quickly as possible. Therefor i removed all the Max Radiator Thermostats on the floor heating groups and replaced these by Thermostatic Motors.

I am now having my Raspberry Pi controlling these valves, opening and closing depending on the set-point. I also added a 0.5 degrees Celsius offset to the set-point temperature to avoid continuous on/off switching of the boiler.
I will post my rules down below and maybe this information is useful to someone.

Home.rules is now:

var boolean Heating = false
var boolean Vloer = false

var boolean WK = false
var boolean GNG = false
var boolean KNK = false


rule "Ketel aan"
when
Item WallmountedThermostatWoonkamerThermostaat_CurrentTemperature changed or 
Item WallmountedThermostatWoonkamerThermostaat_SetpointTemperature changed or 

Item WallmountedThermostatGangThermostaat_SetpointTemperature changed or
Item WallmountedThermostatGangThermostaat_CurrentTemperature changed or

Item WallmountedThermostatKeukenWand_CurrentTemperature changed or 
Item WallmountedThermostatKeukenWand_SetpointTemperature changed or

Item ThermostatRadiatorRoomFront_SetpointTemperature changed or
Item ThermostatRadiatorRoomFront_CurrentTemperature changed or

Item ThermostatRadiatorRoomBack_SetpointTemperature changed or
Item ThermostatRadiatorRoomBack_CurrentTemperature changed


then


if (((WallmountedThermostatWoonkamerThermostaat_SetpointTemperature.state as Number) - 0.5) < (WallmountedThermostatWoonkamerThermostaat_CurrentTemperature.state as Number))
{
Heating = false
Vloer = false
WK = false
}

if (((WallmountedThermostatGangThermostaat_SetpointTemperature.state as Number) - 0.5) < (WallmountedThermostatGangThermostaat_CurrentTemperature.state as Number))
{
Heating = false
Vloer = false
GNG = false
}

if (((WallmountedThermostatKeukenWand_SetpointTemperature.state as Number) - 0.5) < (WallmountedThermostatKeukenWand_CurrentTemperature.state as Number))
{
Heating = false
Vloer = false
KNK = false
}

if (((ThermostatRadiatorRoomFront_SetpointTemperature.state as Number) - 0.5) < (ThermostatRadiatorRoomFront_CurrentTemperature.state as Number)
|| ((ThermostatRadiatorRoomBack_SetpointTemperature.state as Number) - 0.5) < (ThermostatRadiatorRoomBack_CurrentTemperature.state as Number))
{
Heating = false
}

if ((WallmountedThermostatWoonkamerThermostaat_SetpointTemperature.state as Number) > ((WallmountedThermostatWoonkamerThermostaat_CurrentTemperature.state as Number) + 0.5)) 
{
Heating = true
Vloer = true	
WK = true
}


if ((WallmountedThermostatGangThermostaat_SetpointTemperature.state as Number) > ((WallmountedThermostatGangThermostaat_CurrentTemperature.state as Number) + 0.5))
{
Heating = true
Vloer = true
GNG = true
}


if ((WallmountedThermostatKeukenWand_SetpointTemperature.state as Number) > ((WallmountedThermostatKeukenWand_CurrentTemperature.state as Number) + 0.5))
{
Heating = true
Vloer = true
KNK = true
}

if (ThermostatRadiatorRoomFront_SetpointTemperature.state > ThermostatRadiatorRoomFront_CurrentTemperature.state
|| ThermostatRadiatorRoomBack_SetpointTemperature.state > ThermostatRadiatorRoomBack_CurrentTemperature.state)
{
Heating = true
}

if (Heating==true){
KETEL.sendCommand(ON) 
}
else{
KETEL.sendCommand(OFF)
}


if (Vloer==true){
POMP.sendCommand(ON) 
}
else{
POMP.sendCommand(OFF)
}


if (WK==true){
WOONKAMER.sendCommand(ON)
}
else{
WOONKAMER.sendCommand(OFF)
}


if (GNG==true){
GANG.sendCommand(ON)
}
else{
GANG.sendCommand(OFF)
}


if (KNK==true){
KEUKEN.sendCommand(ON)
}
else{
KEUKEN.sendCommand(OFF)
}



end
//This is the items file

Switch KETEL "CV ketel"{gpio="pin:24 activelow:yes initialValue:high"}
Switch POMP "Pomp Vloer"{gpio="pin:23 activelow:yes initialValue:high"}
Switch WOONKAMER "WK Vloer"{gpio="pin:25 activelow:yes initialValue:high"}
Switch GANG "Gang Vloer"{gpio="pin:27 activelow:yes initialValue:high"}
Switch KEUKEN "Keuken Vloer"{gpio="pin:22 activelow:yes initialValue:high"}

Home.sitemap:

sitemap home label="RvD SmartHome"
{
       Frame label="CVKetel"
       {
               Switch item=KETEL
       }
Frame label="Pomp Vloer"
       {
               Switch item=POMP
       }
Frame label="Woonkamer Vloer"
       {
               Switch item=WOONKAMER
       }
Frame label="Gang Vloer"
       {
               Switch item=GANG
       }
Frame label="Keuken Vloer"
       {
               Switch item=KEUKEN
       }


}

Remark:
I am using a Windows pc, and via Samba i can access the files on the Raspberry. I used Wordpad to make changes to the rules file but noticed my rules were not working as expected.
The reason was the text formatting via Wordpad, Openhab was not processing the rules in the right way.

When i made the same changes to the rules via Putty and sudo nano home.rules the same code was recognized and the rules processed as they should.

Yep, you mustnā€™t have a combination of old-style (hydropneumatic) and new-style (fully digital) control.
These will work against each other in a number of situations.
You have to do it right in the first place. Either replace/adjust ALL valves/thermostats/thermometers or better stick with an all-hydropneumatic control.
A very important thing I learned along the way, too.
Trouble is, even most HVAC craftsmen donā€™t understand that.

PS: please edit your posts to use code fences!

I have edit the posts to use code fences (never knew that existed :wink: ), learning all the time.

I just find out by removing the Max! thermostatic valves the week programming, which was done with the Max! cube, is not working anymore.
This is the next thing i have to setup in Openhab. Reading about making groups just has to wait a bit longer :grinning:

Tonight suddenly the rules stopped working. I have no idea why, i used the following command and they started working again:
sudo /bin/systemctl start openhab2.service
Anyone who has an idea what could be happening?

Sorry to hear. But this is off topic so please open another thread. And give as much detail as possible else noone can help.

I will ask the question in a different threat, sorry that i went off topic. Maybe you can just delete these last posts?
Thanks.