Jump to content

Writing Script for a motion sensor


mikebreece

Recommended Posts

Posted

Hey Guys, I have had several Insteon modules installed for a couple of years now, and I have simple timers programmed with several modules and all work great. Recently I wanted to add a motion sensor to my Master Bath and I am having a hard time getting the script correct. I would like the motion sensor only turn the master Bath light on from 12:01am-5:30am and I would like it to come on at 30% and stay on for 15 minutes, then turn off. I have tried several different ways to program with no luck, so I thought I would turn to the experts here on this Forum and ask for some input.

 

Thanks in advance.

Mike Breece

Posted

There is a discussion in the wiki about the use of motions sensors in the bath:

 

http://www.universal-devices.com/mwiki/index.php?title=ISY-99i/ISY-26_INSTEON:Using_Motion_Sensors_in_Bathrooms

 

There are also several posts about motion sensor programming in the forums. Here are a few examples to look at if you have not already.

 

http://forum.universal-devices.com/viewtopic.php?t=5154&highlight=motion+sensor

 

http://forum.universal-devices.com/viewtopic.php?t=4215&postdays=0&postorder=asc&highlight=motion+sensors&start=30

 

http://forum.universal-devices.com/viewtopic.php?t=5204&highlight=motion+sensors

 

Your stated requirements are pretty straight-forward, but there are typically complications that arise after further thought. For example, do you want the motion program disabled if you manually turn on the switch?

 

The general approach that I use is as follows (two programs):

 

Motion Program:

if
time is from 0001 
to 0530 (same day)
and control motion sensor turned on
then
run timer program (then path)
else

Timer Program:

if
then
set bathroom light on 
wait 15 minutes
set bathroom light off
else

Perhaps if you posted your latest program, it would be nothing more than a simple tweak to get it working.

Posted

Thanks oberkc for your fast reply. I apologize for just now getting back with you but I appreciate the reply and I am going to give it a shot. For now I am just going to forget about the 15 minute timer and just get my motion sensor working.

 

Here is what I have written at this point:

 

If

Time is 12:01AM

And from 5:45 AM (same day)

 

And Control Master Bath Motion Sensor-Sen

is switched On

 

Then

Set 'Master Bathroom Main 30%

 

Else

 

This is what I am going to try tonight.

Thanks for your help,

Mike B

Posted

Well I tried the latest script that I posted and the motion sensor will flash red but it doesn't turn on the light at any level. So I added this motion sensor to my console when I installed it, but I didn't link it to any individual light switch. Do I have to manually link it or should the program you suggested do that for me. One other thing that I should mention, in trying to get the sensor to bring the light on to 30%, now when I go to turn the light on locally, it only comes on to 30% until you press it the second time even though I have the On Level set to 100% in my console.

 

Any thoughts.

thanks,

Mike

Posted

Mikebreece

 

Did not know what this means …

 

“So I added this motion sensor to my console when I installed itâ€

 

When the Motion Sensor is added to the ISY the links necessary for the motion sensor to communicate with the ISY when motion is detected are automatically created. No additional Scenes are necessary. The motion sensor must be in linking mode when added to the ISY.

 

If you invoke Tools | Diagnostics | Event Viewer and select Device communications events the motion sensor message indicating motion sensed will be traced in the Event Viewer. If the motion sensor messages are in the Event Viewer then the Program is in question. If Insteon messages are not seen in the Event Viewer window when the motion sensor indicates motion (LED blinks Red) then the motion sensor was likely not in linking mode when added to the ISY. Do you see a Green Icon to the left of the motion sensor nodes under My Lighting?

Posted

LeeG

 

I added the motion sensor to the ISY by clicking Link Management, add sensor to EZSnSRF put the address in and then in showed up in my ISY. Yes it has a green icon to the left with a point on the right of the icon.

 

Does this help any.

 

Thanks for your time.

Mike B

Posted

mikebreece

 

That little Green Icon indicates the ISY has pending changes for the motion sensor. Put the motion sensor into linking mode by pressing the Set button for 4 seconds. You now have approx 4 minutes to right click on the motion sensor node and select Write Updates to Device.

 

Was the mention of the EZSnsRF a finger check? That is a Simplehomenet device for receiving Dakota Alert wireless RF messages. It is not related to the Smarthome Motion Sensor.

 

Lee

Posted

Lee,

 

You were right. I had tried to add the motion sensor to my console by using the EZSnRF instead of add New Insteon Device, not sure why I did that to be honest. Anyway I deleted the module from my console, reinstalled it the correct way, put it in linking mode and right clicked and selected Write updates. It seemed to all be successful and all 3 nodes on the motion sensor now have 3 red curvy lines. It still will not execute my program that I have listed.

If

Time is 12:01am

and from 12:02am

to 5:45am(same day)

and Control Master Bath Motion Sensor is switched On

 

Then

Set Master Bathroom Main 30%

 

Else

 

Any thoughts.

Thanks for you help so far.

Mike

Posted

mikebreece

 

The Program can run only at 12:01am with the first IF condition specified which is not what you want. Plus that is Anded with a window of time 12:02am thru 5:45am which means it will never run because 12:01am does not fall within the 12:02am thru 5:45am window of time.

 

First, does the Motion Sensor Sensor node show On and Off status as motion is detected and the timeout interval expires. Default timeout value is 30 seconds. If the Sensor node is changing from On to Off to On to Off then the motion sensor is telling the ISY about motion and you can rework the If condition.

 

Lee

Posted

Yes the sensor node is changing from Off to On when I test the motion sensor so I think the sensor is working properly and my console recognizes it working properly.

So how should I reword my script in your opinion.

 

Thanks,

Mike B

Posted

mikebreece

 

First, remove the If 12:01am. I don't think you want the motion sensor to trigger the Program only if motion is detected at 12:01 am. From there it depends on what you are trying to accomplish.

 

With the remaining If statements the motion sensor will turn On the Master Bath Main to 30 % between 12:02am and 5:45am when motion is detected.

 

If that is not what you want, what are you trying to accomplish with the Program?

 

EDIT: perhaps this will help. When you AND If conditions, all the conditions must be True for the Then clause to run. Should the Then clause run under multiple conditions, those should be ORed together. If A OR B OR C would run the Then If A is True or B is True or C is True. If A AND B AND C would run the Then if A is True and B is True and C is True. All three conditions must be True for the Then clause to run.

 

Lee

Posted

LeeG

 

I apologize for not stating what I was trying to accomplish in the earlier messages. Yes I just want the Motion Sensor to turn the Master Bath light on to 30% between the hours of 12:01-5:45am. That seems to be working now so I think I can stop with what I have in my program at this point.

 

I commend you on your willingness to help people. Hopefully one day I will know this system enough to return the favor to someone else.

 

Cheers my friend,

Mike B

Posted
I apologize for not stating what I was trying to accomplish in the earlier messages.

This is, in my experience, the hardest part, and the part that pays the greatest dividends. Few put enough thought into understanding their requirements.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...