OH3: cron job and window-contact for heating control

  • Platform information:
    • Hardware: Raspberry PI4
    • OS: Raspberry Pi OS (32-bit)
    • Java Runtime Environment: openJDK version “” 2020-11-04
    • openHAB version: 3.0.1

I’m using OH now for a few months and make myself more and more familiar with it. By doing so I encounter more and more details to solve - like below …

I’m using a cron job to schedule daily heating up of a room in the morning in a simple rule as below. It works very reliable so far. I maintain rules in separate rule-files.

rule "AZ-Heizplan: AN"
        // weekdays ...
        Time cron "0 0 14 ? * SAT *" or     //14:00 Uhr
        Time cron "0 0 16 ? * SUN *"

Occasionally the cron job and opening a window clashes - For instance a window is opened in the morning. A bit later at the scheduled time the heating switches into its normal day-time temperature triggered by the cron job, which I want to avoid.

So I’m looking for a way to somehow “pause” or “re-schedule” the cron trigger. Heating up shall start, if the window was closed. I tried a few things but unfortunately it didn’t work out so far as I want.

What I do if a window opens is I persist the last Setpoint value and retrieve it after to window closed. That also works well.

var String para_1    
rule "AZ-Fenster-AUF"
             Item F_AZ_SensorWindow changed from CLOSED to OPEN
             para_1 = T_AZ_HeatMode.state.toString
             createTimer(now.plusSeconds(5), [ |
                 if(para_1 == "1" || para_1 == "15") {
                    logInfo("rule: AZ-Fentser-AUF", "Keine Bedingung passt")
            ]) end

What I have in mind is to combine the persistence service with the situation “heating-up and window open”. But unfortunately I couldn’t figure out how.

rule "AZ-Heizplan: AN"
    // cron ...
    // wenn das Fenster geöffnet
    if(F_AZ_SensorWindow == OPEN) {
        // How to change temp after window was closed?
    // wenn das Fenster geschlossen ...
    else {

I hope anyone can give me some support on this or even has another idea how to solve this?

Thank you very much in advance,

Think I’d use an intermediate Item, something like “Heating allowed”. Turn ON by cron, turn OFF later by your choice - fixed time, whatever.
When “Heating allowed” changes to ON, check window CLOSED, if okay do whatever e.g. set high temp.
When window changes to CLOSED, check if “Heating allowed” and if so,do it again.
When window changes to OPEN, set lower target temp or whatever.

Thank you very much. I thought about the same approach but was also thinking something less complex might be possible working with persistence. However, I will try this.

Best Regards!

Always more than one way to do things :smiley: there will be other approaches.
Using persistence to save and restore a setting is a good idea. But the problem you are facing is that when “start time” comes around, the current setting may or may not be the “high” setting. When it later comes to “restore” time, you don’t whether to restore a saved value or set something new - need some way to know.