using Openhab since years but still a newbie when using rules
I’ve a openhabian 2.4.0 installation and I need to do one thing. I’ve some ‘dumb’ rollershutter where I cannot open or close with a percentage. Only full up or full down. I’d like to setup a rules so that I can close a rollershutter at 50%. Basically going full up (to ‘reset’ the status) then going down for x number of seconds, then stop.
Now simple rule with thread::sleep like this:
when
Item Tapparella_Cameretta_Balcone_50 changed
then
// Goes up for 24 seconds (maximum time to reach full openness)
Tapparella_Cameretta_Balcone.sendCommand(0)
Thread::sleep(24000)
Tapparella_Cameretta_Balcone.sendCommand(STOP)
// Goes down for 12 seconds (time to reach desired openness)
Tapparella_Cameretta_Balcone.sendCommand(100)
Thread::sleep(12000)
Tapparella_Cameretta_Balcone.sendCommand(STOP)
end
would work, but I understand by reading the forums that it’s not safe. But I can’t for the life of me understand how I would do the same using timers. Since timers really fork another thread that goes in parallel, how can I actually ‘wait’ those seconds?
// Goes up for 24 seconds (maximum time to reach full openness)
Tapparella_Cameretta_Balcone.sendCommand(0)
createTimer(now.plusSeconds(24), [ |
Tapparella_Cameretta_Balcone.sendCommand(STOP)
] )
The timer can itself create another timer, if you are looking for a sequence.
Or construct the more elegant sequencing timer that reschedules itself.
Using expire binding accuracy would be a concern at sub-minute durations.
Thanks rossko57, I didn’t realize I can create another timer within the first one! That will surely be the solution, will code it and come back if I cannot make it work
It does everything that the Expire binding does plus a couple of new features around being able to set a String Item to NULL as well as “NULL”.
I don’t know that I would recommend it’s use from the start as I intended it mainly as a way for people who are already using Expire to move to OH 3 (where Expire 1.x won’t exist) without major changes to their config. But I did not really intend it to be something people would use forever.
But it works and it works well so there is no real harm in using it.