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
then
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
when
motion ends
then
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