[SOLVED] Problem with rule about Door_sensor action

Hi,
I have a problem with an “alarm rule”
This is what I want to do.

When my dummy switch “Alarm_state” is ON and the door is opened :
if nobody set the alarm inactive within 10 seconds, then send a pushbullet.

this is my rule :

rule “Alarm”
when
Channel ‘XiaomiDoorWindowSensor_OpenStatus’ triggered OPEN
then
if (Alarm_State.State == ON)
{
Thread::sleep(10000) /* wait for 10 seconds */

       if (Alarm_State.State == ON){
	   	   	   sendPushbulletNote("Alarm", "Door Opened")}

}

end


But… althoug my switch is set “ON”, nothing happen when I open the door.
Can you please tell me what is wrong with my rule ?

Thanks

I think the problem comes from the “when” instruction.

I replaced the if clock by a simple instruction… nothing happens ! :frowning:

I really don’t understand…

That’s OK !!
I replaced “channel” by “item” and everything works good !

You don’t want to use a Thread::sleep for ore than half a second, it’s a bad idea

rule “Alarm”
when
    Item XiaomiDoorWindowSensor_OpenStatus changed to OPEN
then
    if (Alarm_State.State == ON) {
        createTimer(now.plusSeconds(10), [ | //* wait for 10 seconds */
            if (Alarm_State.State == ON) sendPushbulletNote("Alarm", "Door Opened")
        ])
    }
end

Thanks a lot for this advice !
The example with the motion captor is a very understandable explanation .