Slider value in Notifications

I am trying to use a slider value in as a timer value and also send that value in a notification, both of which I have seen done in examples but nothing will work for me. Could someone please assist with working examples or point me in the right direction.

I have these in a dsl rule and have tried many variants of data manipulation to get it to work as shown below, can some one help

//var duration = timer_length.state as DecimalType
//var duration = (timer_length.state as Number).intValue
//Number timerDuration
var Timer timer = null //Global variable

   // timerDuration = (timer_length.state as Number).intValue // transforms the Timer item value into an integer as timers only accept integers as arguments
var duration = (timer_length.state as Number).intValue * 10
//sendNotification("", duration) //doesn't work
  //sendNotification("" , 'Timer= ' +  String.format("%.3f", duration.state) + ' mm') //doesn't work
   sendNotification("", "Timer finished")

// the timer below also never works as the value is never parsed correctly either????
//var runtime = v_water_rf_timesilder.state as DecimalType
//var timerval = timer_length.state as DecimalType
//var duration = (timer_length.state as Number).intValue
  sendNotification("", duration)
   sendNotification("", "Timer finished")
    //timer1 = createTimer(now.plusSeconds(runtime.timerval), [ |
    // timer1 = createTimer(now.plusSeconds(duration), [ |                                              
        //var remain = MinutesRemainingOnTimer.state - 1
       // if( remain < 0 ) remain = 0
       //if( remain > 0) timer1.reschedule(now.plusMinutes(1))
       //  Theatre_Lights.sendCommand(OFF)     
       //  sendNotification("", "Timer finished")
  //  ]

First things first: how did you create the rule?

I would expect something like this:

// global var is defined on top of the first rule in the file.
var Timer tTheatreLights = null

rule "timer notification"     // rule definition in file needs a header
    // something happend, e.g.
    Item StartScene received command ON
    var Integer iDuration = 10                                 // set a default value
    if(timer_length.state instanceof Number)                   // if item value is of typ Number
        iDuration = (timer_length.state as Number).intValue    // use that instead
    sendNotification("", duration.toString)         // Message has to be a string
    tTheatreLights = createTimer(now.plusSeconds(iDuration),[|
        sendNotification("", "Timer finished!")

Please be aware that global vars can only be used in a *.rules file.


Thanks for the info and I can see how much it hurt you to look at my layout…
I appreciate the help. I needed to better declare the variables and fetch the states as you have demonstrated