Hi all. Topic says it all. In the code below you can see it takes five lines to record the current state; is there a shorter way?
Why record the state? I wanted to have the motion trigger the light only if the door is not already open. I also found that the xor was prone to race condition so I also handle the case where they both trigger "simultaneously."
Front Door Motion motion *changed* Front Door contact open
pending Boolean false prev_door Boolean true prev_motion Boolean false
IF (NOT Front Door Light is on AND ( Illuminance of Weather is <= 1200 OR Time between Sunset-20 minutes and Sunrise+20 minutes) AND ( ( ( Front Door contact open XOR Front Door Motion motion active) AND NOT Variable prev_motion = true ) OR ( Front Door contact open AND Front Door Motion motion active AND NOT Variable prev_door = true AND NOT Variable prev_motion = true ) )) THEN Set pending to true On: Front Door Light Wait for event: Front Door Light turns on --> timeout: 0:00:05 END-IF IF (Front Door contact open) THEN Set prev_door to true ELSE Set prev_door to false END-IF IF (Front Door Motion motion active) THEN Set prev_motion to true ELSE Set prev_motion to false END-IF IF (NOT Front Door Light is on) THEN Set pending to false END-IF IF (NOT Variable pending = true OR Front Door Motion motion active) THEN Exit Rule END-IF Wait for Expression: --> timeout: 0:05:00 Off: Front Door Light Set pending to false