[SOLVED] Close a Timer from a different Rule

Hello there,

i’m new on openHAB2, so I had a Little Question.

I just want to create a timer in one rule an close it in another rule.
In the doc’s it’s seams easily so I think the problem sit behind the Computer…

A Little description of what i want to do:

I just want to start a “delay”-timer for give my sensors some seconds to try build up Connection again.
So I create a Timer that’s change the state of my virtuell online-Status just if the sensor isn’t able to reconnect and don’t send a “online” Message.

If the sensor reconnect and sends his “online” Message i want to cancel the timer.

So I created to rules:

First Rule:

var Timer timer_steckbrett_oben_sensor_lastwill = null

rule "steckbrett_oben Sensor-Offline-Delay"
    Item steckbrett_oben_sensor_lastwill changed from online to offline    //wenn channel Item change from onlien to offline
    logInfo("steckbrett_oben Sensor-Offline-Delay", "Rule wird ausgeführt")

    timer_steckbrett_oben_sensor_lastwill = createTimer(now.plusSeconds((steckbrett_oben_sensor_delaytime_offlineDelayTimer.state as Number).intValue),  //testen 
        timer_steckbrett_oben_sensor_lastwill = null
        if(steckbrett_oben_sensor_lastwill.state == "offline")
            logError("steckbrett_oben Sensor-Offline-Delay", "Überschreitung der Offline Delay Time: Sensor steckbrett_oben")


Second Rule:

rule "steckbrett_oben Sensor-Online-Setter"
    Item steckbrett_oben_sensor_lastwill changed to online
    logInfo("kleinesgewacheshaus_links Sensor-Online-Setter", "Rule wird ausgeführt")
    logInfo("Steckbrett_oben_Sensor-online-Setter","beende offline delay Timer")

    //timer_steckbrett_oben_sensor_lastwill = null
    if(timer_steckbrett_oben_sensor_lastwill != null)


and the Error message from log’s:

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'steckbrett_oben Sensor-Online-Setter': The name 'timer_steckbrett_oben_sensor_lastwill' cannot be resolved to an item or type; line 11, column 8, length 37

P.S.: I tried it with other names for the timer but every time there appears the same problem…

Your rules must be in the same xxx.rules file to share the global variable. That would not be visible to rules in zzz.rules, for example.

One shoot -> one Goal…

this was my stupid failure……

Thank’s a lot !

It’s not obvious. “global” is a misnomer really.