Hi to all
I’m searching a way to know the time from the activation of a action until to block of it.
For Example:
if (LivingRoom_Light2.state == ON) {
logWarn("Alarm", "The {} dentro", LivingRoom_Light2.state)
createTimer(now.plusSeconds(24)) [|
Auto.postUpdate(0)
LivingRoom_Light1.sendCommand(ON)
//
//controlla se la serranda è già per un pò abbassata e calcola di quanto
//la deve ancora abbassare
y = (Percentuale.state).intValue
Percentuale2.postUpdate(y)
logWarn("Alarm", "The {} valore di y in ap automat.", Percentuale.state)
createTimer(now.plusSeconds(y)) [|
LivingRoom_Light1.sendCommand(OFF)
Percentuale.postUpdate(0)
]
//
return;
]
}
When LivingRoom_Light1 swithes to ON i wait for Y seconds and then i command LivingRoom_Light1 to switch to OFF.
But if before of the Y seconds another command turn off LivingRoom_Light1, i want to know how many seconds it take to have this switch to OFF.
I searched the documentation but couldn’t find anything
You will need to take a timestamp before you create the Timer. When the second command comes in to turn off the light, check the timestamp and do the math to see how many seconds are left.
Well, you can either write code that rarely has problems, or you can write code that never has problems. If you want code that never has problems, just use now instead of getSecondsOfDay.