HomeHome AutomationGoogle Home - Location Sharing

Google Home – Location Sharing

A less creepy way to monitor your friends!

When it comes to location sharing, Google Maps got you covered. What if you don’t fancy taking your phone out then navigating through the menus?  Good news for you, I figured out how to do all the Google Home – Location Sharing, without actually sharing the location information with Google! Interested?

Google Home – Location Sharing

The entire setup works on both Google Home and Google Assistant. Let me preemptively dismiss your arguments here. Yes I know about Google Maps location sharing feature, In fact, I use it myself. Google Home isn’t handling this, so I thought I will find a workaround.

It’s so much easier to say: “Where is Matt?” and get the approximated address spoken to you. And should you desire the Google Maps pin, I made the option available for you, so you could send it via voice command to your phone.

There are also additional benefits:

  • Location is not shared with Google (even though I’m using Google Home!)
  • It’s harder to disable Google Home – Location Sharing as it uses Tasker
  • It’s just better!

To enable Google Home – Location Sharing I’m going to use the following services:

  1. NodeRED server (I’m  running it on a $5 Raspberry Pi Zero)
  2. IFTTT – a free account
  3. Tasker with AutoRemote plugin installed on the target device
  4. Google Maps API key

To make the Google Home – Location Sharing work for you, you will need to create a small Tasker profile on each Android phone you want to monitor this way. In addition to this, If you want to get the directions sent to your phone, another Tasker profile has to be created on your personal device.

Google Home – Location Sharing – IFTTT

To send the voice commands to Google Home or Google Assistant – I’m using IFTT service. I have 2 commands, one to request the location from a specific contact, and one to send me the coordinates to my mobile.

IFTTT “Where is $?”

Feel free to modify the questions to your liking, I used the following configuration:

IF THIS(GOOGLE ASSISTANT)

Commands: Where is $, Find $ for me
Answer: Give me one second, I'll go and ask

THEN THAT (WEBHOOK)

Url: https://NODERED_IP:1880/location/person
Method: POST
Content type: application/JSON
Body: {"name":"{{TextField}}"}
IFTTT “Directions”

To get the directions I need another voice command that will trigger the correct flow in the NodeRED, this one is configured as follows:

IF THIS(GOOGLE ASSISTANT)

Commands: Send the directions to my phone
Answer: Check Google Maps for details

THEN THAT (WEBHOOK)

Url: https://NODERED_IP:1880/location/send
Method: POST
Content type: application/JSON
Body:

This request doesn’t need the body, as we only need to trigger the flow, no actual data is passed back to the server.

Google Home – Location Sharing – TASKER

Google Home – Location Sharing requires 2 profiles. Once on each target device, and one on your personal device if you want to get the coordinates sent to you.

Target Device – Get Location
TASKER PROFILE - Get Location
Profile: Get Location 
	Event: AutoRemote [ Configuration:location ]
Enter: Get Location 
	Abort Existing Task
	A1: Get Location [ Source:Any Timeout (Seconds):30 
	    Continue Task Immediately:Off Keep Tracking:Off ] 
	A2: Variable Set [ Name:%loc To:%LOC 
	    Recurse Variables:Off Do Maths:Off Append:Off ] 
	A3: Variable Split [ Name:%loc Splitter:, 
	    Delete Base:On ] 
	A4: Flash [ Text:%loc() Long:On ] 
	A5: HTTP Post [ Server:Port:%MyNodeRED 
		Path:/location 
		Data / File:lat=%loc1
			    long=%loc2 
	    Cookies: User Agent: Timeout:10 
	    Content Type: Output File: Trust Any Certificate:Off ] 

You will need to obtain the AutoRemote key for each device. The plugin is used to issue the request via NodeRED. When the “location” AR event is received, Tasker will grab a set of current coordinates, split them into separate variables (%loc1,%loc2) and sends it back to NodeRED using HTTP post:

HTTP post
Server:Port:%MyNodeRED
Path:/location 
Data / File:
   lat=%loc1 
   long=%loc2
Your Device – Get Directions
TASKER PROFILE: Display Directions
Profile: Display Directions 
	Event: AutoRemote [ Configuration:GHLOCATION (case ins) ]
Enter: Open Location 
	A1: Open Map [ Mode:Point 
		Address: Lat,Long:%arcomm Zoom:1 Label: ] 

This profile installed on your Android device will wait for the coordinates sent by the NodeRED and will open Google Maps pointing you to the destination. This is a very simple profile with a single action Open Map.

Google Home – Location Sharing – NodeRED

Everything is handled by the NodeRED server. The Google Home – Location Sharing setup is split into 3 flows. Before I share the details, be sure to obtain the following information:

  1. AutoRemote Key for yours and target device
  2. Google Maps API key
  3. Your NodeRED external IP

FLOW: Request Location

The HTTP POST request to “/location/person” starts the flow. I’m expecting a name in a JSON from {“name”: “Matt”} in msg.payload.name . Before I do anything with this information, I want to store it for later. To store the variable and make it available globally, we can use this script:

global.set("locationName",msg.payload.name);
return msg;

Note that this function won’t change the payload, we will be able to use it later in the switch node.  The switch node checks the value of the payload against the known contacts. In this example, I’m using “Matt” so I’m checking against the stored names and send the outcome to the correct output.

Since I need the AR Key to send the location request to the correct person, I assign the correct AutoRemote key to each name and set it as msg.payload.

Lastly, I combine the information with the AR URL with the message=location:

https://autoremotejoaomgcd.appspot.com/sendmessage?key={{payload}}&message=location

and save it as msg.url (important) – which is used in the HTTP POST node finishing the flow.

FLOW: Announce Location

Tasker submits the coordinates back to NodeRED as 2 entries:

  • msg.payload.lat
  • msg.payload.long

As before, I want to store the coordinates for the later use – I’m using the Function node which is configured:

global.set("locationLat", msg.payload.lat);
global.set("locationLong", msg.payload.long);
return msg;

At the same time, I’m passing the needed coordinates to the Google Maps API link which will translate the coordinates into the human-readable address. The template node is great for that. Don’t forget to add your API key obtained from Google!

https://maps.googleapis.com/maps/api/geocode/json?latlng={{payload.lat}},{{payload.long}}&key=GOOGLEAPIKEY

I’m saving this link again as msg.url which will be passed over to the HTTP GET request.

This request will return several matches stored in a JSON format. I know that the closest address will be stored as the 1st entry inside that array. I will need another function node to process this information and add the name of the person that shared the location with us:

msg.payload = msg.payload.results[0].formatted_address;
var x = global.get("locationName");
msg.name = x;
return msg;

I’m storing the name in msg.name and the address in the payload. Lastly, I need to format the correct reply and pass it over to the Google Home Node (node-red-contrib-google-home-notify).

{{name}} is near {{payload}}, let me know if you need the directions.

FLOW: Send Location

This is optional, but if you want to have directions on your phone, you will need another HTTP POST node “/location/send” which will trigger a function:

var lat = global.get("locationLat");
var long = global.get("locationLong");
var name = global.get("locationName");
var ARkey = "ARKEY"
var ARmessage = "GHLOCATION=:="+lat+","+long;
msg.url = "https://autoremotejoaomgcd.appspot.com/sendmessage?key="+ARkey+"&message="+ARmessage;
return msg;

I’m retrieving the information about the name and coordinates, and send it back to my phone (using AR Key for my personal mobile) – this URL has to be stored as msg.url to the HTTP POST node could issue the notification back to the Tasker.

Conclusion

Following the feedback given to me, I have added the ETA and distance query options to the setup – you can read about these here. It’s pretty fun to add the functions that are not present in  Google Home. I’m sure, that once I learn how to make Alexa speak in the similar matter, entire Google Home – Location Sharing setup could be used with Amazon Echos instead. Let me know what do you think about it!

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.