In the mean time I tidied up your rules a bit
I used the postUpdate
method for the item Porch_Light_Auto because I assume that is just a flag item with no binding and a postUpdate is sufficient
I used the sendCommand
method for the item Porch_Light_Motion
In both cases I have used the method instead of the action as the item is known.
The explanation is here:
I have also used a timer instead of your 9 seconds sleep
Thread::sleep
should only be used if unavoidable and only for short periods (1s or less)
The explanation is here:
var Timer timer = null
rule "Back Porch Lights Switch2"
when
Item Porch_Light changed
then
if (Porch_Light.state == ON) {
Porch_Light_Auto.postUpdateOFF)
logInfo("info", "Manual2 Lights Switched On.")
}
if (Porch_Light.state == OFF) {
Porch_Light_Auto.postUpdate(ON)
logInfo("info", "Manual2 Lights Switched Off.")
}
end
rule "Back Door Motion"
when
Item BackDoorCamMotion changed
then
if (Daylight.state == OFF && Porch_Light_Auto.state == ON && BackDoorCamMotion.state
== "Motion") {
logInfo( "File", "Motion was detected at the back door at night.")
Porch_Light_Motion.sendCommand(ON)
if (timer === null) {
timer = createTimer(now.plusSeconds(9), [ |
if(Porch_Light.state == ON) Porch_Light_Motion.sendCommand(OFF)
timer = null // resets the timer
])
}
}
end