Trying to turn off a light after two motion detectors show inactive for 3 minutes


#5

If you have two triggers in THE SAME IF, then you might experience problems.,.
several triggers with different IFs in a single piston, is a different ballgame


#6

Yes, the standard approach is:

IF ANY OF Motion 1 or Motion 2 changes to active
    Then Turn on light
END IF

IF ALL OF Motion 1 and Motion 2 stays inactive for X
    Then Turn off light
END IF

(basically your entire piston can be reduced to just a few lines)


#7

I tried this but it didn’t turn off the light. I don’t see how it could either, since both triggers will never be true at exactly the same time.

Are you sure we don’t need to use conditions instead?


#8

Those are two separate IFs… Not one inside the other.
(the first IF ends before the second begins)


#9

I tried this but it didn’t turn off the light

Please post the piston that did’n work…


#10

edit: And from this thread

1) why use conditions, why not only use triggers?

because 2 triggers can never be simultaneously true.


#11

That is correct.
When the first IF is true, the first block runs. When the second IF is true, then the second block runs.


Your “RD42” piston looks rock solid! It that is not working then the issue lies elsewhere.
(don’t forget your time of day restriction)


#12

For what it’s worth, whenever I have a time spanning midnight, I code it inverted.

For example, I will never use this code:
IF Time is between sunset and sunrise

Instead, I code it like this:
IF Time is not between sunrise and sunset


#13

I agree with @WCmore code looks great…

Just try one thing…I don’t like to use TIME as you did… I use TIME as a condition in the IF…

First trigger
Second Condition

IF sensor 5 or 9 changes to active
AND
If time is between sunset and sunrise (or as @WCmore suggested NOT between…)
----Then white bulb
----Turn ON

IF sensor 5 or 9 stay ineactive for 3 minutes
AND
If time is between sunset and sunrise (or as @WCmore suggested NOT between…)
----Then white bulb
----Turn OFF

this MUST work…
If not, I have to say you are having some other issues…
I use the exact code I wrote to you here, in many of my pistons…


#14

But because of the ALL, the second IF is waiting for two triggers to be TRUE at the same time. Unless I’m really missing something here, that can’t happen.

edit: And technically, if the second block ever were to be true, the whole piston is evaluated from top to bottom.


#15

I can say that the time restriction works, as the light is never turned on during the day. It gets turned on at sundown (and currently never turns off).


#16

Time is between OR not between is A CONDITION not a trigger…


#17

Correct.

The triggers are in the IF with both motion sensors being inactive for 3 minutes. That IF will never be true, as triggers are instantaneous.


#18

Trust me, this code works flawlessly:

temp

The single trigger fires 3 minutes after the last device turns inactive.

Any movement in front of either sensor will reset the timer.


This is irrelevant because the first block will be ignored. (it will be false at that time)


#19

Ahhhh. So even though there are multiple sensors in there, it’s technically only counted as a single trigger? I did not know that.

I still don’t understand why it’s not working. Lemme grab some logs.


#20

Make sure you leave the room completely for at least 4-6 minutes.
Staying in the room motionless rarely works… (and don’t forget about any pets)

The reason I say 4-6 minutes instead of 3 minutes is because each device will fall back on ‘inactive’ after a different duration.


#21

if you use ANY SENSOR, trigger will be first one that goes inactive x amount of time…
if you use ALL SENSORS, the system will wait untill ALL related sensors are inactive.


#22

So I should have viewed the logs first. It seems that one of the motion sensors (technically a Nest Hello) would see the light turning off as motion, and turn everything right back on.

Self inflicted yet again…


#23

I would have suggested this, but every one of your posts said that it never turned off.
(often times, the smallest detail is the most important when troubleshooting)


#24

I actually didn’t know myself. It happened very quickly, and every time I walked by it, it was on. That’s why I mentioned that I should have actually looked at the logs. Lesson hopefully learned…