Store current place in a variable


#1
  1. Give a description of the problem
    Whenever my presence enters a configured place ie Work, Home, School etc. I want to store that place in a variable.

  2. What is the expected behavior?
    See above

  3. What is happening/not happening?
    Not sure if I’m using the right syntax.

**4) Post a Green Snapshot of the

Does this look right?

Thanks!


#2

Since you’re triggering on ArrivingAtPlace, I’d use that for setting the variable, too. Otherwise looks good!

Edit to add: Unless you’re adding more sensors to that Piston, you can just set the name = Dad at the top and save an instruction every time the piston runs (or maybe do away with it). String ID doesn’t seem to be used in the piston either - would delete that unless you plan on putting it to use.


#4

I switched the status to ArrivingAtPlace but it doesn’t seem as reliable to me. For some reason it triggered my arrival twice when I got home, once with an empty place and once with the place variable set, both identical times.

My daughter’s phone didn’t trigger at all from WebCore but did switch to present in ST.

Here’s the final piston. Any ideas what could be wrong?

Thanks!


#5

Ah, I forgot the presence sensors like to trigger multiple times. Try adding a condition statement to each arrival trigger that says… and arriving place is not ‘’. That’s two single quote marks. It. should ignore any times the parameter is empty. Or, alternatively, you could say "and arriving place is any of… and list out the places you have in webCore.

I’ll take a look at the piston tomorrow on my computer and will post up any suggestions I might have.


#6

Thanks. I re-worked it a bit since I think my logic was a bit off. So you know, the intention is that whenever my location changes it updates a web service, hence the POST command after setting each variable. The states I am trying to capture are:

I leave home. Update status to Away.
I enter a defined place, update status with that place name.
I leave that place, update status to Away again.
I arrive home, update status with Home.

How does this look?

Thanks!


#7

I think the above could work, but you could do it with a lot fewer statements (and make it easy on yourself if you add places later on). See if this makes sense and does what you want? I’m not sure about the GET request on departure from places, so I left that in there anyway:


#8

So much easier, thank you! I just tested this out and it worked pretty good.

However, when I left my home it got triggered 3 times:

Dad left at 12:55PM
Dad left Away at 12:55PM
Dad arrived Home at 12:56PM

Then it never triggered again during the entire 30 mins I was gone, but did trigger succesfully when I got home.

I found out this was due to the way I had configured the purple/outer bands for my Home place. I live off a road that is parallel to the main road so as I left the house I left the purple zone then passed through it again on the main road but only briefly. I have reconfigured the zones to prevent this from happening again (hopefully).

But this did raise a question. Let’s say this happens in a real life scenario. I leave but immediately turn around and re-enter, and for some reason the currentPlace event never triggers again. Because I’m capturing this status on a 3rd party database it gets stuck with “Away” but in reality I’m back at Home. I’m wondering if there’s a way to force a piston to “double check” my currentplace, say 5 minutes after it was initially changed, and if it is different then get the latest location and update my 3rd party status accordingly.

Saying all that, is that perhaps what the outer (non purple) band is there to prevent?


#9

Glad to help!

I think I know how we can stop that from rapid-fire like that in the piston. Did you use exactly what I posted, or a modified version of it? If modified, can you post it so I can make some changes?


#10

I used the exact piston, no changes.


#11

Ok, I had some time to look this over. The piston below will NOT stop the notifications from coming in if your status changes quickly, but it will set a timer for 5 minutes in the future and will update your push message if your CurrentPlace is different than what it sent last. There’s also a restriction added so you won’t get push notifications you “left Away”. Oversight on my part in the first one.

Lastly, there’s a section at line 53 that writes your presence sensor states to the console (log section below where you edit your piston). This will let you see what various attributes of your sensor are each time it runs. There are written in though, so you’ll need to type your presence sensor’s name over “Dan webCoRE” for it to work properly.

If you want to stop the quick-succession messages, there’s a way to do that, too. Just let me know.


#12

Worked a treat!! Thank you so much! I will test it out this entire week and report back. Ideally, I need to be able to have one script to include everyone in my house. Right now I just duplicated the script and changed the name Dad to each family member. But a single dynamic script would be best. I’ll try tackle that myself. If you have any suggestions to get that working I’d much appreciate it.

Thanks again for this!


External URL for tile?
#13

Glad to hear it!

There are a few different ways you can populate the name based on the active presence sensor. Depending how your presence sensors are named, it might be easiest just to take set your Name variable to a portion of $currentEventDevice.

Another option is to do a device array and map the names to it below. This would be easier to post an example than to try to explain it in plain text… let me know which way you end up going and I’ll help out if I can.

Cheers,
-Dan