UI Rules - createTimer and reschedule not Working anymore

Tags: #<Tag:0x00007f1732318418>

Hi guys,

I just switched to OH3 and wanted to give those UI Rules a try.

Something mayor must have changed because I am completly unable to create Timers the way I am used to. Also forum and documentation research was fruitless.

2021-01-19 23:43:27.792 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'ca84e9a23a' failed: var timer = null

timer = createTimer(now.plus ___ Minutes(5), [ |

if(BewegungsmelderKueche_Bewegung.state == ON) {

timer.reschedule(now.plusMinutes(5))

}

else {

Kuechenschrank_Lichtschalter.sendCommand(OFF)

}

])

1. The method reschedule(ZonedDateTime) is undefined for the type null; line 5, column 139, length 10

2. Cannot refer to the non-final variable timer inside a lambda expression; line 5, column 133, length 5

3. Type mismatch: type Timer is not applicable at this location; line 3, column 30, length 246

This is the output of my Logfile. I DO NOT understand what this means :wink:

This is the script in Rules UI

var timer = null

timer = createTimer(now.plusMinutes(5), [ |

if(BewegungsmelderKueche_Bewegung.state == ON) {

timer.reschedule(now.plusMinutes(5))

}

else {

Kuechenschrank_Lichtschalter.sendCommand(OFF)

}

])

Please give me some advice of what I am doing wrong. Thank you in advance!

Search e.g. for ( click on the link ) site:openhab.org oh3 global variable - Google Suche
this should give a few hits for your problem.
One of them is How to define global variables in oh3 for DSL rule in main UI