I’ve been working on a project to integrate Google Family Location Sharing with OpenHAB, and I wanted to share my experience in case it helps anyone else. The goal was to get GPS locations from my family’s smartphones into OpenHAB for advanced presence detection and automation. At first, I considered using specialized apps, but since my family already uses Google Maps location sharing extensively, it made the most sense to go with that.
The major complication is that Google doesn’t provide a real API for this, but there’s a workaround using the locationsharinglib Python library. I decided to use MQTT to get the location data into OpenHAB since I’m already familiar with it and use it extensively. Here’s a quick overview of how I set it up:
-
Python Script: I wrote a script that fetches the location data using
locationsharingliband publishes it to MQTT. It updates every minute, which seems to be a good balance between freshness and resource usage. -
MQTT Configuration: I set up MQTT on my local network and configured the script to publish to specific topics for each family member. For example,
googlelocation/person1/latitudeandgooglelocation/person1/longitude. -
OpenHAB Setup: I created things and items in OpenHAB to receive the data. Each person has channels for accuracy, address, battery level, charging status, country code, timestamp, full name, ID, latitude, longitude, and photo URL.
-
Transformations: Since OpenHAB expects timestamps in a specific format, I used a transformation script to convert the Google timestamp to the required format.
-
Automation: With the location data in OpenHAB, I can now create automations based on presence. For example, turning on lights or adjusting the thermostat when someone arrives home.
This setup has been running smoothly for a few weeks now, and it’s been a great addition to my smart home ecosystem. I hope this helps anyone looking to do something similar! If you have questions or suggestions, feel free to reach out.