PIR Rule with 2 Switches

Hi Guys,

i got a Problem with a Rule.
I´ve already looked up the Deadmans Rule but could not figure it out how to set this.
Following Problem.
I Got a Pir Sensor which triggers Switch 2 ( has no connection to the Light itself only to Switch 4 which triggers the Light)
So when i´m running through my floor pir sensor triggers and switch2 change to on and send the command on to switch4 which triggers the light. After 2min. the light changes from on to off.
How can i change or disable a rule. For example i want to trigger switch4 manually that Light stays on and if someone triggers the PIR (switch2) nothing should happen so the light should stay on and don´t go off after 2min. would this rule do the job? and where do i have to put switch2 and switch4?
thanks alot guys!!

indent preformatted text by 4 spaces
rule "System Started"
when
    System started
then
    DeadMansSwitch.sendCommand("STARTUP")
end

rule "Rule that changes a gWatchItem"
when
    // some trigger
then
    DeadMansSwitch.sendCommand("RULE")
    Thread::sleep(50) // give it time to populate tto the Item registry, may not be needed, may need to be longer
    // do stuff
    Thread::sleep(200) // give stuff time to complete, may not be needed, may need to be longer
    DeadMansSwitch.sendCommand("MANUAL")
end

// more rules which trigger members of gWatchItems

rule "Is Manually Triggered?"
when
    Member of gWatchItems received update
then
    if(DeadMansSwitch.state.toString == "MANUAL") {
        // triggeringItem was manually triggered
    }
end

A way to detect “manual” operations

For your case, you’d need to “remember” the manual event, so that you can use it in rules later. A simple way might be to make a myLight_manual switch Item, that you can set and test the state of.

I guess you have timer actions involved, with the PIRs, so you’d probably need to take some action about cancelling any existing timers when entering ‘manual mode’

You’d need some way to eventually un-manual the system as well - perhaps after a fixed time with the expire binding.

Confused a bit. Are the switches just toggles? Are they physical or virtual switches? For your switch4, when it’s on manual, how do you set it back to “auto?” You hit it again?

If so, basically, your switch4 determines the auto/manual mode.

thanks guys!
i think i´ve managed this within my rule.

var Timer LightTimer 
rule "Motion Sensor Lights On"
when
	Item HCSR501_2 changed from 0 to 1
       
then
       if (Switch2.state == OFF) 
        if ( (now.getHourOfDay > 6 && now.getHourOfDay < 9) || (now.getHourOfDay > 15 && now.getHourOfDay <= 23)  || (now.getHourOfDay >= 0 && now.getHourOfDay < 2) ) {
        
	Switch2.sendCommand(ON)
        createTimer(now.plusSeconds(120))[|
        Switch2.sendCommand(OFF)
        
]
		}
        
end 

Blockquote