Jump to content

Room motion program logic?


sn0cr4sh

Recommended Posts

Posted
13 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.

 

The answer to your specific question is of course #3.  If I am in a kitchen for 4 hours moving around with only those two programs running, and the lights are randomly turning off while I am in the room, I don't know where exactly I am in the 15 min countdown cycle.  

"Did they turn off in less than 15 minutes?" -> From when?

Posted
8 minutes ago, sn0cr4sh said:
 

The answer to your specific question is of course #3.  If I am in a kitchen for 4 hours moving around with only those two programs running, and the lights are randomly turning off while I am in the room, I don't know where exactly I am in the 15 min countdown cycle.  

"Did they turn off in less than 15 minutes?" -> From when?

LOL. OK then I assume your lights are staying on for the 15 minutes wait time, each time but your program is not getting triggered again from motion. Your MS must be getting it's ISY status reset each night at the 3:00 AM all device query and it is cocked to trigger your status line again...once.
I only have Insteon MSes and do not know what your units actually put out but my MS statuses are always on and using status would never work. Just change your trigger line to:
 

MS control is switched On.

This would cause further motion detections to retrigger the program evaluation and start the Wait 15 minutes over each time. (providing Zwave MSes have the control switched construct).

Posted
2 hours ago, sn0cr4sh said:

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?

Not quite. ISY is a trigger based engine/evaluation. 
A program logic is only evaluated if a trigger line is activated. This starts with a remote device, say an MS sending a command. Then ISY evaluates every program If section containing mention of that triggering device. If the whole If section logic evaluates to True, Then starts to run. If the whole If section logic evaluates to False, Else starts to run.

While Then or Else is running, it will run to completion, unless a Wait or Repeat line is incurred. This is like a voluntary time slice surrender to the O/S allowing ISY to process something else, or another trigger. If the same program logic gets evaluated the Then or Else section will be interrupted and Then or Else will start again.

Therefore this compound trigger logic can never be True
If
     SwitchLinc control is switched ON
     AND
    SwitchLinc control is switched OFF
Then
…….

The ISY trigger based engine can only be evaluated the program logic due to ONE event and the other trigger will be false during that evaluation.

Note there is an "enable" box with each program. This can disable any programs triggers and allow it to be used as a non-triggered sub-routine. This is useful when random triggers could cause unwanted interruption of a process. This is frequent when a program operates the same device used as a trigger, and possibly creating oscillation.

Posted
6 hours ago, Mecheng70 said:

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. 

I don't think it was already suggested.  This, to me, seems to add complication where none is needed.  But, if one's mind grasps the concepts better with variables involved, great.

Posted
10 hours ago, Mecheng70 said:

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.  

...in addition to oberkc above....
We are  of some opposing opinion on the usage of variables, usually. However, for a simple case like this I wouldn't bother wasting a variable spot. Where I do use variables for lighting, is when various levels of scenes are involved. These scenes may be Insteon scenes per se, or they may be programmed combination scenes using multiple technologies. The control variable would then be say 0 for Off, 1 for very low level movie watching, 2 for dim room lights, 3 for medium brightness, 21 for multi-coloured party lighting, 22 for Halloween colours, 24 for Christmas colours etc. Of course none of these numbers are ever used/seen in programs, as I define a bank of Integer variables containing these constants, that never change.

eg:
   set $sGathRm.mode = $cMODE.XMAS   <--------- I don't know or care what number this represents now

If
        $sGathRm.mode is $cMODE.XMAS

As oberkc  posted above, this technique is far to complex for a simple example of the MS/Light control being discussed in this thread. It would take many more code lines and programs.

  • 3 weeks later...
Posted

Not sure if you are still looking for code to keep the lights on while there is motion in the room, and then keep them on for 15 minutes after motion is no longer detected. Here is the program that I use with the Insteon Motion Sensor 2844-222. Change the 2 minutes in the Else part of program 3 to 15 minutes to meet your needs. If you delete the 2 minutes (added for your test), the room light will only stay on as long as there is motion... actually the lights will stay on only as long as the motion timer stills shows the sensor status as "On". With Insteon that is 30 seconds after the last motion was detected. While emptying the clothes dryer, the light stays on, and when we leave the room with a basket full of clothes we do not have to hit the light switch to turn off the utility room light.

I tried to program it in 2 programs, but for some reason it did not work properly. I used the 8 seconds to offset the Motion Sensor timer and the program's wait timer, which originally caused me some issues. I know that program 3 shows go to Pgm 2 (If), should be Then, but will change that next time.

Lights - UtilityRoomPgm 1 - [ID 001E][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' Status is On
 
Then
        Run Program 'Lights - UtilityRoomPgm 2' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 
Lights - UtilityRoomPgm 2 - [ID 001F][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Set 'Lights - UtilityRoom' On
        Wait  1 minute and 8 seconds
        Run Program 'Lights - UtilityRoomPgm 3' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 

Lights - UtilityRoomPgm 3 - [ID 0023][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' Status is On
 
Then
        Run Program 'Lights - UtilityRoomPgm 2' (If)
 
Else
        Wait  2 minutes and 8 seconds
        Set 'Lights - UtilityRoom' Off
 

 

Posted
1 hour ago, Mustang65 said:

Not sure if you are still looking for code to keep the lights on while there is motion in the room, and then keep them on for 15 minutes after motion is no longer detected. Here is the program that I use with the Insteon Motion Sensor 2844-222. Change the 2 minutes in the Else part of program 3 to 15 minutes to meet your needs. If you delete the 2 minutes (added for your test), the room light will only stay on as long as there is motion... actually the lights will stay on only as long as the motion timer stills shows the sensor status as "On". With Insteon that is 30 seconds after the last motion was detected. While emptying the clothes dryer, the light stays on, and when we leave the room with a basket full of clothes we do not have to hit the light switch to turn off the utility room light.

I tried to program it in 2 programs, but for some reason it did not work properly. I used the 8 seconds to offset the Motion Sensor timer and the program's wait timer, which originally caused me some issues. I know that program 3 shows go to Pgm 2 (If), should be Then, but will change that next time.


Lights - UtilityRoomPgm 1 - [ID 001E][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' Status is On
 
Then
        Run Program 'Lights - UtilityRoomPgm 2' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

Lights - UtilityRoomPgm 2 - [ID 001F][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Set 'Lights - UtilityRoom' On
        Wait  1 minute and 8 seconds
        Run Program 'Lights - UtilityRoomPgm 3' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 


Lights - UtilityRoomPgm 3 - [ID 0023][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' Status is On
 
Then
        Run Program 'Lights - UtilityRoomPgm 2' (If)
 
Else
        Wait  2 minutes and 8 seconds
        Set 'Lights - UtilityRoom' Off
 

 

 

 

That can all be combined into one simple program. Most disable the MS Off transmission in the MS. The program off timer is retriggerable by ISY nature.. Note use of "switched"

Lights - UtilityRoomPgm 1 - [ID 001E][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' is switched On
 
Then
        Set 'Lights - UtilityRoom' On
        Wait  5 minutes
        Set 'Lights - UtilityRoom' Off
Else
   - No Actions - (To add one, press 'Action')
 
Posted
8 hours ago, larryllix said:

 

 

That can all be combined into one simple program. Most disable the MS Off transmission in the MS. The program off timer is retriggerable by ISY nature.. Note use of "switched"


Lights - UtilityRoomPgm 1 - [ID 001E][Parent 0001]

If
        'MotionSensor - UtilityRoom-Se' is switched On
 
Then
        Set 'Lights - UtilityRoom' On
        Wait  5 minutes
        Set 'Lights - UtilityRoom' Off
Else
   - No Actions - (To add one, press 'Action')
 

I will try it, but the way I read your code, this will only set the timer for 5 minutes and is not monitoring motion while I am in the utility room. Based on the code if I am in the Utility Room for more than 5 minutes the light will turn off.  I originally tried "Control" , but that did not work in my code. When I used "Status" it worked fine. Will give your code a try today. 

Posted
2 minutes ago, Mustang65 said:

not monitoring motion while I am in the utility room

No, this is not true.  The motion sensor will send an ON command each time (past the time-out period) it senses motion.  So long that motion is sensed more frequently than 5 minutes (in this case), the program will trigger and restart the countdown.  

Posted
25 minutes ago, Mustang65 said:

I will try it, but the way I read your code, this will only set the timer for 5 minutes and is not monitoring motion while I am in the utility room. Based on the code if I am in the Utility Room for more than 5 minutes the light will turn off.  I originally tried "Control" , but that did not work in my code. When I used "Status" it worked fine. Will give your code a try today. 

I have ten original  Insteon MS  units in use. The status of them never changes, as I have the off command disabled by software options set in the admin console. They show permanently 'On' and using status would never trigger any programs.

Posted

I had a few minutes between some major projects here and I figured I would try your working solution. I selected the motion sensor and options and the results are in the below pictures. It should be an interesting night.

 

Sensor - Options error1 -.jpg

Sensor - Options error2.jpg

Posted

Given that the motion sensor is a battery device, I wonder if you need to put it into linking mode (wake it by providing motion to sense) in order to write changes.

Posted
1 hour ago, Mustang65 said:

Thanks

Tried that with no luck. I will do a factory reset tomorrow morning to see if that does anything.

When testing an original MS, after going back into normal mode, double clicking on the linking button will alternate sending an On and then an Off command to ISY.

Fast clicking the MS linking button seven times will force the MS to send it's dark detection status, without the usual 5 minute sensing delay. Hold it under a desk well, and well covered up to test the dark status send. You can watch all this on the MS device pages in the admin console.

Posted

After resetting all the sensors to factory defaults (like 4+ times), increasing/decreasing the distance between sensors I was setting up and the PLM, the sensors finally accepted the ON only option without those error messages. The common thing that I did notice, which probably is nothing, is that when I selected 2844-222 from the sensor drop down list, and clicked on the start button, the sensor type changed to 2842-222 and continued with the install. Anyway they work with your one program code.

Thanks

Posted

Check your "write to battery devices" option. There are two battery device option icons at the top of the admin console that are involved.

Posted

 

30 minutes ago, Mustang65 said:

The common thing that I did notice, which probably is nothing, is that when I selected 2844-222 from the sensor drop down list, and clicked on the start button, the sensor type changed to 2842-222 and continued with the install.

I cannot say for certain, but that sounds like mine.  I suspect it has something to do with the fact that smartphone apparently did not share data with UDI about the new motion sensor.

  • 2 weeks later...
Posted

As mentioned above, I was having issues with programming the sensors with the "On" only to send command. Well, after 3 bottles of wine (only kidding as I do not drink.... yet) and after installing my backup PLM, still was not working. So I decided to reinstall ISY using a backup (fortunately, it was a month old) and re did all the added modules... switches (did a new backup). Everything works fine, ... and the PLM was not bad. I was able to program the motion sensors with no errors, but there was still issues with constant motion not being recognized, so after MANY rewrites I came up with the following code and it works as designed. Turns off and stays on if there is motion. Tried it in 2 programs with no luck. So 3 it is. Still messing around with the code in a test program. Used the HalfBath this time as it is closer than the UtilityRoom

Working code:

Lights - HalfBathPgm 1 - [ID 0004][Parent 0001]

If
        'MotionSensor - HalfBath-Senso' is switched On
    And 'Lights - HalfBath' is not switched On
 
Then
        Set 'Lights - HalfBath' On
        Run Program 'Lights - HalfBathPgm 2' (Then Path)
 
Else
        Set 'Lights - HalfBath' Off
 
Lights - HalfBathPgm 2 - [ID 0019][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Set 'Lights - HalfBath' On
        Wait  1 minute 
        Run Program 'Lights - HalfBathPgm 3' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 
Lights - HalfBathPgm 3 - [ID 001A][Parent 0001]

If
        'MotionSensor - HalfBath-Senso' is switched On
 
Then
        Run Program 'Lights - HalfBathPgm 2' (Then Path)
 
Else
        Set 'Lights - HalfBath' Off
 

 

Posted

Would there be a way to peel off the Insteon logic discussions from this one?  I wanted to focus specifically on Zwave sensors and their programming logic.  I don’t think the things you can do with Insteon sensors apply to Zwave sensors does it?

Posted

You can't have two lines containing switched logic that depend on each other. (ANDed)
They can never be true at the same time

Sent using Tapatalk

Posted
2 hours ago, larryllix said:

You can't have two lines containing switched logic that depend on each other. (ANDed)
They can never be true at the same time

Sent using Tapatalk
 

@Mustang65 I think you meant "status is not on".  

You can combine things like

lights a is switched on 

and

light a is not switched off

That causes a "True" with every on press of the paddle, and a "False" with every off press. 

Archived

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

×
×
  • Create New...