Hello, I would like to use a Number item to schedule a time in rules.
My item definition is:
Number CancelloTimer "Timer Cancello [%.0f]" <clock>
My rule is
TimerCancello = CancelloTimer.state as Number waitTimer = createTimer(now.plusSeconds(TimerCancello))[ sendCommand(FibaroCancello, ON) postUpdate(CancelloAuto,0) ]
but once the rule is triggered, I receive:
Error during the execution of rule 'Cancello Auto': Could not invoke method: org.joda.time.DateTime.plusSeconds(int) on instance: 2016-06-29T11:08:20.250+02:00
How I can use the item and reuse the value of it as a wait timer?
you have to use an int value for plusSeconds(), so please try
waitTimer = createTimer(now.plusSeconds((CancelloTimer.state as DecimalType).intValue)) [
And maybe ensure, CancelloTimer is already set to a correct value:
if (!(CancelloTimer instanceof DecimalType)) CancelloTimer.postUpdate(10)
if (CancelloTimer.state as DecimalType < 1) CancelloTimer.postUpdate(10)
Thanks! Now it works.
There is another way to do that? I mean, If I create a Int var, may I assign the item state with a function like:
var int timer = Integer.parseInt(CancelloTimer.state)
The documentation don’t report any of the confersion function…