Jump to content

Room motion program logic?


sn0cr4sh

Recommended Posts

Posted

I'm having issues with a "room occupancy" program and I can't tell if my program logic is totally flawed, or maybe my sensor is acting up.  Or am I overloading the device with bad logic?

Setup: I have the EcoLink PIR2 Zwave motion sensor set about chest height in a kitchen, very clearly in view of activity in the room. The TEST jumper is enabled, so it's not locking out for 4 minutes after being tripped.  Should I not be doing it this way, and instead let it lock out for 4 mins?

Problem: the lights keep getting turned off on us while we are in the room, moving around right in front of the sensor.  The sensor seems to stop registering motion completely - the green light doesn't flash as we move in front of it.

I have two programs in a folder:

(1) Check Motion:  IF sensor is ON, run Kitchen Lights THEN

(2) Kitchen Lights: Turn lights on.  Wait 15 mins.  Turn lights off.

I've used this type of logic in other areas of the house and it seems to work, but those areas are usually areas we pass through, not linger in. So I could be approaching this totally wrong.

Universal_Devices_Administrative_Console.png

Universal_Devices_Administrative_Console.png

Posted

I had a setup like this except the motion sensor reset after 3 minutes.  The wait command was set to 15 minutes.  A multiple of 3.  What if you set the 15 minutes to 8 or 12?

 

Posted

There nothing in your programs that will turn your light off in less than 15 minutes.

Use th ac search fuction to find another program doing it.

Sent using Tapatalk

Posted

No matter what happens, the logic in your kitchen lights program is set to turn off after 15 minutes. 

I separate my offs when it comes to sensors.  That way, I can write various programs for whatever condition without effecting how the off works. I use:

If control motion is switched off and control motion is not switched on 

Then wait 5 minutes turn off light.

What happens is the motion will restart the timer each time it's sensed. 

Posted
10 minutes ago, lilyoyo1 said:

No matter what happens, the logic in your kitchen lights program is set to turn off after 15 minutes. 

I separate my offs when it comes to sensors.  That way, I can write various programs for whatever condition without effecting how the off works. I use:

If control motion is switched off and control motion is not switched on 

Then wait 5 minutes turn off light.

What happens is the motion will restart the timer each time it's sensed. 

My understanding was that if the program starts, I'm on a 15 minute countdown until the lights go off.  But every time I run the program again during that 15 minute window, I am just resetting my countdown to 15 minutes, which should keep the lights on until 15 minutes after the last motion was detected.

I'd like to try your idea, but I don't quite follow:

IF MotionSensor is OFF and KitchenLight is ON
  THEN wait 5 minutes.  Turn off KitchenLight

Is that what you mean?

Posted
14 minutes ago, sn0cr4sh said:

My understanding was that if the program starts, I'm on a 15 minute countdown until the lights go off.  But every time I run the program again during that 15 minute window, I am just resetting my countdown to 15 minutes, which should keep the lights on until 15 minutes after the last motion was detected.

I'd like to try your idea, but I don't quite follow:

IF MotionSensor is OFF and KitchenLight is ON
  THEN wait 5 minutes.  Turn off KitchenLight

Is that what you mean?

The way your program is written there's nothing that overrides the off. Locally you are saying turn the lights on wait 15 turn off. Regardless of what happens the system will run that.

My off program is based on movement so it's control motion is switched off and control motion is not switched on. 

What happens is the lights are on and someone is moving about the sensor will show on. Leave the room/stop moving, the sensor will send the off command which starts the then portion which is the wait time. If the motion triggers on during the wait, it cancels it and the light stays on. 

Posted
27 minutes ago, sn0cr4sh said:

My understanding was that if the program starts, I'm on a 15 minute countdown until the lights go off.  But every time I run the program again during that 15 minute window, I am just resetting my countdown to 15 minutes, which should keep the lights on until 15 minutes after the last motion was detected.

Not so sure that this is true.  That works on "control" conditions, but not necessarily on "status" conditions.  "Status" conditions trigger only upon CHANGE of state, not upon every receipt of ON commands.  But...if the sensor turns off, then back on, I would expect the program to re-trigger the wait program.  Furthermore, I find it hard to know without testing whether z-wave sensors trigger a "control" condition (my z-wave switch does not) without testing it.

What I suspect is happening is that the motion sensor continues to trigger before turning off, and the status never changes to off, then back to on to re-trigger the timer.

Posted

I think what you want us if motion is on turn lights on. If motion is off wait 15 Minutes then turn lights off. The issue will be what happens during the wait if motion is detected again and the status of motion changes to on. 

Posted
43 minutes ago, oberkc said:

Not so sure that this is true.  That works on "control" conditions, but not necessarily on "status" conditions.  "Status" conditions trigger only upon CHANGE of state, not upon every receipt of ON commands.  But...if the sensor turns off, then back on, I would expect the program to re-trigger the wait program.  Furthermore, I find it hard to know without testing whether z-wave sensors trigger a "control" condition (my z-wave switch does not) without testing it.

What I suspect is happening is that the motion sensor continues to trigger before turning off, and the status never changes to off, then back to on to re-trigger the timer.

This seems to be the most likely scenario. I'll change the program logic to be Control vs Status, plus use the suggested idea from lilyoyo1.

Posted

So I changed the logic based on my understanding of lilyoyo's version.

I'm not clear why I would need to use both the "If sensor is switched off" AND "if sensor is not switched on".

Universal_Devices_Administrative_Console.png

Universal_Devices_Administrative_Console.png

Posted
13 minutes ago, sn0cr4sh said:

I'm not clear why I would need to use both the "If sensor is switched off" AND "if sensor is not switched on".

Well...if you choose to do this with separate programs, and you want to avoid having the 15-min timer cause the lights to go off while the room is still occupied....

The "switched off" program will trigger upon receipt of OFF commands and cause the program to run THEN path (the second condition, not switched on, is true at all times other than receipt of an ON command).  This will start the 15-min wait timer.

The "not switched on" condition will trigger upon receipt of an ON command, and will evaluate FALSE, thus causing the ELSE path to run.  If this happens during the 15-minute period, then it will halt the timer until the next OFF command is sent.

Personally, this seems overly complicated to me for the specific set of requirements you state.  On the other hand, using two programs might be more expandable should your desires change.

Of course, none of this will work if the ISY does not, or cannot, distinguish between "control" and "status".  Only you will be able to confirm this.  Trigger a motion....do these programs react in any way?  Trigger multiple motions with short periods between.  Do these programs react each time motion is sensed, or only after the sensor first turns off?

Posted

Are your lights turning off before the 15 minute timed off? If so your program isn't doing it.

Does this Zwave MS not have an Off command disable? Most using Insteon MS users disable the Off command in the MS and let programs handle the Off control.

One program is all that is needed and two does not offer any advantage with the simplicity of your programs.

If
      MS is switched On   <--------- 'switched' detects the On command only when sent and makes the Wait timer retriggerable.
Then
     set Lamp to On
    Wait 15 minutes
    set Lamp to Off
Else
    ----

Posted
12 minutes ago, larryllix said:

Are your lights turning off before the 15 minute timed off? If so your program isn't doing it.

Does this Zwave MS not have an Off command disable? Most using Insteon MS users disable the Off command in the MS and let programs handle the Off control.

One program is all that is needed and two does not offer any advantage with the simplicity of your programs.

If
      MS is switched On   <--------- 'switched' detects the On command only when sent and makes the Wait timer retriggerable.
Then
     set Lamp to On
    Wait 15 minutes
    set Lamp to Off
Else
    ----

I honestly don't know about the "off" command for a Zwave MS. I also prefer your single-program for most use cases. I think the distinction is "STATUS" vs "CONTROL" for my IF statement. I've been using "STATUS" this whole time, and the Kitchen turned off about 3 times today while being occupied.

Posted
1 hour ago, sn0cr4sh said:

So I changed the logic based on my understanding of lilyoyo's version.

I'm not clear why I would need to use both the "If sensor is switched off" AND "if sensor is not switched on".

Universal_Devices_Administrative_Console.png

Universal_Devices_Administrative_Console.png

You need something to stop the action that happens. Look at the system as a robot. It does exactly what you tell it.  If your motion sensor is telling the lights to turn off, what tells it not to? That's where the "on" statement comes from. 

I like separating my offs because I can have different situations occur. For example, during the day my lights don't automatically turn on. During certain times certain lights turn on to certain brightness levels as well as late at night. 

By having the off separate from that, I don't have to worry about different programs interfering with different actions. 

Posted
7 minutes ago, lilyoyo1 said:

You need something to stop the action that happens. Look at the system as a robot. It does exactly what you tell it.  If your motion sensor is telling the lights to turn off, what tells it not to? That's where the "on" statement comes from. 

I like separating my offs because I can have different situations occur. For example, during the day my lights don't automatically turn on. During certain times certain lights turn on to certain brightness levels as well as late at night. 

By having the off separate from that, I don't have to worry about different programs interfering with different actions. 

Ok, so I don't want to tangent too far off, but this might come down to some misunderstanding on my part for how the logic of the program is evaluated. Just when I think I know how something works, I learn something new.

My misunderstanding: The IF gets evaluated at a precise moment in time, and based on the one-time evaluation it executes the THEN or the ELSE and ceases operations. Nothing that happens to the system after evaluating the IF would change the outcome. In this case, the statement "IS OFF AND IS NOT ON" seem like redundant statements to me. I might be thinking of this in linear programming / scripting terms.

It doesn't sound like that is the program flow. It sounds like the program runs like this:

IF sensor is switched OFF AND sensor is NOT switched ON WHILE THIS PROGRAM IS RUNNING, THEN wait 15mins AND switch lights OFF.

So if during the 15min countdown, the IF statement no longer evaluates to TRUE, it no longer executes THEN.  The program is persistent, constantly running. 

Is this what's actually going on?

Posted
1 hour ago, sn0cr4sh said:

I honestly don't know about the "off" command for a Zwave MS. I also prefer your single-program for most use cases. I think the distinction is "STATUS" vs "CONTROL" for my IF statement. I've been using "STATUS" this whole time, and the Kitchen turned off about 3 times today while being occupied.

I don't have any Zwave. Let's say the Off command is blocked in the MS  and you detect "status on". Off will never happen.
 

Status is the last known position. Control switched is the fresh command arriving. Multiple ONs without an Off does not change Status detections, but Control switched will trigger every time without any status change. It is good for retriggering program timers.

Again. If you are experiencing the lights Off before 15 minutes then you have another program turning them off. You can search programs by right clicking on any program in the admin console program tree and select the search function, searching for that same device. I have found a few old ones that I forgot about years back with this.

Posted
2 minutes ago, larryllix said:

I don't have any Zwave. Let's say the Off command is blocked in the MS  and you detect "status on". Off will never happen.
 

Status is the last known position. Control switched is the fresh command arriving. Multiple ONs without an Off does not change Status detections, but Control switched will trigger every time without any status change. It is good for retriggering program timers.

Again. If you are experiencing the lights Off before 15 minutes then you have another program turning them off. You can search programs by right clicking on any program in the admin console program tree and select the search function, searching for that same device. I have found a few old ones that I forgot about years back with this.

I definitely checked that out. There aren't any rogue programs messing it up. I've had that happen before, so I knew to check for it. 

Posted
8 minutes ago, sn0cr4sh said:

I definitely checked that out. There aren't any rogue programs messing it up. I've had that happen before, so I knew to check for it. 

Your first post implied these lights may have been going off before the 15 minutes. This is the third time I will ask. Is this true?

Posted

If you say your logic works in other programs, and you say the green LED is not going off when moving in front of it then the problem seems to be with the motion sensor not working as intended.

 

 

Posted
1 minute ago, larryllix said:

Your first post implied these lights may have been going off before the 15 minutes. This is the third time I will ask. Is this true?

They were going off, which is the whole reason for the post. We were in the kitchen, a few feet from the sensor, and the lights would turn off.  The programs I posted in the first post are the only programs that the Kitchen Lights or Kitchen Sensor are found in. So the post was meant to ask if my logic is flawed and the lights are being turned off because of that. Part of that logic has to involve the jumper and the lock out period of the sensor.

Or, as could still be a possibility - I have an actual problem or fault with the sensor, which could totally screw up the program logic too.

Posted
1 hour ago, sn0cr4sh said:

 

IF sensor is switched OFF AND sensor is NOT switched ON WHILE THIS PROGRAM IS RUNNING, THEN wait 15mins AND switch lights OFF.

So if during the 15min countdown, the IF statement no longer evaluates to TRUE, it no longer executes THEN.  The program is persistent, constantly running. 

Is this what's actually going on?

This is correct. The if (if motion is switched off) starts the THEN running. The if (if motion is switched on) causes it to re-evaluate and stop the countdown. 

Your motion sensor probably works properly. I wouldn't worry about that part right now. Your original program didn't work due to the logic. You never had anything in your original program to cause it re-evaluate so the program continued to run its course.

Technically while moving around your kitchen your sensor probably always sent the on command. It's just after 15 minutes, the off from the original run would hit and lights would turn off since there was nothing to stop that from happening

Posted

What about setting a state variable for when the motion is sensed.  Each time this program is triggered, the then sets the variable to true, else sets it to false.  

Second program runs when the state variable is true.  The then is to turn the light on, wait x minutes, turn light off.  

That way if the motion detector continues to turn off and then back on during the x minutes, the timer resets.  

On mobile, so don't know if anyone else suggested.  

Posted
31 minutes ago, sn0cr4sh said:

They were going off, which is the whole reason for the post. We were in the kitchen, a few feet from the sensor, and the lights would turn off.  The programs I posted in the first post are the only programs that the Kitchen Lights or Kitchen Sensor are found in. So the post was meant to ask if my logic is flawed and the lights are being turned off because of that. Part of that logic has to involve the jumper and the lock out period of the sensor.

Or, as could still be a possibility - I have an actual problem or fault with the sensor, which could totally screw up the program logic too.

Using your original post programs this would not be possible no matter what the sensor did. The MS sending another command could reset your program but never turn the light off before 15 minutes was expired.

OK..last time, then I give up.

Did the lights turn off at any time, in less than 15 minutes? - Respond with one of these answers only.
1) Yes
2) No
3)I do not know.

Posted
5 minutes ago, larryllix said:

Using your original post programs this would not be possible no matter what the sensor did. The MS sending another command could reset your program but never turn the light off before 15 minutes was expired.

OK..last time, then I give up.

Did the lights turn off at any time, in less than 15 minutes? - Respond with one of these answers only.
1) Yes
2) No
3)I do not know.

His problem isn't the lights turning off early. It's that they were turning off even though he was moving in front of the sensor. 

The way he wrote his program there was nothing to cause the program to re-evaluate and stop from turning off. 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37.2k
    • Total Posts
      372.5k
×
×
  • Create New...