So you’re saying that the piston fires when one of the conditions changes, then the piston looks at the two conditions, and if one condition OR the other condition is true - the piston continues… Am I on the right track?
You are correct. The trigger kicks everything off, and then the code dictates what happens next.
The tricky thing you may not have noticed is, triggers fire in both directions.
In other words, even though your code says “
is present”, your piston will run top to bottom when either sensor changes to “
present” OR “
What happens after that, depends on the rest of your code.
From a behind-the-scenes standpoint, when a piston subscribes to a Sensor’s presence, then any changes to that presence will trigger the piston. This concept carries over to all types of devices. (IE: “
IF Switch changes to on” will also run when the switch changes to off, but will skip that block, and continue on with the rest of the piston (if conditions allow it))
Unlock on arrival with redundant presence sensors and door contact
I’m going to have to think about this, I’m not sure how to go about making it work.
I also have a “leaving” piston that, when we BOTH leave, the piston does the lights/lock thing.
Now I’m wondering what actually happens when we both leave - which one fires, which one fires first, is the house locking or unlocking… LOL So confused! Not earth shattering if it is unlocked - as I know to look at my dashboard and look for a notification, etc etc, but I’d LIKE it to all work properly!
Well, for what it’s worth, I try to make sure only one of my pistons executes when a presence sensor changes. This is because each piston with a lightning bolt next to a presence sensor, will execute from top to bottom when leaving OR arriving. Having more than one piston executing at each event means a higher chance of commands getting lost in all the commotion.
Personally, I would prefer only one piston executing at such events.
This can work, but the wording has to be specific.
(since both sensors will never exit/return at the same instant)
Personally, I would try to combine all your logic that you want to happen when someone arrives or leaves into one giant piston. With only one trigger, but as many conditions beneath as you like.
For those who want to tackle this by themselves, I normally recommend clients stall a few months before coding for presence sensors, since they can be some of the trickiest coding.
In my opinion, it really helps to have a solid grasp on webCoRE’s logic before diving in to a Presence piston.
How about this, this will make your piston a bit longer but might help…
Here are possible scenearios:
a) One of you leaves everything will be same, no ACTION in the house.
b) Both of you together or seperately out. Lock the doors etc.
IF sensor 1 changes to AWAY (lets say you just left)
WAIT 5 minutes.
Check the other sensor (to see if home or not, if not)
Do this do that…
The wait is just to make sure ST HUB had enough time to register the sensors…
You can create another IF block just for the second sensor…
something like this:
Presense sensors are very tricky.
I can see that! Ok, thanks both of you. But I’m stubborn, and I want to learn, and I know the only way I’m going to learn is if I forge through it. Let me look at that example, and think this over, and come up with… Oh, something exciting! Forget cowbell, I need more bells and whistles!
I’m still looking at this - what if I split this into two separate pistons? One for me "presence is ‘present’. And then a different piston for him? If we’re both away and both come home at the same time and one piston fires a few second/minute after the other - that won’t harm anything.
OR - Could I fit both of these on the same piston? "IF “present” then “lights”. Second “IF”: If “present2” then “lights”?
Would “Changes to” work in either of these scenarios, or stick to “present”?
Huh. Ok. So what would be the actual trigger in my case?
I want action if BOTH of us leave.
I want NO action if ONE of us leaves and the other stays home.
I want action if ONE of us leaves and the other is NOT home.
I want action if either one of us or BOTH of us comes home.
I THINK I see how to create much of this - I’m not sure what the initial trigger should be.
I am about to head out the door to work, but here is what I am thinking:
IF Sensor 1 or 2's presence change to present <-- Trigger Then IF Sensor 1 or 2's presence is not present <-- Condition Then Do "Welcome Home" stuff (Keep duration short, might be two back to back) ELSE Do "Everyone Home" stuff END IF IF All of Sensor 1 & 2's presence are not present (Force subscription) Then do "Goodbye stuff" END IF
Notice how each IF block is subscribed to the exact same devices & attributes.
(so really this piston has two triggers. Sensor 1 & 2’s presence)
Also, please be careful with the ELSE. If the wording is even slightly different, it will not work as expected.
Thanks again! I’m going to try all this out. I need to run logs more. I noticed today that when we left, the house secured and stayed secured. When we came home, the house desecured (is that a word?), but then after we had been home 5 or 10 minutes… the “desecuring” happened again. Sigh. LOL I’m bound and determined to get this working!
I admire your determination, I just wish you were learning with pistons that did not involve security or presence sensors…
I understand. But I AM following up with looking at my dashboard every time, and getting alerts from a separate, non-Webcore/Smartthings source.
HEE! Ok, so I’m looking at what you replied with in that other thread - I like!
He’s got a Pixel 3, I’ve got an iPhone Xs. Both of us connect through bluetooth to both our vehicles (a Jeep and a Ram). How would this work, please?
My little trick uses Tasker, which works on Android devices. Tasker keeps track of events on the Android side, and then sends a command to execute a piston when the time is right. WebCoRE takes over from there.
(Tasker is to Android, what webCoRE is to SmartHomes… Mind-blowingly Powerful!)
COOL! Is there an iPhone equivalent? I hope?
Not that I have found. Tasker utilizes Android’s open philosophy.
(and is actually one of the reasons I will never buy an iPhone)
Ah ok gotcha. And honestly, my iPhone “presence” seems to work just fine and right away, while his Pixel 3 sometimes doesn’t register for up to 5 or 10 minutes.
Well, before investing time in extra coding, Android has some advance options for GPS (Location) that might be tweaked to give him better results… (quicker results means a bit more battery drain)
If that doesn’t help, since his phone is the flaky one, you could put Tasker on his phone, and let either:
a) Disconnect from car’s bluetooth - or
b) Is Near the Home WiFi - or
c) Connects to Home WiFi
become the trigger in Tasker, and send a command to webCoRE for snappy execution.
(If his GPS is slow, then I would probably use method (b))
So here’s what I’m going to do - I’m going to make TWO pistons. One will be for me “is present” “this happens”.
I’m still getting this piston firing when I drive away. I think this will solve it. And if we BOTH leave together, my “leaves” piston will fire and that’s it. And if we BOTH return - ONE of our pistons will fire, and then the OTHER piston will fire. Not a big deal, and if it’s annoying (not firing until after we’re home) I can always do a check on a door being locked, or light being on, or something.
The other will be for HIM “is present” “this happens”.
This will tell me for sure who’s phone is the delay. I’m fairly certain it’s his.
Should/Can I, instead of “is present” use “changes to present” in this case, since there’s only one device?