Hello,
First of all you should not use Thread::sleep in rules unless REALLY necessary, that’s why:
You have two options here, you can use a timer or the expire binding
I will show you the expire binding solution
Install the expire binding
Create a switch item:
Switch KMotionPresence_Timer { expire="1m, command=OFF }
This item, when turned ON will turn itself OFF after 1 minute unless updated to ON
So, knowing that, your rule becomes:
rule "Presence in Kitchen changed"
when
Item KMotionPresence changed
then
KMotionPresence_Timer.sendCommand(ON) //Start timer whenever presence changes in the Kitchen
end
rule "Kitchen Presence Timer expires"
when
Item KMotionPresence_Timer changed to OFF
then
if(KMotionPresence == OFF && LightRoofKitchen.state == ON) {
logInfo("RULE", "Light switched OFF, because of no presence")
LightRoofKitchen.sendCommand(OFF)
}
end