The problem is that you get a Python timer if it’s in the local scope, but a Java thread if it’s global. See these topics for investigations and experiments we’ve already done:
EDIT: Grrrrr, second try. First version was completely lost.
Rule
This is one of my more complicated Rules but it doesn’t really matter if it doesn’t work right. This is a Rule that alerts me when a service or device goes offline.
import org.eclipse.smarthome.model.script.ScriptServiceUtil
import java.util.Map
val Map<String, Timer> timers = newHashMap
rule "A sensor changed its online state"
when
Member of gSensorStatus changed
then
if(previousState == NULL) return;
// val aler…
The problem is that you are using a Jython timer, when you promote it to a global it gets typed differently (you get the underlying Java thread if I recall from our experiments with it). If you use the timer provided by openHAB then it behaves as expected in all contexts and all DSL documentation remains applicable. With the import and assignment below, createTimer can be used as it is in DSL rules, with Python syntax of course.
from core.actions import ScriptExecution
# Shortcut for similarit…