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

rules
openhab2
maxcube
Tags: #<Tag:0x00007f1e5a9ddcd8> #<Tag:0x00007f1e5a9dda58> #<Tag:0x00007f1e5a9dd878>
(Markus Storm) #15

As already mentioned, consider using groups. You can then shorten your code to
if (group) changed

0 Likes

(Richard) #16

I definitely will look into how to setup groups, thanks.

In the meantime i discovered an other problem i have to solve first. I have connected a 12 V relay to the output to switch on the heater and pump. This is working with a small problem. The status of the output is changed according the result of the equations. Because i have several equations (multiple room temperatures to check) it can happen that the temperature in 1 room is oke but in the next room it is to cold.
If the heating was already ON the output then goes from OFF to directly ON again. The result is that the relay switches also from OFF to ON again in a short interval. The heater should not be switch OFF and ON again but should just remain ON all the time and should only switch OFF when all rooms are warm enough.

So my solution is to set a variable (TRUE or FALSE) as a result of the equations and only at the end set the output according this variable. So i first have to do some reading on how to store the outcome in a variable (Boolean).

0 Likes

(Richard) #17

Solved the unwanted switching off the output.

var boolean Heating = 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

then

if (WallmountedThermostatWoonkamerThermostaat_SetpointTemperature.state < WallmountedThermostatWoonkamerThermostaat_CurrentTemperature.state 
|| WallmountedThermostatGangThermostaat_SetpointTemperature.state < WallmountedThermostatGangThermostaat_CurrentTemperature.state
|| WallmountedThermostatKeukenWand_SetpointTemperature.state < WallmountedThermostatKeukenWand_CurrentTemperature.state)
{
Heating = false	
}
if (WallmountedThermostatWoonkamerThermostaat_SetpointTemperature.state > WallmountedThermostatWoonkamerThermostaat_CurrentTemperature.state 
|| WallmountedThermostatGangThermostaat_SetpointTemperature.state > WallmountedThermostatGangThermostaat_CurrentTemperature.state
|| WallmountedThermostatKeukenWand_SetpointTemperature.state > WallmountedThermostatKeukenWand_CurrentTemperature.state)
{
Heating = true	
}

EDIT: BOLD part is not correct, see below
if (Heating){
KETEL.sendCommand(ON)
POMP.sendCommand(ON)
}else{
KETEL.sendCommand(OFF)
POMP.sendCommand(OFF)
}

end

0 Likes

(Rossko57) #18

It seems to me that you could use if-else here.

if (conditions) {
turn things on
} else if (conditions) {
turn things off
}

Only one path is followed. If neither condition is satisfied, nothing is done.

0 Likes

(Richard) #19

I just did some more testing and i found out this didn’t work as i originally expected. I will implement your proposal. Thanks

0 Likes

(Richard) #20

Did some first testing and seems to work now. Thanks

if (Heating==true){
KETEL.sendCommand(ON)
POMP.sendCommand(ON)
}else if(Heating==false){
KETEL.sendCommand(OFF)
POMP.sendCommand(OFF)
}
0 Likes

(Rossko57) #21

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
0 Likes

(Richard) #22

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!

0 Likes

(Richard) #23

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.

0 Likes

(Richard) #24

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.

0 Likes

(Richard) #25

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.

0 Likes

(Richard) #26

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
0 Likes

(Richard) #27
//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"}
0 Likes

(Richard) #28

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
       }


}
0 Likes

(Richard) #29

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.

0 Likes

(Markus Storm) #30

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!

0 Likes

(Richard) #31

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:

0 Likes

(Richard) #32

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?

0 Likes

(Markus Storm) #33

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

0 Likes

(Richard) #34

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

0 Likes