Python Plugin: GPSLogger

Python and python framework

Moderator: leecollings

User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Python Plugin: GPSLogger

Post by Marathon2010 »

I've used the Life360 integration for several years with much pleasure. Unfortunately the Domoticz integration was not maintained anymore the moment the integration appeared to be broken (authentication issue by Life360, see https://www.domoticz.com/forum/viewtopi ... 60#p310361).

So, based on this integration, I've created a new plugin (see https://github.com/TurnOfAFriendlyCard/ ... ger-Plugin for more details). A mobile phone is used to capture actual location data. The app used for this plugin is GPSLogger (see https://gpslogger.app), however other GPS logging apps can be used as well. In fact the most important prerequisite is that the app is able to share location data via the Domoticz API on regular basis.

Concept is that users are determined for these mobile phones (just names, no formal users in Domoticz). Besides that the home location is identified by the location setup in Domoticz. A fence around the home location determines how Home is identified. For example a circle of 100 meters around the address Coolsingel 40, Rotterdam, the Netherlands (latitude 51.922710 and longitude 4.479160).

Next devices will be created and updated in Domoticz (in the utility tab unless otherwise specified) - those devices are the same as for the Life360 integration:

Presence: This is an On/Off switch indicating the user is within the fence (in switches tab).
Location: Text describing what the actual location of the user is.
Battery: Charging percentage of the battery of the user.
Distance: Distance in minutes of the actual location to the fence (to implement in future).
Speed: Speed in kilometers / hour of the user.
RawData: Data which is captured from the GPSLogger app. This device is hidden (only in devices tab).

Switches.jpg
Switches.jpg (10.16 KiB) Viewed 2633 times
Utility1.jpg
Utility1.jpg (18.27 KiB) Viewed 2633 times
Utility2.jpg
Utility2.jpg (19.22 KiB) Viewed 2633 times
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: GPSLogger

Post by waltervl »

Thanks for the alternative!
I have added your plugin to the Wiki Plugin List and modified the original start topic of the Life 360 plugin to indicate its deprecation.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

Looks great, but atm there is an error message that GPSLogger has some bugs and it won't open. .
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

Hello Edwin, please share details so I can analyse.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

It seems fixed now.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Python Plugin: GPSLogger

Post by HvdW »

waltervl wrote: Tuesday 20 February 2024 9:02 I have added your plugin to the Wiki Plugin List and modified the original start topic of the Life 360 plugin to indicate its deprecation.
Why is GPSlogger present in the WiKi list and not present in the Python Plugin Manager?
Plugins.jpg
Plugins.jpg (21.92 KiB) Viewed 2540 times
Bugs bug me.
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: GPSLogger

Post by waltervl »

Because the wiki list and the plugin manager(s, there are 2) are not related.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

So far I have it working on the phone, but in the log I can see a message that it couldn't upload the log. I created an user for GPSLogger and used this in the base64decode site. The output from there I entered in GPSLogger app.
Custom URL: maximum attemps failed: giving up
Custom URL: Kon het bestand niet uploaden (Coulnd't upload the file)
I can manually enter data to the devices with going directly to https://<myurl>.ddns.net/json.htm?type=command&param=udevice&idx=429&nvalue=1&svalue=1,2,3
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

I can manually enter data to the devices with going directly to https://<myurl>.ddns.net/json.htm?type=command&param=udevice&idx=429&nvalue=1&svalue=1,2,3
Related to the example, can you see in Domoticz the setup/devices tab the RawData device showing data received from GPSLogger? In your situation it should show "1,2,3"

RawData.jpg
RawData.jpg (30.39 KiB) Viewed 2491 times
Custom URL: maximum attemps failed: giving up
Custom URL: Kon het bestand niet uploaden (Coulnd't upload the file)
If data is not at all in the Domoticz RawData device it should be GPSLogger cannot connect to Domoticz, did you validate the SSL certificate in GPSLogger? See https://gpslogger.app/#customsslcertificates

GPSLogger SSL.jpg
GPSLogger SSL.jpg (137.2 KiB) Viewed 2491 times

Did you enter in the "HTTP Headers" section of GPSLogger:


Content-Type: application/json
Authorization: Basic <base64>

where <base64> is the decoded base64 of <username>:<password> (including the colon).

See below setup:
GPS Logger Custom URL2.jpg
GPS Logger Custom URL2.jpg (94.78 KiB) Viewed 2491 times
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

This is what I have in the raw data
Screen Shot 2024-02-21 at 16.39.34.png
Screen Shot 2024-02-21 at 16.39.34.png (24.04 KiB) Viewed 2487 times
So that works. I already had validated the certificate, but will go through all this again.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

Seems that it is something with some security, I tried the same url on another laptop and then the result was a 401 error.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: GPSLogger

Post by waltervl »

You probably have to add your user credentials to the link.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

Perhaps try with HTTP instead of HTTPS to at least get it up and running?
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: GPSLogger

Post by EdwinK »

Going to try tomorrow (or the day after). Now time for some rest :)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

Updated functionality of the plugin (v3.0.0) by adding Map device showing the actual location in either Google Maps or Open Streetmap. Map will be opened in a new window.

Utility3.jpg
Utility3.jpg (9.98 KiB) Viewed 2402 times
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Python Plugin: GPSLogger

Post by capman »

A still get this error in the log

Code: Select all

 2024-03-30 11:48:47.190 Error: Location: Call to function 'onHeartbeat' failed, exception details:
2024-03-30 11:48:47.190 Error: Location: Traceback (most recent call last):
2024-03-30 11:48:47.190 Error: Location: File "/home/pi/domoticz/plugins/Domoticz-GPSLogger-Plugin/plugin.py", line 313, in onHeartbeat
2024-03-30 11:48:47.190 Error: Location: _plugin.onHeartbeat()
2024-03-30 11:48:47.190 Error: Location: File "/home/pi/domoticz/plugins/Domoticz-GPSLogger-Plugin/plugin.py", line 210, in onHeartbeat
2024-03-30 11:48:47.190 Error: Location: Domoticz.Debug('Processing '+str(member)+' RawData: '+Devices[member*self.numberDevicesPerMember+self.devRawData].Name+' = "'+Devices[member*self.numberDevicesPerMember+self.devRawData].sValue+'"')
2024-03-30 11:48:47.190 Error: Location: KeyError: 27 
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

What version did you install (and started with an earlier version)? Please show the input fields (specific the "Users GPSLogger" entry). And please show overview of the devices created (so <user> Location, <user> RawData, ...) from the Setup/Devices menu.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Python Plugin: GPSLogger

Post by capman »

Thanks 4 the reply.
Started direct with the latest version , of the moment, v3.
See screenshots.
Schermafbeelding 2024-04-01 102433.jpg
Schermafbeelding 2024-04-01 102433.jpg (240.55 KiB) Viewed 2250 times
Schermafbeelding 2024-04-01 102638.jpg
Schermafbeelding 2024-04-01 102638.jpg (52.22 KiB) Viewed 2250 times
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

The last semi colon after Milan should not be there. So entry should be:

Kris;Sabine;Milan

Will process this as an issue to be validated as well.

Edit: https://github.com/TurnOfAFriendlyCard/ ... n/issues/5
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
User avatar
Marathon2010
Posts: 37
Joined: Tuesday 02 February 2021 23:02
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: GPSLogger

Post by Marathon2010 »

Issue resolved in v3.0.1.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest