Timer Question - plusMillis in Openhab 3

Hello,

In Openhab 2 I used my now.plusMillis(…) to create timers in my rules. I understand that Openhab 3 uses Java Time and the plusMillis(…) is not working anymore. How to I achive to run a command in 250 Milliseconds from now? What I want to achieve is to stop the rollershutter after a quater of a second.

createTimer(now.plusMillis(250))[ |rollo.sendCommand(STOP) ] obviously does not work anymore.

createTimer(now.plusSeconds(0.250))[ |rollo.sendCommand(STOP) ] also does not work.

Thank you very much for a hint…

Regards,

1 Like

I used the method plusNanos(): https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html#plusNanos-long-

// duration in Nanoseconds
var Long duration = 250000000

var Timer t = createTimer(now.plusNanos(duration), [|
            logInfo("Created Timer","Timer finished. Sending command: " + cmd)
            sendCommand(myItemName, commandToSend)
        ])

Note: I copied the code snipped from above from my Lambda function. Please be aware, that the used variables myItemName and cmd are locally defined as val to be possible to pass them into the lambda function!

Thank you very much!