Controlling boiler from valve position

How would a script or rule look like, if I want the Switch to be off, when all values/numbers are 0, and on when its between 1 and 100?

Number Laboratoriet_Valve "Laboratoriet Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0011714:valve"}
Number Fyrrum_Valve "Fyrrum Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:KTS0000426:valve"}
Number Walk_in_Valve "Walk-in Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:KTS0000606:valve"}
Number Spisestue_Valve "Spisestue Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0010022:valve"}
Number Stue_1_Valve "Stue 1 Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0003322:valve"}
Number Stue_2_Valve "Stue 2 Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0002525:valve"}
Number Stue_3_Valve "Stue 3 Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0006269:valve"}
Number Trappe_Valve "Trappe Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0011680:valve"}
Number Boernevaerelse_Valve "Børneværelse Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0011821:valve"}
Number Gaestevaerelse_Valve "Gæsteværelse Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0011931:valve"}
Number Sovevaerelse_Valve "Soveværelse Ventilposition" <settings> {channel="max:thermostat:LEQ1324948:JTS0011641:valve"}


Switch BoilerAndCirculation "Vaskerum / *centralvarme" {channel="loxone:miniserver:504F94100E77:12EE1147-0355-4A01-FFFFEEE000000000"}

You can put all the items in a group and use persistence with a rule.

Example:

rule "persistOnEveryChange"
when
  Member of persistOnEveryChange changed
then
  if(triggeringItem.state > 0) {
    triggeringItem.persist
  }
end

Just need to add your switch to be on/off depending on the results.

Great thx, and where do I throw in the On Off thingie

rule "Boiler Start/Stop"
when
  Member of HeaterValve changed
then
  if(BoilerAndCirculation.state > 0) {
    BoilerAndCirculation.persist
  }
end
rule "Boiler Start/Stop"
when
  Member of HeaterValve changed
then
  if(BoilerAndCirculation.state > 0) {
    BoilerAndCirculation.persist
    YourSwitch.sendCommand(ON)
  }
else {
    YourSwitch.sendCommand(OFF)
}
end

I think you will need to use if(triggeringItem.state > 0) and not BoilerAndCirculation.state as this is a switch item not a number.

Maybe like this:

rule "persistOnEveryChange"
when
  Member of persistOnEveryChange changed
then
  if(triggeringItem.state > 0) {
    triggeringItem.persist
    BoilerAndCirculation.sendCommand(ON)
  }
else {
   BoilerAndCirculation.sendCommand(OFF)
}
end

Im pretty sure im close, but the switch doesnt trip, only manually in OH Controlpanel, and when I mouseover the group in the rule in visual I get all the states for the group etc…

rule "Boiler Start/Stop"
when
  Member of HeaterValveGroup changed
then
  if(HeaterValveGroup.state > 0) {
    HeaterValveGroup.persist
    BoilerAndCirculation.sendCommand(ON)
  }
else {
   BoilerAndCirculation.sendCommand(OFF)
}
end

What do you see in the logs when the rule runs? Open frontail log in a browser if you have frontail.

This is what I got in the log, it only sends OFF

2020-05-10 18:35:34.000 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:35:34.019 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:36:04.210 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:36:04.233 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:36:34.384 [vent.ItemStateChangedEvent] - Stue_2_Valve changed from 80 to 0

2020-05-10 18:36:34.395 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 18:36:34.440 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 18:36:34.466 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:36:34.477 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:37:04.525 [vent.ItemStateChangedEvent] - Trappe_ActualTemp changed from 19.3 °C to 19.1 °C

2020-05-10 18:37:04.603 [vent.ItemStateChangedEvent] - Dagligstue_Mode changed from BOOST to AUTOMATIC

2020-05-10 18:37:04.615 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:37:04.639 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:37:34.798 [vent.ItemStateChangedEvent] - Sovevaerelse_ActualTemp changed from 21.9 °C to 21.8 °C

2020-05-10 18:37:34.840 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:37:34.851 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:38:05.002 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:38:05.021 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:38:16.655 [hingStatusInfoChangedEvent] - 'hue:0220:ecb5fa1ed4d2:16' changed from OFFLINE: Hue bridge reports light as not reachable. to ONLINE

2020-05-10 18:38:35.166 [vent.ItemStateChangedEvent] - Spisestue_ActualTemp changed from 24.6 °C to 24.5 °C

2020-05-10 18:38:35.262 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:38:35.281 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:38:56.826 [hingStatusInfoChangedEvent] - 'hue:0220:ecb5fa1ed4d2:27' changed from ONLINE to OFFLINE: Hue bridge reports light as not reachable.

2020-05-10 18:39:05.382 [vent.ItemStateChangedEvent] - Stue_2_Valve changed from 0 to 80

2020-05-10 18:39:05.390 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 18:39:05.420 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 18:39:05.452 [vent.ItemStateChangedEvent] - Stue_3_Valve changed from 0 to 80

2020-05-10 18:39:05.453 [vent.ItemStateChangedEvent] - Dagligstue_Mode changed from AUTOMATIC to BOOST

2020-05-10 18:39:05.456 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 18:39:05.469 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:39:05.482 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 18:39:05.492 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

2020-05-10 18:39:35.597 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.2 °C

2020-05-10 18:39:35.624 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.2 °C

Try this:

rule "Boiler Start/Stop"
when
  Member of HeaterValveGroup changed
then
  if(HeaterValveGroup.state > 0) {
    HeaterValveGroup.persist
    BoilerAndCirculation.sendCommand(ON)
  }
else if (HeaterValveGroup.state <= 0){
   BoilerAndCirculation.sendCommand(OFF)
}
end

Nope, Im thinking, could it be a problem for the Rule, if some valves are 0 and some lets say 80? all valves are independent, and when the shines, all valves upstairs are 0 but basement still 18 or so…
Make sence?

Yes, as the rule is checking for all to be at or equal to 0. You may need to split the rule and groups, one for upstairs and one for downstairs if that will work for what you need.

You will need circulation if the valves are open correct?

if I stop using group but the items, can i just some kind of if,if,if,if,if,if = then?

That would work, but it all depends on if you need circulation when a valve is open, assuming the switch controls the pump. You would also need to know the correct value of each valve that is not 0 for when you want the switch off.

The switch just tells the OpenTherm protocol, to make the boiler stop circulating water to the radiators, only hotwater is then maintained :slight_smile:

So the mission is, if any of the Radiator Valves are open, the boiler should kick in, and offcource if all are closed, then kill the boiler…

Forgive me if I do not understand, I live in the South part of U.S. so boilers are rare, if any valve is open the boiler should kick in correct?

Yes

Try removing HeaterValveGroup.persist part from the rule and see if it changes.

Hmm its still very stuborn sending the OFF command when theres a Valve change in either direction

It may be the trigger and using groups,:thinking: change it to:
when
Member of HeaterValveGroup received update
then

EDIT: How do you have the Group defined, e.g. Group:Number, Group:Number:AVG, etc…?

same

Logs:

2020-05-10 19:54:48.230 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Varme.rules'

==> /var/log/openhab2/events.log <==

2020-05-10 19:54:54.590 [hingStatusInfoChangedEvent] - 'hue:0220:ecb5fa1ed4d2:15' changed from OFFLINE: Hue bridge reports light as not reachable. to ONLINE

2020-05-10 19:55:04.637 [hingStatusInfoChangedEvent] - 'hue:0220:ecb5fa1ed4d2:14' changed from OFFLINE: Hue bridge reports light as not reachable. to ONLINE

2020-05-10 19:55:06.787 [vent.ItemStateChangedEvent] - Gaestevaerelse_ActualTemp changed from 21.1 °C to 21.0 °C

2020-05-10 19:55:06.835 [vent.ItemStateChangedEvent] - Sovevaerelse_ActualTemp changed from 21.5 °C to 21.6 °C

2020-05-10 19:55:07.092 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.106 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.158 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.168 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.1 °C

2020-05-10 19:55:07.177 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.188 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.197 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:07.209 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:07.217 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:07.227 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:07.235 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.1 °C

2020-05-10 19:55:07.245 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:07.254 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:07.264 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:34.755 [hingStatusInfoChangedEvent] - 'hue:0220:ecb5fa1ed4d2:27' changed from ONLINE to OFFLINE: Hue bridge reports light as not reachable.

2020-05-10 19:55:37.006 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.041 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:37.094 [vent.ItemStateChangedEvent] - Stue_1_Valve changed from 0 to 100

2020-05-10 19:55:37.095 [vent.ItemStateChangedEvent] - Stue_2_Valve changed from 0 to 80

2020-05-10 19:55:37.096 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.110 [vent.ItemStateChangedEvent] - Stue_3_Valve changed from 0 to 80

2020-05-10 19:55:37.123 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.134 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.144 [vent.ItemStateChangedEvent] - Dagligstue_Mode changed from AUTOMATIC to BOOST

2020-05-10 19:55:37.146 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.1 °C

2020-05-10 19:55:37.157 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.168 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:55:37.177 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:37.185 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:37.193 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:37.200 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.1 °C

2020-05-10 19:55:37.209 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:55:37.217 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.173 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.214 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.244 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.260 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.272 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.289 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.298 [ome.event.ItemCommandEvent] - Item 'Dagligstue_ActualTemp_Lox_V' received command 25.1 °C

2020-05-10 19:56:07.309 [vent.ItemStateChangedEvent] - Boernevaerelse_ActualTemp changed from 24.7 °C to 24.8 °C

2020-05-10 19:56:07.310 [ome.event.ItemCommandEvent] - Item 'BoilerAndCirculation' received command OFF

2020-05-10 19:56:07.319 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.330 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.344 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.357 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

2020-05-10 19:56:07.367 [nt.ItemStatePredictedEvent] - Dagligstue_ActualTemp_Lox_V predicted to become 25.1 °C

2020-05-10 19:56:07.374 [nt.ItemStatePredictedEvent] - BoilerAndCirculation predicted to become OFF

Groups:

Group   HeaterValveGroup       "Radiator Ventil Position"        (HeaterValveGroup)

Items:

Number Laboratoriet_Valve "Laboratoriet Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:JTS0011714:valve"}
Number Fyrrum_Valve "Fyrrum Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:KTS0000426:valve"}
Number Spisestue_Valve "Spisestue Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:JTS0010022:valve"}
Number Stue_2_Valve "Stue 2 Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:JTS0002525:valve"}
Number Stue_3_Valve "Stue 3 Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:JTS0006269:valve"}
Number Boernevaerelse_Valve "Børneværelse Ventilposition" <settings> (HeaterValveGroup) {channel="max:thermostat:LEQ1324948:JTS0011821:valve"}


Switch BoilerAndCirculation "Vaskerum / *centralvarme" {channel="loxone:miniserver:504F94100E77:12EE1147-0355-4A01-FFFFEEE000000000"}

Since all need to be Zero I think using average would work.

Change group to:

Group:Number:AVG   HeaterValveGroup       "Radiator Ventil Position"        (HeaterValveGroup)

I gotta few things to take care of, best of luck, will check in later. Here’s a link to group info if using AVG didn’t work out.