Method or field intvalue is undefined for the type NumberItem

I use Openhab 3 and want make some rules more flexible. One of them is a timer routine where I will set the delay minutes via a Variables.

I have create an Item Timer_Badezimmer format Number - this will be set by a slider. All tries to use it are no successfull.

if (HmIPETRV2000A1A49A133C2_1_SetPointTemperature.state as Number > 20.00)
    {
    logInfo("Badezimmer","Timer " + Timer_Badezimmer.state as Number + " Minuten Thermostat aus gestartet")
  createTimer(now.plusMinutes(Timer_Badezimmer.intvalue), [|  
        HmIPETRV2000A1A49A133C2_1_SetPointTemperature.sendCommand(13)
    ])
    }

This error I got

The method or field intvalue is undefined for the type NumberItem; line 11, column 479, length 8

Actual I have no clue anymore how I can realize it. I have made a lot of changes of data types and conversions but nothing works.

Is there anybody who knows whats wrong.
best
Christian

It’s correct.
When you display this in your logInfo(), you use the Item .state - not the label or the type or the name etc.
It follows that you would want to use the state in your plusMinutes() as well.

But even a state object does not have an .intValue method - first we’ll have to get the state as a Number (like you did in your if() earlier)

createTimer( now.plusMinutes( (Timer_Badezimmer.state as Number).intvalue ), ...

Thanks rossko,

changed it to

if (HmIPETRV2000A1A49A133C2_1_SetPointTemperature.state as Number > 20.00)
    {
    logInfo("Badezimmer","Timer " + Timer_Badezimmer.state as Number + " Minuten Thermostat aus gestartet")

    createTimer( now.plusMinutes( (Timer_Badezimmer.state as Number).intvalue ), [|  
        HmIPETRV2000A1A49A133C2_1_SetPointTemperature.sendCommand(13)
    ])
    }

Simular error

The method or field intvalue is undefined for the type Number; line 11, column 501, length 8

Ich have also changed it to long, same result → is it better to convert the timer value first to a string and then to a number ?

Or better use java and not a dsl rule ? But Java I have no experience.

bests
Christian

I made some more tries andwill share my solution. Ich canged from DSL to JAVA Script.

Here now the rule

    var logger          = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID); 
    var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");  
    var ZonedDateTime   = Java.type("java.time.ZonedDateTime");  
    var TimerMinutes    = items["Timer_Badezimmer"];

    logger.info("TimerMinutes: "+TimerMinutes);

    if (this.timer != undefined) {
      this.timer.cancel();
    }

    function turnOff() {
      events.sendCommand("HmIPETRV2000A1A49A133C2_1_SetPointTemperature", 13)
      logger.info("Badezimmer Timer "+items["Timer_Badezimmer"]);
      this.timer = undefined;
    }

    this.timer = ScriptExecution.createTimer(ZonedDateTime.now().plusMinutes(TimerMinutes), turnOff);

The Variable Timer_Badezimmer is an Item type number. This can be set with a slider and defined the time until the Temperatur will be changed back. The logger infos are only for testing and see the result - can be removed.

bests
Christian

Case sensitive. intValue

Thanks very much for your support, I will make a new try later. Actual the Java script work like expected.

But it explains the message, so i know in the future I must have a look on it too.