Bedroom Heating Control Valve Rule Update

output

2021-05-02 17:50:30.063 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is OFF

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

2021-05-02 17:50:30.068 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Kids_Bedroom_Radiator_Valve' received command ON

2021-05-02 17:50:30.077 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Kids_Bedroom_Radiator_Valve' predicted to become ON

2021-05-02 17:50:30.083 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Kids_Bedroom_Radiator_Valve' changed from OFF to ON

2021-05-02 17:50:30.084 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gALLRADIATORS' changed from OFF to ON through Kids_Bedroom_Radiator_Valve

2021-05-02 17:50:30.088 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Switch' received command OFF

2021-05-02 17:50:30.094 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Switch' predicted to become OFF

2021-05-02 17:50:30.100 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Switch' changed from ON to OFF

2021-05-02 17:50:30.283 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Boiler_Status' changed from OFF to ON

Sorry that was a typo, i dont want the window to control the heating as such i would like the rule to check if the window is open or closed, if the window is open i want it to not allow the valve to come on to save on heating. If the window is closed i want it to allow the valve to come on.

Please note that Heating_Switch is a reverse of its actual state ie ON=OFF

Sorry for the confusion

That’s all? You’ve removed the other logging (that was telling to us it was ON) now?

Okay, makes more sense.
Your rule should do as you ask - but no more. Meaning, if the valve is already ON and the window is opened, nothing changes. Did you want to take action in that case?

Heating_Switch is not involved in this rule, so we don’t really care.

Finally got chance to add the code to the rule again and run some tests.

Output when window is closed

2021-05-03 15:54:59.833 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is ON

2021-05-03 15:54:59.835 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 15:54:59.836 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 19.8

2021-05-03 15:54:59.838 [INFO ] [org.openhab.core.model.script.test  ] - Cold, now do if-2 with radiator ON

2021-05-03 15:54:59.839 [INFO ] [org.openhab.core.model.script.test  ] - and window 0

Output when window is open

2021-05-03 15:57:55.618 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is ON

2021-05-03 15:57:55.620 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 15:57:55.621 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 19.8

2021-05-03 15:57:55.623 [INFO ] [org.openhab.core.model.script.test  ] - Cold, now do if-2 with radiator ON

2021-05-03 15:57:55.624 [INFO ] [org.openhab.core.model.script.test  ] - and window 1

From what i can gather from the above. The rule is allowing the Radiator valve to come on when the window is open when i dont want it to.
what do you think?

But …

It was ON before the rule started.

Under that condition, the rule you have shown us will not command the valve ON again, and sure enough we don’t see the log message associated with commanding it on either.

Again, are you expecting the rule to turn the valve OFF because the window is open after it is already ON? It’s not written to do that. Of course it can be changed, but maybe you should first work out what else is turning it ON without your knowledge.

The Rule is run everytime the room temperature or setpoint changes. I think what im looking to do is add code in to the rule, so that everytime the rule is started it also checks the state of the window, if its open basicly go no further with the rule and send command off to the valve. If the windows closed carry on with the rule and if the setpoint is higher than the current temperature then send command on to the valve? Does that make more sense?

Outputs from the last testing, window was open before i altered the setpoint and the valve still came on.

2021-05-03 15:57:56.627 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is ON

2021-05-03 15:57:56.629 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 15:57:56.630 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 18.8

2021-05-03 15:58:01.708 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is OFF

2021-05-03 15:58:01.709 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 15:58:01.710 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 17.8

2021-05-03 15:58:02.943 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is OFF

2021-05-03 15:58:02.944 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 15:58:02.945 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 18.8

2021-05-03 16:09:27.337 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is OFF

2021-05-03 16:09:27.338 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 16:09:27.339 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 19.8

2021-05-03 16:09:27.341 [INFO ] [org.openhab.core.model.script.test  ] - Cold, now do if-2 with radiator OFF

2021-05-03 16:09:27.342 [INFO ] [org.openhab.core.model.script.test  ] - and window 1

2021-05-03 16:09:27.343 [INFO ] [org.openhab.core.model.script.test  ] - Valve was off and window not-closed

2021-05-03 16:09:41.024 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is ON

2021-05-03 16:09:41.025 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.37

2021-05-03 16:09:41.026 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 18.8

2021-05-03 16:14:34.320 [INFO ] [org.openhab.core.model.script.test  ] - My rule is starting and the valve is OFF

2021-05-03 16:14:34.323 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with cur_temp 19.16

2021-05-03 16:14:34.325 [INFO ] [org.openhab.core.model.script.test  ] - Do if-1 with target 18.8

Any help in altering my rule will be much appreciated.

Yes, I know. But before you kept showing us logs when valve already ON so they didn’t help much with window stuff.

Sure. You have all the pieces, just need to re-arrange them. Have a go; you know how to check progress and results now.

Yes, that’s what you’ve asked for in the rule. This is what confused me earlier.

So …
Kids_Bedroom_Window.state != 0
That’s not-zero i.e. 1
This condition is true if the window is open.
So …
if (Kids_Bedroom_Radiator_Valve.state != ON && Kids_Bedroom_Window.state != 0)
if the valve is OFF (not-ON) -and- the window is open (not-closed) … then
Kids_Bedroom_Radiator_Valve.sendCommand(ON)
then the valve gets turned ON. It’s just doing as it is told.

Ok so i was unsuccessful at achieving my goal today so ive had to revert back to how ive previously done it. Creating 2 other rules in the ui to enable and disable the heating rule when the windows is opened or closed and also turning the valve off on the lata rule :grinning: