Leveraging google maps api for location on demand



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:


  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


** 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.


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


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.


Should this work with an iPhone as a Presence sensor?


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?


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.


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


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


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


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.


@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.