DSL timer with unit number item

I am trying to get this rule to work:
timer_backhall = createTimer(now.plusMinutes(timerItem.state as Number), [ |
bright.sendCommand(OFF)
timer_backhall.cancel()
timer_backhall = null
logInfo("Motion Lights - " + getLocation(bright).label, “Timer elapsed. " + getLocation(bright).label + " " + getEquipment(bright).label + " turned OFF”)
])
timerItem is a number with unit “s” metadata

Hi, I have this working…

var Integer TIMER_TIME = (timerItem.state as DecimalType).intValue
timer_backhall = createTimer(now.plusMinutes(TIMER_TIME), [| 

Greets

That won’t work if the state of the Item is a Quantity type. It will fail the cast to DecimalType.

timerItem.state as Number

should work.

You are right. Mine is a number item without quantity.
But if I remember correctly state as Number didn’t work. But is is long time ago…

edit:
I tested with a Number:time Item.

(timerItem.state as Number).intValue

worked with timer.

Thank you both, indeed
(timerItem.state as Number).intValue is working fine