Motion Trigger and counter


#1

1) Give a description of the problem
Piston doesn’t always fire
2) What is the expected behaviour?
when motion, start a counter and if counter hits 1 then turn on lights,

3) What is happening/not happening?
piston very inconsistent the reason for the counter is I don’t want motion to keep firing the piston while the room is occupied so I wanted to restrict it to only running once while in a room, I also tried this with boolean and had same results. It seems to work ok with when I set it when motion counter = 1 but it still runs piston, I had it working before when motion counter changes to 1 but that’s where it starts getting inconsistent for some reason. any help is appreciated

**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)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

For what it’s worth, the reason for the over-active motion sensor is your line of code:

temp

Most of us use 5-10 minutes here, instead of 15 seconds


#4

Ok, the reason for the 15 seconds was just for testing purposes, other than that is that how you would try to achieve what i was trying to do? i only wanted it to fire once while in in a room and if the sensor goes inactive i didnt want it to keep firing


#5

This is impossible. When you have a trigger (such as Sensor 3’s motion) then each time that device changes at all (active or inactive), the entire piston will run thru the code, top to bottom, and will execute anything allowed by conditions.


What you can do is make code that directs different paths depending on other circumstances. (like you are trying to here)

I would start with this:

IF Sensor's motion changes to active  <-- Trigger
Then
   Set variable count = count+1
   Wait 1 second
      IF count is less than 2         <-- Condition
      Then
         Turn on lights
      END IF
END IF

IF Sensor's motion stays inactive for 10 min  <-- Trigger
Then
   Turn off lights
   Set variable count = 0
END IF

Notice the second IF is inside the first IF, and the third IF is all by itself.


#6

How’s this look?


#7

That should do it.

Please turn logging to Full, and turn on Trace if you have any issues


#8

Just tested it out for the first time and it worked flawlessly, thank you so much, didn’t even think to use the less than 2 on the counter, was stuck on changes to or is equal to. That should do it though. Going to test it out a few more times then call it good. Thank you so much!


#9

Glad to be able to help.

For the record, I think the real trick was moving the second IF inside the first, and changing it to a condition. You could also go with IF count is equal to 1


#10

Awesome, thanks again.