I am a newbie and haven’t used the groovy programming I am currently trying to learn though. I want to know which way i’m coming to a door using the motion sensor and the door contact switch to turn on the porch light when i’m leaving. I used one of the sample programs to turn a light on with motion and tried to add the contact switch and add some IF AND logic but I was unsuccessful. In the example they used a motionhandler EVT I tried to alter the result of the motionhandler EVT if the door was closed but that didn’t work either.
Capturing Motion and door multisensor sequence to turn a light on based on direction of travel?
Are you using WebCore? or Smart apps?
Let’s try this
on the bottom tap automation
then Smart Lighting
If you do not have it installed tap Marketplace
then tap lights & Switches
first entry should be Smart Lighting tap it
then follow the in apps steps.
Which light select then tap done in rt corner
Then select trigger
You can use a motion sensor or if you tap open/ close
then tap the door sensor
you can add more options at this time
if done continue to tap Done Or Save in the rt corner till it is saved to smartthings.
Hope this will help you
I will say this some of the Smartthings apps do not work real well so you may want to look at WebCore.
Webcore is essentially a scripting language for SmartThings, it’s likely to be your best bet anytime you want a stacked conditional.
That said, from a network engineering point of view I feel obligated to point out that SmartThings primarily uses mesh networks, Z wave and Zigbee. These do not guarantee forced sequencing. Messages can and do bounce around the network a little bit before they are delivered to the hub, which means getting very precise timing for anything under one minute is often difficult.
It is entirely possible that you might walk past the motion sensor, then open the door, but the hub might receive the “door opened” message before receiving the “motion detected” message. So this particular technology is not really a good match for trying to determine direction based on which device fires first. You can try it using web core, but it won’t be guaranteed to work every time.
See, for example, the following discussion (this is a clickable link)
So it’s not so much writing groovy that is the issue as the technology you are writing it for. Mesh networks are intended for tiny messages sent infrequently. Not for continuous command and control designs, which is usually what you are looking for when determining direction.
But you can certainly try it and see how it works for you.
Thanks but I don’t want motion or door open I want motion and door witch smart lights does not give you an AND option.
Thanks JD Good info. I will just have to have motion sensors on both sides of the door and use them to trigger the lights
@JDRoberts I’m curious if the best solution in this case might be to “trick” Zone Motion Manager into using the door contact sensor as a second motion sensor in a “Triggered Activation” scheme, instead of doing this completely with CoRE/WebCoRE.
For example, if you created a virtual motion sensor device and tied its active/inactive state to the open/closed state of a physical contact sensor (via CoRE or Smart Lighting or what-have-you), Zone Motion Manager could utilize this new virtual device perfectly. Now, the hallway motion sensor is the “trigger” and the virtual motion sensor can trigger the “going out the door” zone only when the door is opened within 15…30…60 seconds of the hallway motion event.
To me, this seems simpler (and more re-usable) than building a multiple-sequenced-events time-window trigger in WebCoRE, but I’m not that familiar with building more complex patterns in WebCoRE.
I wish I could just extend the basic contact sensor DTH with a virtual motion capability, but then they would lose offline operation. Bah.
- it’s easy to have a contact sensor report as a motion sensor, or vice versa… You just use Mike’s universal device type handler. So you can definitely have a zone for zone manager that includes some contact sensors and some motion sensors. Quite a few people are doing that.
- however, doing that doesn’t address the basic problem of the OP, which is trying to determine whether someone is walking into the house or out of the house based on which device fired first. Because in a mesh network, there’s no guarantee that the message from one device will arrive before the message from the other if they are very close together.
About two years ago, before Core or web core existed, I solved a somewhat similar problem at my own house by using two devices plus mode to identify whether I was arriving or leaving. But my devices included one presence device, so the approach was different than just A fires and then B.
- with regard to your comments about local processing, at the current time the only code that can run locally is the official smartlights feature and a little bit of smart home monitor, plus a specific set of device type handlers provided via SmartThings. Core doesn’t run locally, zone manager doesn’t run locally, virtual devices generally don’t run locally… even routines don’t run locally. So I don’t think there’s any way to address the problem this thread is about and keep all operations local.
The solution here is using a variable in webCoRE
X^2 Define Variable
motion1first (Boolean)<----This will give you a quick and easy way of saying which one was triggered first
Motion 1 changes to Active
Motion 2 is Inactive
Using Variable motion1first=True
Motion 2 changes to Active
Motion 1 is Inactive
Using Variable motion1first=False
Any of Motion 1 or motion 2 changes
All of Motion 1 and Motion 2 are inactive
Using Variable motion1first=false
Any of Motion 1 or Motion 2 changes
All of Motion 1 and Motion 2 are Active
Variable motion1first is True
Do whatever when coming from Motion 1 direction
Any of Motion 1 or Motion 2 changes
All of Motion 1 and Motion 2 are Active
Variable motion1first is False
Do whatever when coming from Motion 2 direction
That piston is definitely worth trying, but it can’t overcome the lack of forced sequencing in a mesh topology. As long as the hub receives the reports in the desired sequence, the piston will work. But if one of the messages happens to bounce around the mesh a bit and they arrive out of sequence, the piston will fail.
So a lot is going to depend on the exact devices chosen, their “sleepy” settings, and their physical locations relative to each other and to any nearby repeaters. It may work, it may work most of the time, or it may just fail unpredictably depending on network traffic.
The option to use in either CoRE or webCoRE is the “followed by” grouping method (as opposed to and or or). This allows detection of sequences, so he could detect sequences both ways - webCoRE has much more comprehensive support for sequences, including max time between events in the sequence or detecting the lack of an event as a step in the sequence.
But mesh networks may interfere with the sequence if the two events are too close to each other. In practice, if there is at least 1s distance between the two events, the correct event order is presented in most cases.
Hi ady, I made a piston using followed by for 2 motion sensor to tell the direction of travel.
but there is a some problem.
Motion 1 and 7 is IN direction.
Motion 2 and 8 is out direction.
if IN and OUT motion is triggered within 30 seconds, it worked perfectly. on both direction.
but if only one motion is triggered, eg IN is triggered and stay triggered, and 30 seconds later, without any other motion triggered, it will execute the IN direction, vice versa.
so I think is the follow by problem,
please help, thank you
Here is the detail of the problem!