LinuxMCE Forums

General => Users => Topic started by: jeangot on November 05, 2008, 07:32:16 AM

Title: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 05, 2008, 07:32:16 AM
Hello,

I'm trying to do something fairly simple, which is to use my X10 motion detectors outside to turn on a light nearby for a few minutes each time there is movement, then turn the light off. I wasn't able to find out specific hints about this in the wiki or forums, which probably only means that I didn't search properly :-)

I have my motion detector configured according to very handy infos from the wiki, and it's properly firing movement alarms. Next I created an event to turn on my light each time there is movement at this particular detector, which works fine as well.

The problem now is: how do I turn the light off? I did set the movement alarm's duration via the web admin to a few seconds (for test), but nothing happens after the alarm is over. I created an event to turn the light off on "security breach reset" but that doesnt work either (and even if it did, that's probably the wrong way since I want to have several of these motion detectors all around the house and don't an alarm reset to turn off all the lights in the house).

So can anyone hint at the proper way to either turn on a light for a set amount of time, or turn off the light a certain time after the movement event?

Thanks.

Jean
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: freymann on November 05, 2008, 02:09:29 PM
I was thinking of getting a couple of these:

X10 EagleEye Motion Sensor (MS14A)

http://cgi.ebay.ca/MS14A-l-X10-Automation-Compact-EagleEye-Motion-Sensor_W0QQitemZ140271764882QQihZ004QQcategoryZ50585QQtcZphotoQQcmdZViewItem

These units seem to take care of the on and off commands on their own without the need of programming anything in LMCE.

I have a X10 2-Way Transceiver Module (RR501) that I believe will pass on the commands to the house.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: tschak909 on November 05, 2008, 03:43:36 PM
Please keep in mind, that X-10 devices are not bi-directional, so LinuxMCE does not know anything of whether the device is on or off.

Guys, if you can, please go Z-Wave, you'll be a lot better off.

-Thom
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: freymann on November 05, 2008, 03:54:52 PM
Quote from: tschak909 on November 05, 2008, 03:43:36 PM
Please keep in mind, that X-10 devices are not bi-directional, so LinuxMCE does not know anything of whether the device is on or off.

Guys, if you can, please go Z-Wave, you'll be a lot better off.

Yes, that is true.

Unfortunately, the price of Z-Wave makes playing with X10 more affordable. I think I have under $100 invested in my X10 equipment and it's doing a decent job, at least for now.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 05, 2008, 05:13:10 PM
The motion detectors I use can also turn the lights on and off after a delay (which is what I was doing successfully until now), however the idea is to have LMCE handle this so that LMCE is aware of movement and I can make the lights conditional upon house mode an various other things.
I do know that X10 has its limits, but this should nevertheless be a very easy exercice for LME. any ideas anyone?

Jean
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 07, 2008, 05:40:37 PM
No ideas anyone on how to turn on a light for a fixed amount of time?
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 07, 2008, 07:26:19 PM
I'll give this a try when I get a few moments free (i'm at work right now, and have almost been living here for a while now), but if I remember correctly, the motion detector device template is a security interface type only, and therefore it won't work for the purpose you want it to.

The good news that you can make a new device template that uses either Lighting or Specialized interfaces - this will ensure that lighting_plugin receives the event from the motion detector, after which you can deal with it as you want.

Aside from that, once you capture the event, just send an On command to the light you want to, followed by a DCERouter delay command, followed by an Off command to the same light.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 09, 2008, 07:08:07 AM
Jon,

thanks for jumping in. I am actually getting the light to turn on, no problem, using the Motion Detector template and "Respond to Events" for Motion. My only problem was to turn it back off after a delay. With the DCE Delay command that you recommend followed by "off" it should do it. Will try it out tomorrow. Thanks a lot! Little by little, my system is getting to where it needs to be...

Jean
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 09, 2008, 01:40:25 PM
A couple points to mention:

The DCERouter Delay command - the time command parameter is in minutes

Regarding the motion detected event - I thought that I had tried this in the past, and it would only work in certain security modes, but it has been so long that I honestly don't remember..  If you could, once you do your setup - can you test it out while in all different house security modes (Secure, Away, Entertaining, etc)...? For some reason I think the last time I tried this, it would not work in certain modes.. Then again, I may have been trying to respond to a security event... Either way, good luck - I look forward to seeing how this works out for you.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 10, 2008, 07:03:02 AM
Jon,

it seems to work fine for me. You;re right that by default the motion sensors won't fire events in all house modes. To change this, I went in the web admin under Security / Active Sensors and there you can decide for each motion sensor, in which house modes you want it to fire events. This is very handy, for example if you have outside sensors that you want to turn on lights all the time (like me) but also inside sensors that should only fire events when you're not home.

If you ever try this again and it doesn't work let me know, I'll be glad to try and help.

Jean
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: asplodzor on November 10, 2008, 07:49:13 AM
In an ideal world, not only should a motion sensor turn on a light and turn it back off again after a set amount of time, it should queue it's status so that if it keeps getting tripped, it will reset the off timer. I have been hoping to set this exact type of scenario up, but for a long hallway inside with a motion sensor at either end (it's so long, I might use three...) If I were to use the X10 Eagle Eye, I would only have to set them all to the same code and linuxmce would think that they are one unit.

This brings up a side matter... has anyone gotten linuxmce to respond to X10 signals yet? I've only even been able to transmit them.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: superfro on November 10, 2008, 05:34:48 PM
You guys mind adding this one to the wiki with better instructions / screenshots ?(custom device template, respond to events.... DCERouter Delay command...)

Once hari is finished helping me add support for these HSM100's (z-wave) sensors I'll be trying to do the same thing, and I'm sure others find this info useful as well.... Motion, turn light on, turn light off after a x minute delay.... maybe even advanced config /caveat's with house security modes, or time of day (or luminosity since the hsm100's report light level when support has been added).

Much appreciated.

Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: hari on November 10, 2008, 06:32:09 PM
i now know all needed pieces for the HSM readout, but to add the needed bits in a clean way I need to rework the code a bit and add special device templates.

best regards,
Hari
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 10, 2008, 07:06:43 PM
Jeangot:

I just gave this a try again with the same results as before.. We must be doing something differently. Since you have gotten this working as expected, lets see if I can reproduce it..

1) In Respond to Events, are you responding to the "Movement is Detected" event or the "Sensor is Tripped" event?
2) In Security->Active Sensors, are you selecting "Movement" or "Announcement" from the drop-downs?


If you could, please post your steps including the type of details listed above. It would be excellent for a wiki entry.

thanks

Jon
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 11, 2008, 12:29:00 AM
I had a couple of hours to mess around today before coming to work for the night...  I tried Announcement mode out today(under Security->Active Sensors). When anything would trip one of my X10 Eagle Eye motion detectors, a text popup would appear on the orbiters saying that movement was detected on the stairway.. Pretty cool.

I'm off for a week starting tomorrow, so I'm going  to be messing with this over the week. I also want to see what it takes to receive x10 commands. One could use a wireless X10 remote for example then to pause or play a movie, or anything else you could come up with.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 11, 2008, 04:05:50 AM
Having a slow night at work so I checked out the CM11A source which I haven't messed with for a while. A few points to note after reviewing the source again:

1) Security devices emitting X10 codes will fire a Sensor Tripped event. I'm now wondering if in the future I should chane it to a Movement Detected event. Anyone have an opinion on this?

2) Events are fired if a light transitions between On/Off and when any Dimms are triggered by an X10 command. However, the On/Off events are used when the lights are turned on or off, and the State Changed event is used on bright/dim commands. I'm wondering if a better implementation would be to use the State Changed event for On/Off transitions as well as the dims. I'll have to talk to Hari and Ddamron and see how they are doing it in ZWave/Insteon so that we match. Again, suggestions are welcome.

3) Regarding "Capturing" X10 events. Currently the CM11A driver disregards any received command if there is not a configured Security or Lighting device using the House/Unit code. This currently prevents us from using X10 remotes for other purposes. However, I will be adding in changes that will allow this kind of behavior. We just have to decide what event to attatch it to. So far I'm leaning towards a State Changed event fired directly from the CM11A (the CM11A being the emitter of the event). Suggestions?

4) Climate devices are currently disregarded, but will also be added.

I will be working on these over the next week so anyone with some input, please leave it and I will do my best to further improve the X10 support.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on November 11, 2008, 07:33:47 AM
Jon,

I guess I was very lucky if it only works one way and I found that way by chance! (For once it seemed to me like something works out of the box :-)

So first I followed these excellent instructions:
http://wiki.linuxmce.com/index.php/X10
and setup the motion detector with EK_AlertType set to 4 (for motion events)

Then in Security->Active Sensors, I set the sensor to "movement" for all house modes (so that I don't have a problem with house modes initially. I can always restrict that later on.)

Then in Events, I respond to the Event "Movement is detected" (And not "sensor is tripped", which probably makes a difference). I turn on the light, then add a DCE Delay command (value in minutes as you pointed out), and then an off command.

Is this how you have it?

To answer asplodzor, I did actually find how to reset the Delay on further movement after reading through some threads on the forum.
It's not very user friendly though. I have to look at the table EventHandler in the database pluto_main. There I find the record corresponding to the event I'm building for this motion detector, and find its FK_CommandGroup value.
Then at the beginning of the list of commands in my Event (meaning before the on/delay/off sequence) I add the command DCE->Stop Pending COmmand group and put the PK_COmmandGroup value there in field 28.
So basically whenever this detector is triggered, it first stops any other command sequence from this same event (which if it was pending, would be waiting for "Delay"), so that sequence never gets to turning the light off, until my newest sequence does so (if not killed by a following sequence and so on).
It seems to work (although I only tested it once since it was freezing outside). There might be a way to identify the command group by its description rather than by its ID, but I have not tried that.

Notification was what I was going to try next. Does anyone have an idea how this event can trigger Orbiters in the house to show me a camera that's next to this motion detector?
It seems very easy to set up this kind of notification on the symbian mobile phone orbiter, but I didn't find how to do it easily for the orbiters inside my house? This would be usefull also for a motion detector at the front door for example, so that my TV would pause and show me the video when someone approaches the front door (which I always thought was a basic feature of LMCE).

Jon: when I come back from vacations (in Australia :-) I want to try and create a template for my Rain8 X10 based irrigation controller. Looks like you;re the right person to ask if I need help?

Jean

Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jondecker76 on November 11, 2008, 08:04:17 AM
jeangot:

I'll help you with any X10 stuff I can. I do most of the X10 source maintaining, bugfixes and upgrades, plus my house is crammed full of X10 stuff (over 100 devices) - some of which I still need to learn how to properly use and/or implement features to the CM11A driver for. So any help and additional testing I get here from the community only helps me to find and fix more bugs and add more features.

Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: secs on December 03, 2008, 05:18:34 AM
I too am very intersted in this. I have a camera set up overlooking my workshop. I want to activate a device (X10 Appliance plug in) when ever there is movement in that area and idealy when there has been none for 15 minutes, turn the lights off.

I think I have tried most bits and pieces but cannot get it to work.

My X10 is working great. I can turn it off and on with the TEST. I have also added this to Wake House and House Sleep mode and it turns on and off

So under my Wizard Reaction to sensors I have my Camera Showing up and I have

Monitor Mode ticked
All N boxes ticked
and in every mode I have movent selected.

If I check the Alerts Log, I have a list of images of each time I walked in front of the camera.


I have tried adding an event, security sceneriou and I have confused myself.

Can someone point me in the right direction please?
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: bulek on December 03, 2008, 08:55:56 AM
Quote from: jeangot on November 11, 2008, 07:33:47 AM
...

Notification was what I was going to try next. Does anyone have an idea how this event can trigger Orbiters in the house to show me a camera that's next to this motion detector?
It seems very easy to set up this kind of notification on the symbian mobile phone orbiter, but I didn't find how to do it easily for the orbiters inside my house? This would be usefull also for a motion detector at the front door for example, so that my TV would pause and show me the video when someone approaches the front door (which I always thought was a basic feature of LMCE).

Jon: when I come back from vacations (in Australia :-) I want to try and create a template for my Rain8 X10 based irrigation controller. Looks like you;re the right person to ask if I need help?

Jean


Try to do it from Orbiter (going into screen with camera), see what command gets fired in logs and then use the same from event handler....

HTH,

regards,

Bulek.
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: jeangot on December 05, 2008, 07:48:08 AM
Bulek,

thanks, yes I will do that. Will report if it works. I could event play a beep (saw a command somewhere to do that), then after a certain Delay I could unpause the media and revert to media playing or something like that. Will report if I get any luck.

Jean
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: golgoj4 on December 08, 2008, 05:29:15 AM
Ok, i for some reason cant get this setup properly. I think i will try and delete my cm11 and try again because it isnt seeing anything at all, which i dont get at all.  :-[
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: joerod on June 25, 2011, 06:08:21 AM
Is there any update to this?  I tried getting up to the part where it would turn on a light and  can't seem to get it to work.  Any updates or is this out of date..
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: seth on August 08, 2011, 06:07:46 PM
I wiki'd this a while back, when I was still using X10.

see my post here : http://wiki.linuxmce.org/index.php/Using_Respond_To_Events (http://wiki.linuxmce.org/index.php/Using_Respond_To_Events)

This worked well for me at the time. I have since switched to Zwave. But the instructions should get you what you want.

Best Regards,

Seth
Title: Re: How to have a motion detector turn on a light for a few minutes, then off
Post by: Techstyle on August 08, 2011, 08:02:35 PM
Seth,

I used your page and it worked fine for me although I think the 'Delay' is in Seconds

Techstyle