openhab/openhab — pull request #1436 by berndpfrommer (2014-09-18 11:52:55+00:00)
Title: added new action: createTimerWithArgument(expiryTime, argument, closure)

to allow creation of timers with an argument passed to the closure.
This allows more complex scripting for e.g. motion sensor timeouts.

This extends the existing createTimer() to allow for scripting like this:

var String cookie = "cookie"
var Timer timer = createTimerWithArgument(now.plusSeconds(10), cookie,
[ x |
logInfo("timer_expired", " with cookie: " + x)
]
)

Having the cookie allows the expiring timer to e.g. look up its timer in hash table.

A combination of Groups, hash maps, and timers with arguments allowed me to write
some powerful rules to avoid cut-and-pasting code.