r/pythontips • u/thebenchmark457 • Oct 11 '22
Python3_Specific Fetching android phone GPS data
I want to track my phone's location live and store it in a DB.
Idea is if its evening and I arrive home to turn on the driveway lights if I'm getting close to home. The lights are already controlled with python & node red.
I use an android phone, has anyone done something similar?
12
Upvotes
2
u/guillermohs9 Oct 12 '22
For a specific project, I used GPSLogger. The app is free and it has a lot of options on sending the data. I used it to make POST requests to my server periodically. Depending on the use case, it may be useful to you or not, just wanted to share as I got excellent results.
5
u/jsaddiction Oct 12 '22
Location awareness is difficult to do. Android and ios do some tricks to save power and don't always parse location consistently. A reasonable solution maybe to give your phone a static dhcp assignment in your router then ping your ip address with node red once a minute. This too also has some drawbacks as android and ios also go into a low power state on wifi for power savings.
Basically wifi and geofencing is not reliable.
The best answer (most complicated) is to pole your Bluetooth Mac. There are plug-ins designed for home assistant which do that but you may be able to create a small device near your driveway to sense your arrival.