[SOLVED] Variable Timer with "createTimer"

Hello all,

at the moment I try to program a variable Timer for my Bathroom Heater.

in the past i used a fix timer:

.....
createTimer(now.plusMinutes(90)) [|
if (MyHeaterBath.state != "ECO") {
sendCommand(MyHeaterBath,"ECO")
}
....

Now I want to Excange the fixed Minutes to a variable value

Fist I create an Item:

Number Heattimer

and set a Setpoint item in my sitemap:

setpoint item=Heattimer minValue=1 maxValue=150 step=1

My event Log shows, dass my Items value is changed to the set value. So it works to Set the wanted Minute value

My Rules I changed like this:

.....
createTimer(now.plusMinutes((Heattimer.state as DecimalType).intValue)) [|
if (MyHeaterBath.state != "ECO") {
sendCommand(MyHeaterBath,"ECO")
}
....

I tried also:

.....
createTimer(now.plusMinutes(Heattimer.state)) [|
if (MyHeaterBath.state != "ECO") {
sendCommand(MyHeaterBath,"ECO")
}
....

and

.....
createTimer(now.plusMinutes(Heattimer)) [|
if (MyHeaterBath.state != "ECO") {
sendCommand(MyHeaterBath,"ECO")
}
....

But the Heater is not switching off after the set Minutes. What i Do wrong? Can anybody help me?

BR
Dennis

You are on the right track…

val Integer TIMER_TIME = (Heattimer.state as DecimalType).intValue
createTimer(now.plusMinutes(TIMER_TIME), [ |
    if (MyHeaterBath.state != "ECO") {
        MyHeaterBath.sendCommand("ECO")
    }
])

Thank you, but it doesn’t work

(I recognize your small mistake with TIMERTIME and TIMER_TIME - this is not the cause :slight_smile:)

EDIT: It works I make another mistake! Thanks!

Coolio, please mark the thread as solved. Thanks

Instead of using

val Integer TIMER_TIME = (Heattimer.state as DecimalType).intValue

you could also use

val Integer TIMER_TIME = Heattimer.state as Number

:wink:

1 Like

Nice.
Didn’t know you could cast into integers like that

Hey gentlemen, what is ”ECO” in the code?

Mike

It’s a string that means something to the person who wrote the code. It’s not a magic word or anything.

Thank’s Rossko

“ECO” is a string like @vzorglub has written.

In this case “ECO” is the STring for the ECO-Mode of my Themostat. The Themostat knows to set the Temperature to 17°C if this command is received.

The setting of ECO mode is saved into my fritzbox router, which is also the bridge for the Themostat.

greets and EXTERMINATE!!! :wink: