Help with using multiple locations in a variable


#1

I want to use the webcore presence sensor to send push notifications when certain presence sensors leave or arrive at different locations. So if presence sensor 1 arrives at location 2, send a notification and when they leave location 2, send a notification.

This should be a fairly easy piston but I am stuck on consolidating it by using a variable for the locations. It would look something like this…

IF presence sensor(1,2or 3) arrives at location (1, 2, 3, etc.)
THEN
Send Push notification "presence sensor(1,2,or 3) arrived at location(1, 2, 3, etc.)
IF presence Sensor(1, 2, 3) leaves location (1, 2,3,etc)
Then
send Push Notification " presence Sensor(1, 2, 3) left location (1, 2, 3, etc.)


#2

See if something like this would work? If not, there are a few other ways we could approach it, but I think this one is probably one of the more simple methods if it works.

I only have one presence sensor so the variable looks a bit… useless. But if you load it up with 3 of them it’ll make more sense.


#3

So this is basically the piston in its basic form. I currently have this sort of notification setup using CoRE and various locations setup in ST. But if I use the webCore presence sensors then I don’t need all the different locations in ST. However, I think that this piston could be consolidated somehow to pick up the presence sensor and just notifiy when they arrive or leave certain places.


#4

I’ve been obsessed with a Commute Time piston that is short and simple. I had one similar to yours, with a lot of if then then this else this, etc. it worked,but was pretty huge. I then started working on getting it as small and simple as possible, but most importantly, easy to add things, without having to do major rework.

I’ll know for sure when I get home if this works, but I believe it will. It would be easy to modify this remove the commute time if you were not interested in that, just delete the last line.

This pretty much was stolen and slightly modified from a piston from Ady on this site


#5

I’m a bit confused. The piston I posted should do exactly that, unless I’m missing something? Just select all your presence sensors in the device variable, change log to console to send SMS with the same expression, and you’re off.


#6

This looks pretty close. One question though. In you IF {&currentEventDevice}'s currentplace is can I put a “any of” and a couple of locations?


#7

Ha, Sorry, to be honest I missed your post. Yup, that looks like the one I started with. :slight_smile:

Your piston is great, and works well


#8

No worries, my response was directed to pcgirl. I feel like what I posted accomplishes what she wants very cleanly with no need for variables.

But maybe there’s more functionality she wants that I missed.


#9

I have done this piston to notify my wife where I am close to, and how long the drive time should be.

It relies on a virtual switch for each family members presence device. If it turns on it starts the piston for that device and cultivates the desired info that I want

And a google api key

Import code is 0hqs


#10

That looks pretty cool. I like the idea. Can you send a green screen shot of this so I can import and play around. Also, the screen shot you have included has an address in it that you may not want published?


#11


#12

Sorry I posted this in the wrong place.


#13

@michicago how would I get just specific locations into this piston? I only want it to notify me when we arrive or leave certain places.


#14

Depending on the locations and presence sensors, there are a couple ways to go about it.

First question: is it the same list of locations for both sensors? If it is, then a simple change to each IF statement to make them “changes to any of”, and then typing in your locations would do the trick.


#15

If you use $places that is actually an array I believe. So $places[n] should reurn your place in the list, starting with 0 and going up


#16

@michicago this piston didn’t work. The push notifications that I received were $currentEventDevice " is departing " [$currentEventDevice : leavingPlace]".“
And $currentEventDevice " is arriving at " [$currentEventDevice : arrivingAtPlace]”."


#17

Can you post a green snapshot? Or, better yet, click on the send SMS line and post a screen shot if it?

Sounds like quotes are in the wrong place or Value was selected instead of Expression.


#18

This is imported from the original post that you put at the top of this thread. Here is the line:
$currentEventDevice " is departing " [$currentEventDevice : leavingPlace]"."

Here is the whole piston:


#19

Interesting. I think what happened is, when you changed the “log to console” commands from my piston example to Send PUSH notification for your implementation, it changed to the default drop-down of “Value”. Just change it to expression and you’ll see from the colors in the evaluation box that it’s going to work correctly.

From the piston I posted above:

From the piston I imported from 57gr, the 2nd IF statement has Value selected. The first one is correct and should work:

Try making sure they are both expression in your current piston and see if it works? If not, we’ll get it there. It worked when logging to the console so there’s no reason it won’t work.


#20

OK I have changed these to be Expressions.