Help With Motion Sensor Piston


#1

1) Give a description of the problem
I have a pistion that I created for a motion sensor to turn on a light but lately it’s been very random with it’s actions. Sometimes it will turn the light on and then immediately off and sometimes it will work properly.

2) What is the expected behaviour?
Switch 5 is the light that I want to control with Motion Sensor 1. Basically if there is motion then Switch 5 turns on UNLESS any of Switch 3, Switch 4, or Outlet 1 are on. I then want Switch 5 to turn off when motion has been inactive for 60 seconds or if any of Switch 3, Switch 4 or Outlet 1 is turned on. I also only want all of this to happen between 9pm and 7am.

3) What is happening/not happening?
I thought my piston was pretty good, but it appears not to be based on the behavior I’m getting with random firing and inconsistent results.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)


#2

#3

I am not the expert here, but I think that I have added your criteria and simplified your piston with the following. I have not been able to test this, so keep that in mind. You can divide these up into two pistons or leave them as one.

(Notice the negative approach towards the time since your original code spanned midnight)

IF Motion Sensor 1 motion changes to active
AND
All of Switch 3, Switch 4, Outlet 1 are not on
AND
Time is NOT between 7 am and 9 pm
THEN
  with Switch 5
  Turn On
END IF

IF Motion Sensor 1 stays inactive for 60 seconds
OR
Any of Switch 3, Switch 4, Outlet 1 changes to on

AND

Time is NOT between 7 am and 9 pm             
THEN
  Wait 90 seconds   (Set TCP to never here)
  With Switch 5
    Turn Off
END IF

#4

Your could divide the second IF into two…

IF Motion Sensor 1 stays inactive for 60 seconds
AND
Time is NOT between 7 am and 9 pm             
  THEN
    With Switch 5
      Turn Off
END IF

IF Any of Switch 3, Switch 4, Outlet 1 changes to on
AND
Time is NOT between 7 am and 9 pm             
  THEN
    Wait 90 seconds   (Set TCP to never here)
    With Switch 5
      Turn Off
END IF