Help With Hue Rules

Use a global var initialized to null then assign the result of the call to creatTimer to it.

var Timer myTimer = null
...
  
    // Create timer
    myTimer = createTimer( now.plusSeconds(2), [ |
        // Do stuff
        myTimer = null
    ]

...

    // Is timer running?
    if(myTimer != null) // timer is running

...

    // Cancel timer
    myTimer?.cancel
    myTimer = null

Or, even better, use Design Pattern: Expire Binding Based Timers

1 Like