Location sharing: How data is saved / can be send by mqtt

I tried the default google maps location sharing of home-assistant, but its not working. There is a cookie error.

My own script (see below) works. The content of the cookie file is the same, I have no clue why is does not work. Probably some part of google rejects it because of something with the docker container or whatever.

How do I have to adopt the script so it works with home-assistant? Any hints or examples would be helpful, I do not need the complete solution.

I read the relevant code of HA and the docs

from locationsharinglib import Service

import time

import paho.mqtt.client as paho

cookies_file = 'cookies.txt'

google_email = 'myemail'

broker="192.168.XX.XX"

#define callback

service = Service(cookies_file=cookies_file, authenticating_account=google_email)

for person in service.get_all_people():

    #print(person)

    print(person.nickname)

client= paho.Client("client-001") #create client object client1.on_publish = on_publish #assign function to callback client1.connect(broker,port) #establish connection client1.publish("house/bulb1","on")

######Bind function to callback

#####

print("connecting to broker ",broker)

client.connect(broker)#connect

print("send config ")

for person in service.get_all_people():

    #print(person)

    print(person.nickname)

    config = '{"state_topic": "' + person.nickname + '/state", "name":' + person.nickname + ', "payload_home": "home", "payload_not_home": "not_home", "json_attributes_topic": "' + person.nickname + '/attributes"}'

    topic_config = 'homeassistant/device_tracker/' + person.nickname + '/config'

    client.publish(topic_config,config)

   

    topic_payload = '"' + person.nickname + '"/attributes"'

    message = '{"latitude": ' + str(person.latitude) + ', "longitude": ' + str(person.longitude) + ', "gps_accuracy": ' + str(person.accuracy) +  '}'

    client.publish(topic_payload,message)

client.disconnect()

For anyone interested: I am using Phonetrack addon for nextcloud now. There is a nice map and stuff.