In the future I want to use 2 KNX relay ports to control my shutters (up and down) and I want to do this using only one push button.
I started experimenting and I have the following rule that works quite okay, the only thing i want to add in the rule is a timer function.
In both switches, rol_UP and rol_down, i set up an expire of 5 seconds (the time it takes the shutter to move up/down). But it is this timing I want to add in my rule and not in my switch, it seems a more elegant solution for me.
Now the idea is:
push button (wip1) is changed;
if the shutter is up it will move down (until the 5s expire is over) and vice versa.
when the button (wip1) is changed and the shutters are moving they are stopped, paused and rol_UP is activated for 5s, reopening the shutters.
I tried using "Thread::sleep " and “createTimer” but both keep on running and can’t be stopped once started. Apparently the expire attribute can be interrupted. Or I am doing something wrong with sleep or timer?.
I think I’m looking for a function: turn on for X seconds or until turned off.
Any tips on this?
//rol_loc: 0=down 100=up 150=inWork work in progress, to check location
rule "rolluiken"
when
Item knxschakelaar_wip1 changed
then
if(rol_loc.state==0 && rol_down.state == OFF && rol_UP.state== OFF ) { // going up/open
rol_UP.sendCommand(ON) //thing is a 5 second expire switch
rol_loc.sendCommand(150)
rol_loc.sendCommand(100)
}
if(rol_loc.state==100 && rol_down.state == OFF && rol_UP.state== OFF ) { // going down/close
rol_down.sendCommand(ON) // thing is a 5 second expire switch
rol_loc.sendCommand(150)
rol_loc.sendCommand(0)
}
if(rol_down.state == ON || rol_UP.state == ON) { // stop while moving
rol_down.sendCommand(OFF)
rol_UP.sendCommand(OFF)
Thread::sleep(500) // pause to protect shutter motor from direct switching
rol_UP.sendCommand(ON)
rol_loc.sendCommand(150)
rol_loc.sendCommand(100)
}
end