Ask google to know where person x is and show location

Hi

I’m using presence detection (using HA app on android) for my family and i have set up zones in HA.
Is there i way i can ask google to know where person x is?
If its a known zone in HA, it should TTS the zone and show the HA or google map with the location on.
If its not a known zone, it should say "i’m not sure exactly but probably here and then show the HA map or google map with the location

Is that possible?

Anyone know?

I’m the only one wanting this?

I just searched for this solution and got here. I’m thinking about script that you could expose to Google. I will try it and let you know

1 Like

I have this.
I used the reverse places sensor to get the street name/address and distance from home.
Then I use a Node red sequence to send a request to the phone in question to do a high accuracy update, the code waits for a new location to be updated and then proceeds to TTS the location and distance of the person/phone.
If it’s in a zone then I get the zone name instead of the address.

Probably possible in yaml too, but I did it in Node red.

1 Like

Looking forward to some yaml :slight_smile:

As I said, I used Node red. I can give you the Node red sequence but I will not even attempt to convert it to yaml.

Sure why not, multiple solutions will bring one for me too i hope :slight_smile: I’ll see if i can make anything out of it

This is what I use to get my spouse position:

[{"id":"04f6362bd6ddf462","type":"function","z":"c513d12c.45645","name":"Build message to speak json string","func":"if(msg.loc == \"\"){\n    msg.zone = \"vid \" + msg.zone;\n    msg.payload = {\n        data:{\n            \"entity_id\": \"media_player.nedervaningen\",\n            \"message\": \"Petra är nu \" + msg.zone.replace(\"vid home\",\"hemma\") + \". Ungefär \" + msg.distance + \" meter härifrån.\",\n            \"language\": \"sv-SE\"\n        }\n    }\n}else{\n    msg.payload = {\n        data:{\n            \"entity_id\": \"media_player.nedervaningen\",\n            \"message\": \"Petra är nu vid \" + msg.loc + \". Ungefär \" + msg.distance + \" meter härifrån.\",\n            \"language\": \"sv-SE\"\n        }\n    }\n}\nmsg.event_type = \"\";\nmsg.topic = \"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3260,"y":1820,"wires":[["ca588a429bd5d98b"]]},{"id":"364fea07ae3a5193","type":"api-current-state","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.distance_away_petra","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"distance","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":2810,"y":1780,"wires":[["04f6362bd6ddf462","f87b48b1335c0de2"]]},{"id":"ca588a429bd5d98b","type":"api-call-service","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"tts","service":"cloud_say","entityId":"media_player.nedervaningen","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":3530,"y":1820,"wires":[[]]},{"id":"8218e39e447c8dac","type":"api-current-state","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":2,"outputs":2,"halt_if":"not_home","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"person.petra","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"zone","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":2100,"y":1820,"wires":[["364fea07ae3a5193"],["468870aa70b511c6"]]},{"id":"468870aa70b511c6","type":"api-current-state","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.petra_geocoded_location","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"loc","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":2460,"y":1840,"wires":[["364fea07ae3a5193"]]},{"id":"f87b48b1335c0de2","type":"function","z":"c513d12c.45645","name":"","func":"\nmsg.payload = \"\";\nmsg.event_type = \"\";\nmsg.topic = \"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3220,"y":1760,"wires":[["1479ab47f69a011d"]]},{"id":"d02755963bf68c3c","type":"switch","z":"c513d12c.45645","name":"","property":"continue","propertyType":"msg","rules":[{"t":"eq","v":"false","vt":"str"},{"t":"eq","v":"stop","vt":"str"},{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1870,"y":1820,"wires":[["a4a2077dfd8e8f93"],[],["8218e39e447c8dac"]]},{"id":"1479ab47f69a011d","type":"api-call-service","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.var_ar_petra","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":3440,"y":1760,"wires":[[]]},{"id":"ffb2dc7737b9285b","type":"function","z":"c513d12c.45645","name":"","func":"var changed = Date.parse(msg.payload);\nmsg.time = Date.now()-changed;\n//if(Date.now()-changed < 20000){\nif(msg.data.timeSinceChangedMs < 15000){\n    msg.continue = \"true\";\n}else{\n    msg.continue = \"false\";\n}\nif(isNaN(msg.counter)) msg.counter = 0;\nmsg.counter = msg.counter +1;\nif(msg.counter == 20){\n    msg.continue = \"true\"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1720,"y":1820,"wires":[["d02755963bf68c3c"]]},{"id":"a4a2077dfd8e8f93","type":"delay","z":"c513d12c.45645","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":1460,"y":1720,"wires":[["2968ee8e9585a431"]]},{"id":"d61c57f0229c435f","type":"api-render-template","z":"c513d12c.45645","name":"Last updated","server":"4bbca37b.1700ec","version":0,"template":"{{ as_timestamp(states.device_tracker.moto_g_8.last_updated) | timestamp_custom('%Y-%m-%d %H:%M', true) }}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":1570,"y":1820,"wires":[["ffb2dc7737b9285b"]]},{"id":"2968ee8e9585a431","type":"delay","z":"c513d12c.45645","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"7","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"outputs":1,"x":1640,"y":1720,"wires":[["e61bb75bf4abd356"]]},{"id":"e61bb75bf4abd356","type":"api-current-state","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"device_tracker.moto_g_8","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1320,"y":1820,"wires":[["d61c57f0229c435f"]]},{"id":"3a21ae0b31da17b7","type":"api-call-service","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_petra","entityId":"","data":"{\"message\":\"request_location_update\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":980,"y":1820,"wires":[["e61bb75bf4abd356"]]},{"id":"33b12558d92a128e","type":"change","z":"c513d12c.45645","name":"","rules":[{"t":"set","p":"loc","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":1820,"wires":[["3a21ae0b31da17b7"]]},{"id":"e505435c7a04cf22","type":"trigger-state","z":"c513d12c.45645","name":"","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.var_ar_petra","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"i8fdelpqngp","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":480,"y":1820,"wires":[["33b12558d92a128e"],[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

If you remove the “loop” in the beginning then it will not loop until it gets a new position and it will be faster but perhaps less accurate.

The last function node that creates the TTS message is this:

if(msg.loc == ""){   # if she is in a zone
    msg.zone = "vid " + msg.zone;  # "at" + zone
    msg.payload = {
        data:{
            "entity_id": "media_player.nedervaningen",
            "message": "Petra är nu " + msg.zone.replace("vid home","hemma") + ". Ungefär " + msg.distance + " meter härifrån.",
            "language": "sv-SE"
        }
    }
}else{  # not in zone
    msg.payload = {
        data:{
            "entity_id": "media_player.nedervaningen",
            "message": "Petra är nu vid " + msg.loc + ". Ungefär " + msg.distance + " meter härifrån.",   #Petra is now at <address>. About <distance> from here.
            "language": "sv-SE"
        }
    }
}
msg.event_type = "";
msg.topic = "";
return msg;
2 Likes

mm chinese for me

Did you import the sequence?

Import where, i dont use node red
I thought you would give me a diagram
Nevermind, i’ll wait for @therelevant20 then :slight_smile:

A picture won’t do much good since there is code in each node so the picture will only show you part of the automation.
To get all the details you must import it.

Any update on this?

Hey
Did you find a working solution for this?

not exactly what you’re looking for. I have been testing Life360. There is a lat long entity that could be extracted to create a google maps link or something similar but getting it on a map, I can’t get. The other thing with the script I mentioned is I could only get it on one device you ask with a single automation, not any google assistant device in your home. Its a bit convoluted and above my skill level. I’ll post what I have so far tonight

Thx, will see what you post
Why do you use life360 instead of just using the android app?

does the android app have location tracking other than home/not home?

Yeah of course.
You can see the perfect location, and if you are setting up “zones” in home assistant, the location is shown as “zone” when they are in it.

ok I’ll check that out too. I didnt see that