Light on Motion Rule - Need to understand

I defined the Item this way. It is a switch defined as below. So it is accessible fro all UIs

Switch    OfficeMainLightRule       "Main Light Rule [%s]"        <switch>    ["Switchable"]

The rule shall run only if the switch is on. If it’s OFF brake it and leave status as its… IF you switch it on than the rule check conditions an runs as defined.

I do not understand the intention. You mean to depend on state of the switch only and inside the rule create conditions for that…

when   motion begins
  if (rule switch on) {
      if (conditions){
        turn light on
        if a timer is already started, cancel it, and make handle null
      } end of 'if(conditions)'
   } end of 'if(switch)'
end of rule

   motion ends
  if (light is on) {
      make a new timer
      handle = start timer
             [ timer code for later:
               turn light off
               set handle null
             ] end of timer code
   } end of 'if()'
end of rule

Yes, its as simple as that.

Stop thinking of it as “stop rule running”.
You don’t care if the rule runs, you care about what the rule does.
So the rule still runs on every motion trigger, but the rule uses your new switch to decide what to do - maybe nothing.

You can choose to modify your [timer code] section as well. That can check the state of this new switch before turning off the light. Make sure it still tidies itself up if you skip the light action.

I knew I am complicating things…Let me try.