Leveraging google maps api for location on demand

presence

#1

OK here is how i do the where is family by request.

  1. create a virtual switch in Smartthings for each person that you wan to know their location on demand I named mine 'virtual presence request tom, virtual presence request Kim, etc.
  2. share those switches with webCore so that you can use them.
  3. i use google home for my requests, but you can use Smartthings app to turn the individual switch on, when you want to know someones location. i have set up shortcuts in google home so when i say "where is tom, it turns the virtual switch on.
  4. you need to get an API key for google distance matrix API and one for the geolocation API
    you can get the keys by going to the following websites:

https://developers.google.com/…/distance-matrix/start
https://developers.google.com/…/docum…/geolocation/intro

  1. follow the instructions on how to create an API key for each. once created copy these and save them somewhere. you will need them later.
  2. in webCore create a few global variables :
    @GoogleMapsDriveTimeApiKey = enter the key you created earlier
    @Google_Maps_Api_Key = enter the key you created earlier
    @GPS_Home = enter in the GPS location of your home (latitude,Longitude)
    @LongState= Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming

@ShortState= AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KA,KY,LA,ME,MD,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PE,RI,SC,SD,TN,TE,UT,VT,VA,WA,WV,WI,WY

** note ** the longstate and shortstate are used to convert the shortstate text to a long version. this allows there wording to be used by speakers when using text to peach commands from webCore

  1. import the following piston and use as needed. your results may vary but it works great from my side.

my actual presence sensors are named presence tom, presence kim, etcl that is why when you look at this code it is replacing the word presence with a ’ ’ so when outputing the result to speakers it would not say the word presence. change that to your circumstance.


#2

This sounds absolutely delicious! :grinning:
Thanks for sharing!!


#3

It’s actually the geocoding api not the geolocation api I believe. Check the url in my get statements and that is the one you want.


#4

Should this work with an iPhone as a Presence sensor?


#5

So if I’m understanding this, this allows for Echo to speak where someone is located in my Google maps. Which is really cool, and I will definitely set it up.

Is there anyway to leverage it as an actual presence sensor?


#6

I use it with my iPhone webCoRE presence sensor.

I gave a duffeeent version that should be posted later tonight that will allow the expressions to be imported for the google apis. For some reason the current one that I shared leaves them blank.


#7

here is the revised version… no need for the @shortState and @longstate variables


#8

Can you perhaps share a little information on how you went about it? Seeing up as presence in Android.


#9

The original post pretty much Eskisehir u through it. What questions do u have.


#10

I guess I was missing the part of how to tie in Google Maps to the Presence sensor. I’ll read it over again. But I believe I attempted the Webcore presence sensor install before, and it didt work well at all; and I didnt remember google maps tied into it.


#11

@Gopack2 ,
Thanks for the great example script and work!

@Philpan ,
I believe that the Webcore presence sensor has issues with newer releases of Android (>=8.0) (See the end of the webcore presence sensor thread). I found recent work updating the life360 DH (Life360 device handler with improved refresh discussion) that appears to fix most of the issues on android; however, it appears that there are transient issues that are being addressed in iOS currently in the last few posts. I will be posting a piston on that thread that leverages their work and @Gopack2 work presented here.