Jump to content

motion light programming for both intermittent & long acting


piconut

Recommended Posts

I'm new to ISY and Insteon and have been playing with the programming functions to try to learn them (although I'm not a programmer but I can usually muddle my way through basic If/Then statements). I have a motion sensor in the garage that turns on the inside garage light. I want the light to come on and then go off in 30 seconds when someone walks through the garage. I also want the light to stay on for 10 minutes or more when someone walks into the garage and works on a project in there.

 

From reading numerous posts on this forum by the helpful members here, I have successfully setup a simple program that can turn on the light for any chosen interval of time when the motion sensor is activated, and keeps the light on as long as the sensor still detects motion. I have set the motion sensor so that it only sends ON commands.

 

Now here is my logic for what I want but I'm not exactly sure how to program it.

 

I have created an integer variable that starts at 0 and gets ticked up +1 for each time the motion sensors sends the ON command. I'm not sure how to do it but I want to set that variable so that it gets reset to zero when the motion sensor has not sent the ON command on anything over 30 minutes. I'm trying to use the variable as an "activity" monitor. When someone just walks through once and then there is no other activity for an 30 minutes or more, then the motion sensor clicks off the light within 30 seconds because the variable is 1 or 2. But when there is a fair amount of motion within the 30 minute time frame, the variable gets increased and then this larger variable is used in a program to tell the light to stay on for a longer time, like 10 minutes after the last activity. Ideally, the larger the variable, the longer the light stays on up to a point. Like a variable of 8 within 30 minutes might make the light stay on for 5 minutes after the last motion being sensed, but a variable of 20 within 30 minutes would make the light stay on for 10 minutes past the last motion sensed. I don't want the light to stay on longer than 30 minutes after the last motion was sensed. I don't know if there is a way to do this but this is why I'm asking for help here.

 

This is my first post after several days of reading these forums and playing with basic programming. Thank you for any help that you can provide. :)

 

Thanks...

 

Scott

Link to comment

My tmptation, from a logic standpoint, would be something like:

 

If

Control motion sensor is switched on

Then

Set integer variable to integer variable +1

Wait 30 minutes

Run this program (else path)

Else

Set integer variable = 0

Link to comment

Here is what I have programmed and am currently testing.

 

I have an integer variable called gmotion_timed which starts at zero and when the motion sensor detects motion, a program adds +1 to it for each detection.

If
       Control 'Devices Garage / Motion Sensor / Garage Motion Sensor-Sensor' is switched On

Then
       $gmotion_timed += 1

Else
  - No Actions - (To add one, press 'Action')

Then I have another program called reset variable that waits for 5 minutes after the last motion is detected and then it resets the gmotion_timed variable to 0.

 

If
       Control 'Devices Garage / Motion Sensor / Garage Motion Sensor-Sensor' is switched On
   And $gmotion_timed > 0

Then
       Wait  5 minutes 
       $gmotion_timed  = 0

Else
  - No Actions - (To add one, press 'Action')

The program that actually turns on the light is this:

If
       Control 'Devices Garage / Motion Sensor / Garage Motion Sensor-Sensor' is switched On
   And $gmotion_timed <= 10

Then
       Set Scene 'Garage Motion Light' On
       Wait  2 minutes 
       Set Scene 'Garage Motion Light' Off

Else
       Set Scene 'Garage Motion Light' On
       Wait  20 minutes 
       Set Scene 'Garage Motion Light' Off

So far it seems to be working well and I'm playing with both the reset time and the length of time to wait to see what works best for being able to determine whether the light should stay on briefly, or for a long time. There is probably a better and/or more efficient way to write all of this so I'm open to suggestions.

 

What I really need now but I'm unsure how to setup is a way to log the time of each motion detection for each day (every one) and then have that emailed to me. The reason I want this is to see how frequently, on average, the motion detector gets tripped by the "just passing though" trips in the garage. I think if I had this information that I would be better able to tweak the values of my program to achieve what I want regarding the momentary and long acting lighting. I know how to do the email part but I don't know of a way to write a program that would create and log the times. Is this possible?

 

Thanks ...

 

Scott

Link to comment
so I'm open to suggestions.

 

I have already offered a suggestion. Whether or not it is better or more efficient, I will leave to you. Certainly, it is fewer lines of code.

 

What I really need now but I'm unsure how to setup is a way to log the time of each motion detection for each day (every one) and then have that emailed to me.

 

The ISY keeps a log that would provide the clues you are looking for. I don't believe, however, that there is a native way to Email this log to anyone, however.

Link to comment
so I'm open to suggestions.

 

I have already offered a suggestion. Whether or not it is better or more efficient, I will leave to you. Certainly, it is fewer lines of code.

 

 

Hi oberkc...

 

Thanks for your quick response. I should have mentioned that I tried what you suggested but it didn't work as expected and this is probably because either I wasn't clear in my expectations of how I wanted the light to work, or I wrote the program wrong (or most likely, both). I also guess I wasn't clear on what the Run this program (else path) meant. Here is are the two programs I tried originally after your first response.

 

If
       Control 'Devices Garage / Motion Sensor / Garage Motion Sensor-Sensor' is switched On

Then
       $motion_test += 1
       Wait  30 minutes 
       Run Program 'motion test light on' (Else Path)

Else
       $motion_test  = 0

 

and then the program that it runs is:

If
       Control 'Devices Garage / Motion Sensor / Garage Motion Sensor-Sensor' is switched On

Then
       Set Scene 'Garage Motion Light' On
       Wait  30 seconds
       Set Scene 'Garage Motion Light' Off

Else
       Set Scene 'Garage Motion Light' Off


 

What happened was that the light just stayed on for 30 seconds after the last motion then went off, regardless if whether someone was just passing through the motion sensor beams or if they were continually working in the area. The part that didn't work as expected was that the continual motion in the area would cause the light to stay on for at least 10 minutes after the last activity.

 

If you can give me some pointers as to where I might improve this, I would appreciate it.

 

Thanks...

 

Scott

Link to comment

My original program suggestion was in response only to the only question that I noticed:

 

"I'm not sure how to do it but I want to set that variable so that it gets reset to zero when the motion sensor has not sent the ON command on anything over 30 minutes."

 

I should have been more clear as to the request to which I was responding and the limit of scope I was offering.

 

What happened was that the light just stayed on for 30 seconds after the last motion then went off, regardless if whether someone was just passing through the motion sensor beams or if they were continually working in the area.

 

That is exactly what that program should do, unless you get another ON signal from the motion sensor within the 30-second wait period. I don't have a lot of time right now to offer deeper suggestions, but I would start by checking the configuration of your motion sensor. In it is a setting that defines how long to wait until re-enabling the sensor. If that is higher than 30 seconds, then there is no way for the sensor to send ON commands quicker than the program wait period, thus the program will always turn off the light.

 

If you don't get additional suggestions, I will be checking back and offer more.

Link to comment

I am back. With regards to your second program (the one with the 30 second wait period), I continue to suspect the problem was not a programming issue, but a motion sensor configuration issue. From the ISY, select the motion sensor in question. Select "options". You may need to now put the motion sensor in linking mode.

 

Notice there are a couple of options with regards to sensitivity and continuous ON commands. Make sure the continuous ON commands are checked, or that you select a timeout period much less than 30 seconds.

 

Note, too, that the physical jumper 5 must be set to allow for software control of the motion sensor. (This is described in the manual for the motion sensor.)

 

I also guess I wasn't clear on what the Run this program (else path) meant

 

"this program" would be whatever was the name you gave for that program itself.

 

Regardless, clearly the two programs you tried originally had no relationship to each other. One incremented and cleared the value of a variable. The other responded to a motion sensor without regards to the value of the variable. In your original post, I was under the impression that you had an idea what you wanted to do with the variable and how to do it. Your only question, I thought was simply how to clear the variable after 30 minutes. That was the question to which I was responding.

 

If you want some thoughts on how to use a variable to vary the response to the motion sensor, I may be able to offer some ideas.

Link to comment

Hi oberkc....

 

Thanks again or your quick response.

 

I am back. With regards to your second program (the one with the 30 second wait period), I continue to suspect the problem was not a programming issue, but a motion sensor configuration issue. From the ISY, select the motion sensor in question. Select "options". You may need to now put the motion sensor in linking mode.

 

Notice there are a couple of options with regards to sensitivity and continuous ON commands. Make sure the continuous ON commands are checked, or that you select a timeout period much less than 30 seconds.

 

Note, too, that the physical jumper 5 must be set to allow for software control of the motion sensor. (This is described in the manual for the motion sensor.)

 

Regarding the settings and jumpers, I have it all set correctly as you stated (I learned all that from the other helpful info found on this forum). Just to note, you cannot set the timeout to anything less than 30 seconds from the options menu (which actually shows up as 0.5 minutes). If you try to set something like 0.25 minutes, it just reverts back to the 2 minute default. So I currently have it set to 30 seconds (0.5 minutes). Also, I have the "On commands only" set which is actually unchecking the On Only Mode. I thought this was very confusing when I originally set it up but I tried various things and read more stuff here and you actually have to uncheck it to turn on the ON Only Mode. See my image of my settings below and it should be clear what I'm talking about.

 

motion_options.png

 

The three programs I have now seem to be working but I would still like to tweak it so that the number of the integer variable corresponds to the length of time the light stays on, to a point. I just can't think of how to program that. I might try to play with the programming some more to see if I can figure it out and I'm open to suggestions from you and the other experienced members here. I may not know much but at least I enjoy trying to logically solve the problem and test it, and whether I'm successful or a failure, I still learn from the experiences.

 

If you want some thoughts on how to use a variable to vary the response to the motion sensor, I may be able to offer some ideas.

 

That would be great! Thanks!

Link to comment
I would still like to tweak it so that the number of the integer variable corresponds to the length of time the light stays on, to a point.

 

This is what I assumed when I read your initial post. On the surface this seems like a good idea but in practice, not so much. Here is why:

 

Lets assume that for each count of the integer variable, you want to keep the light on for an additional 30 seconds. Your sensor is in "Sensing" mode with no timeout. This means the the sensor will continue to send "On" messages as motion is "Sensed". This can be numerous "On" events in a fairly short period of time (20 to 30 per minute depending on the activity in front of the sensor). Lets say a few people walk into the room and stay for a minute then leave, you could easily end up with a count of 30+ resulting in a delay of 15+ minutes.

 

In my opinion, the better approach is to pick a reasonable fixed delay from last sensed motion like say 2 minutes. Every time the sensor sends an "on" event, you restart the 2 minute countdown. If you are concerned about the lights turning off while the room is still occupied, there are some suggestions to aid with that. Use a Dimmer for the lights. When turning off at the timeout, use a scene with a medium ramp rate so the lights slowly fade rather than just turn off. This will give the opportunity for the occupants to move and trigger the sensor without being left in the dark. Others will send "Beep" commands to devices in the affected area before the timeout to warn of the upcoming "Off" event again giving occupants the opportunity to avoid being left in the dark.

 

Other things to consider are possibly disabling the motion programs when the light is operated manually at the switch, and re-enable the programs when the light is turned off at the local control. This way, the lights are on auto unless operated manually. This is how all of my motion controlled indoor lights are configured and my front porch and back deck as well. Easy to operate. The wife and kids don't need to think about how it works because it just does.

 

Hope this helps.

 

-Xathros

Link to comment

Other things to consider are possibly disabling the motion programs when the light is operated manually at the switch, and re-enable the programs when the light is turned off at the local control. This way, the lights are on auto unless operated manually.

-Xathros

 

Hi Xathros...

 

Could you please explain how this is done? I think your motion setup might work well for me but the only thing I might want to add is a 2 hour timeout added to the switch so that if the light is left on accidentally, the light still goes out 2 hours after the last motion sensed movement.

Link to comment

piconut-

 

The way mine work is that right before midnight, I have a program that runs and enables all of my motion programs. This way if any were left disabled, they are reset each night.

 

I have worked up a solution that should meet you specs and it looks something like this:

Program: LivingRoomMotionLightsDisable

If 
  (
  Control 'LivingRoomLight' is Switched On
  Or Control 'LivingRoomLight' is Switched Fade Up
  or Control 'LivingRoomLight' is Switched Fast On
  )
  And Status 'LivingRoomLight' is not Off

Then
  Disable Program 'LivingRoomMotionLights'
  Stop Program 'LivingRoomMotionLights'
  Wait 2 Hours
  Set 'LivingRoomLight' Off

Else
  Enable Program 'LivingRoomMotionLights'

 

This will disable the motion program when the switch is turned on manually and re enable the program when the light is turned off regardless of how it is turned off. Modify to fit your device and program names.

 

Hope this helps.

 

-Xathros

Link to comment
piconut-

 

The way mine work is that right before midnight, I have a program that runs and enables all of my motion programs. This way if any were left disabled, they are reset each night.

 

I have worked up a solution that should meet you specs and it looks something like this:

Program: LivingRoomMotionLightsDisable

If 
  (
  Control 'LivingRoomLight' is Switched On
  Or Control 'LivingRoomLight' is Switched Fade Up
  or Control 'LivingRoomLight' is Switched Fast On
  )
  And Status 'LivingRoomLight' is not Off

Then
  Disable Program 'LivingRoomMotionLights'
  Stop Program 'LivingRoomMotionLights'
  Wait 2 Hours
  Set 'LivingRoomLight' Off

Else
  Enable Program 'LivingRoomMotionLights'

 

This will disable the motion program when the switch is turned on manually and re enable the program when the light is turned off regardless of how it is turned off. Modify to fit your device and program names.

 

Hope this helps.

 

-Xathros

 

 

Thanks. It never occurred to me that I could disable a program within a program and utilize that function to make things work like you did. I appreciate your helping me to learn this stuff. I've implemented your program and am testing it now.

Link to comment

It sounds as if you are well on your way. The only thing I would offer at this point is to further refine your thought process and requirements. What do you want to happen if you turn the switch on while the light are currently OFF? Is this different than what you want to happen if you turn the switch on while the lights are currently ON? How does this affect your program?

Link to comment

Archived

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


×
×
  • Create New...