Rule to lower temperatur when door is open for more then 2 minutes

Hello, i am looking for a rule to lower the temperatur for my max! thermostate when a door is open for more then 2 Minuntes and restore the former set temperatur when the door is closed. The rule for lowering the temperatur is easy:

var Timer tWG_Tuer = null 

	rule "Send telegram when Backdoor is open after 30 Sec"
	when
	    Item  WG_Tuer changed to OPEN
	then
		if(tWG_Tuer==null) {
    		tWG_Tuer = createTimer(now.plusSeconds(30)) [|
    		if (WG_Tuer.state==OPEN) {
    			77 sendTelegram("Ludger", "Die Wintergartentuer ist auf")
                            sendCommand(WG_SetTemp, "15.0")
    		}
    		tWG_Tuer = null
    		]
    	}  
	end

But how do i save the former temperature “WG_SetTemp” and how to do the door close rule.

I have no idea.

Quick and dirty, with errors possible :wink:

var Number lastValue = -1
var Timer tWG_Tuer = null 

	rule "Send telegram when Backdoor is open after 30 Sec"
	when
	    Item  WG_Tuer changed
	then
if(WG_Tuer.state ==OPEN){
		if(tWG_Tuer==null) {
    		tWG_Tuer = createTimer(now.plusSeconds(30)) [|
    		if (WG_Tuer.state==OPEN) {
    			77 sendTelegram("Ludger", "Die Wintergartentuer ist auf")
                 lastValue = WG_SetTemp.state
                            sendCommand(WG_SetTemp, "15.0")
    		}
    		tWG_Tuer = null
    		]
    	}  
} else if (WG_Tuer.state == CLOSED){
   if(tWG_Tuer==null) {
       tWG_Tuer.cancel
        tWG_Tuer=null
   }
if(lastValue != -1)
   sendCommand(WG_SetTemp, lastValue )
}
	end
1 Like