Having problems setting up multiple motion sensors

Good day all,
I’m having difficulties setting up my basement motion sensors to act when either of them detects/stops detecting motion.

I’m trying to base it off my existing rule for a single sensor, which is a motion sensor built into a GE switch. These are based on conditions/triggers Richard posted in one of his PLEG basics threads.

Triggers

Name Description
tBasementLightOn Whenever the Basement Lights is turned on
tBasementMotion Whenever Basement Motion detects motion whether is armed or disarmed
tBasementMotion2 Whenever Basement Motion 2 detects motion whether is armed or disarmed
tBasementNotMotion Whenever Basement Motion stops detecting motion whether is armed or disarmed
tBasementNotMotion2 Whenever Basement Motion 2 stops detecting motion whether is armed or disarmed
tBasementStairMotion Whenever Basement Stairs detects motion whether is armed or disarmed
tBasementStairNotMotion Whenever Basement Stairs stops detecting motion whether is armed or disarmed
tBasementStairsOn Whenever the Basement Stairwell is turned on
Name Options Logic Expression
cBasementTurnOnLight (NOT tBasementLightOn) AND tBasementMotion
cBasementAutoOnLight cBasementTurnOnLight; tBasementLightOn < 15
cBasementTurnOffAutoOnLight cBasementAutoOnLight AND ( tBasementMotion ; tBasementNotMotion ) AND ( tBasementNotMotion ; NOW > 20:00)
cBasementTurnOffManualOnLight (NOT cBasementAutoOnLight) AND ( tBasementMotion ; tBasementNotMotion ) AND ( tBasementNotMotion ; NOW > 0:45:00)

So, the primary triggers I’m concerned about are tBasementMotion and tBasementMotion2, and their counterparts tBasemetnNotMotion and tBasementNotMotion2.

tBasementMotion is the GE motion sensor switch that currently works fine. I’ve added a battery-operated motion sensor in a different area of the basement that the GE sensor can’t detect. If I can figure this out, I’ll want to tie the basement stairway into the equation as well, so it doesn’t turn off the basement stairwell lights if it detects motion on either of the basement motion sensors.

My attempt to add the second sensor into the programming logic has been as such:

  1. Create a condition with an OR condition for motion, and an AND condition for not motion (tBasementMotion OR tBasementMotion2), (tBasementNotMotion AND tBasementNotMotion2), and I’ve substituted this condition into the logic conditions above. It doesn’t give me an error, but it doesn’t work either.
Name Options Logic Expression
cBasementMotion (tBasementMotion OR tBasementMotion2)
cBasementNotMotion (tBasementNotMotion AND tBasementNotMotion2)
  1. I’ve tried directly adding the above expressions in parenthesis into the condition expression, substituting it for the single trigger, and I get an error that I’m trying to compare null expressions.
Name Options Logic Expression
cBasementTurnOnLight (NOT tBasementLightOn) AND (tBasementMotion OR tBasementMotion2)
cBasementAutoOnLight cBasementTurnOnLight; tBasementLightOn < 15
cBasementTurnOffAutoOnLight cBasementAutoOnLight AND ((tBasementMotion OR tBasementMotion2) ; (tBasementNotMotion AND tBasementNotMotion2) ) AND ( (tBasementNotMotion AND tBasementNotMotion2) ; NOW > 20:00)
cBasementTurnOffManualOnLight (NOT cBasementAutoOnLight) AND ( (tBasementMotion OR tBasementMotion2) ; (tBasementNotMotion AND tBasementNotMotion2) ) AND ( (tBasementNotMotion AND tBasementNotMotion2) ; NOW > 0:45:00)

What am I missing?

I have another room that I’d like to do this to as well, as I have a hard-wired motion sensor from my alarm system, but I also have a Fibaro 3-in-1 sensor that I can place in a different location for better coverage, but it will also give me lux readings.

Home Lights Logic[288].pdf (151.3 KB)

I’ve only had a brief look but can’t see where the conditions have been added?
FWIW, the PLEG is getting seriously overloaded with triggers-conditions & actions - it’s too difficult to follow for someone who hasn’t had an intimate relationship in constructing it.
Consider breaking this into another PLEG for simplicity…

I understand what you are saying, however, it’s hard to break it apart further than I already have. I have PLEGs setup for several different types of actions in my home, so breaking it up further really isn’t an option. That’s why I specified the conditions and triggers separately, as well as attached the status report. I’ve highlighted the relavant triggers and conditions in yellow.It would also mean duplicating everything I’ve done into another PLEG instance, introducing the possibility of transcription errors.

As I mentioned, this is based off an example that Richard posted years ago. I’ve tried finding the original, but since the forums migrated, it’s hard to find the original anymore.

For what it’s worth, I’ve been experimenting with different variations, and I’ve made some progress, however, now when I walk into a room with multiple sensors, it’s flashing my lights on and off 8 or 9 times in quick succession.

variables beginning with a lower case t are Triggers, lower case c are conditions.

This is what I’ve been able to do:

Name Options Logic Expression
cBasementTurnOnLight (NOT tBasementLightOn) AND ( tBasementMotion OR tBasementMotion2 )
cBasementAutoOnLight cBasementTurnOnLight; tBasementLightOn < 15
cBasementTurnOffAutoOnLight cBasementAutoOnLight AND (( tBasementMotion ; tBasementNotMotion ) OR ( tBasementMotion2 ; tBasementNotMotion2 )) AND (( tBasementNotMotion ; NOW > 20:00) AND ( tBasementNotMotion2 ; NOW > 20:00))
cBasementTurnOffManualOnLight (NOT cBasementAutoOnLight) AND (( tBasementMotion ; tBasementNotMotion ) OR ( tBasementMotion2 ; tBasementNotMotion2 )) AND (( tBasementNotMotion ; NOW > 45:00) AND ( tBasementNotMotion2 ; NOW > 45:00))

To turn on the lights, I do a simple check (NOT tBasementLightOn, the basement lights are not on), AND I see a motion trigger on either basement motion sensors. If this condition is met, it will turn on the basement lights.

The second condition checks to see if the basement lights were automatically turned on cBasementAutoOnLight. This simply sets a condition for the following two conditions. No actually action is taken on this condition.

For the turning off of the lights, I had to break it up into ((tBasementMotion; tBasementNotMotion) OR (tBasementMotion2; tBasementNotMotion2)), so it’s looking at the conditions for each motion sensor and seeing if there is motion from either of them, then looking to see if the motion stops after motion. It then does a similar action to look for lack of activity for 20 minutes for automatically turning on the lights( cBasementTurnOffAutoOnLight), or 45 minutes if I turned on the lights manually (cBasementTurnOffManualOnLight)

So, there are two problems i am experiencing/foresee. First, is the rapid blinking. I believe that the condition cBasementTurnOffAutoOnLight, but I’m not sure how. If you look at another example CFamRoomTurnOnLight and it’s corresponding conditions, they seems to follow a similar time stamp sequence.

The other problem I foresee, is that if only one sensor sees motion, and it exceeds the time frame to turn off, but the other sensor never sees motion, will the logic still work? I’m specifically looking at (( tBasementNotMotion ; NOW > 20:00) AND ( tBasementNotMotion2 ; NOW > 20:00)) in each of the turn off conditions. I think it should work, so long as the motion/no motion sequence is greater than the stated time for the one that hasn’t been triggered, but I’m not 100% sure

Home Lights Logic[288].pdf (193.5 KB)

I’ve solved the issue. For simplification, I pulled out the (( tBasementMotion ; tBasementNotMotion ) OR ( tBasementMotion2 ; tBasementNotMotion2 )) part of each of the turn off light conditions, and made it into it’s own condition, and I changed the OR in the statement to an AND: cBasementNotMotion. I also added a set of parenthesis around the motion conditional statements (bolded) in the TurnOff conditions.

Name Options Logic Expression
cBasementNotMotion ( tBasementMotion ; tBasementNotMotion ) AND ( tBasementMotion2 ; tBasementNotMotion2 )
cBasementTurnOnLight (NOT tBasementLightOn) AND ( tBasementMotion OR tBasementMotion2 )
cBasementAutoOnLight cBasementTurnOnLight; tBasementLightOn < 15
cBasementTurnOffAutoOnLight cBasementAutoOnLight AND ( cBasementNotMotion AND (( tBasementNotMotion ; NOW > 20:00) AND ( tBasementNotMotion2 ; NOW > 20:00)))
cBasementTurnOffManualOnLight (NOT cBasementAutoOnLight) AND ( cBasementNotMotion AND (( tBasementNotMotion ; NOW > 45:00) AND ( tBasementNotMotion2 ; NOW > 45:00)))

I believe it was the OR that was causing the lights to flash. Once I pulled out two sensor expressions and put it into it’s own condition, I was able to see exactly what that condition was doing and it’s value in the whole expression. It’s only true for a very short time, when motion is sensed, then it goes back to false. At that point, the remained of the expression with the time value comes into play. The additional set of parenthesis seperating the how the light was turned on condition (auto vs manual) from the motion condition/timer part may have had some effect as well.

The only other thing I want to simplify, if possible, is the time conditions.

(( tBasementNotMotion ; NOW > 20:00) AND ( tBasementNotMotion2 ; NOW > 20:00)))
(( tBasementNotMotion ; NOW > 45:00) AND ( tBasementNotMotion2 ; NOW > 45:00)))

I was thinking I might be able to do a (tBasementNotMotion AND tBasementNotMotion2 ; NOW > 20:00) or something to that effect, but I’m getting an Invalid Key token error. Thoughts on how to make this statement work?

1 Like

With PLEG getting a bit long in the tooth, I made the switch over to Reactor plug-in and never looked back. For me, it’s infinitely easier to create and maintain routines with Reactor, so I only mention it as a possible viable alternative for your workflows.

I’ve heard this before, however, I have so much invested in PLEG as far as my home logic goes, switching over would be a) a completely new learning process and b) a long investment in transferring rules over. I’m not objecting to switching over, but it would take a lot of effort and I’d need to see what the benefits to switch over would be.

1 Like

Agreed. For example, I’m still moving all my old Vera “Scenes” over to equivalent Reactor routines, and have taken my time doing so (because it can be rather laborious, insofar as I also create virtual switches – using the same dev’s Switchboard plug-in – to trigger them via Alexa, and so forth).

Worth it? Absolutely. Advantages? Not entirely sure except for active code maintenance and, I believe, a much sleeker footprint on Vera’s limited resources.

PLEG once ruled, sure. But I will assert that Reactor runs rings around PLEG when it comes to some of its value-added features (sending SMTP notifications, for example, or being able to do GET HTTP requests directly from other services, even to Vera units on the same network, etc.).

Big fan here. I don’t mean this to come across as a promotional ad. :wink:

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules