I'm using Traccar already for some years, with different kind of GPS trackers. In the beginning I was running a script that grabbed some static data from the MySQL DB, which is filled by Traccar itself. Based on requests of other board members and comments on my blog post: https://www.rutg3r.com/gps-data-traccar-homeseer/ and improvement of my own programming skills, it is resulted in a full automated script, that grab the device data dynamically and create virtual devices from it automatically.
More information, see blogpost: https://www.rutg3r.com/gps-data-traccar-homeseer/
Some screenshots of what the result can be:
DailyDistance dynamically created table:
Features:
The additional virtual devices are:
Release Notes:
Traccar version 2.05
Script: Traccar.vb:
Script: Traccar_DailyDistance.vb:
27-05-2018
Traccar version 2.01
Main changes are:
21-05-2018
13-05-2018
27-01-2019 (version 4.2.01)
Download: https://www.rutg3r.com/download/Traccar_4.2.01.zip
More information, see blogpost: https://www.rutg3r.com/gps-data-traccar-homeseer/
Some screenshots of what the result can be:
DailyDistance dynamically created table:
Features:
- *Get columns and values data from Traccar table 'positions' and store both in seperate arrays, except the last column "Attributes"
*Get the last column "Attributes" and add all the Keys and Values of the KVPair to seperate arrays
*Add additional virtual devices to the arrays, to provide seperate data
*Get data from all arays, create virtual devices and update values to Homeseer devices.
*A switch for show distances in kilometers or miles.
The additional virtual devices are:
- * Google Maps
* Google Streetview (API necessary)
* Google Streetview API counter (regarding new Google API legislation starting June 11th 2018)
* Moving (will track other devices for if tracker is moving)
* Aerial distance between current car location to home
* Aerial distance between current car location and "work".
* Presence tracker@Home
* Presence tracker@Work, can be used for timesheet purposes or what so ever.
* Realtime driven distance (+ saving total daily value to database)
Release Notes:
Traccar version 2.05
Script: Traccar.vb:
- Generating Streetview images is fixed. If "UseGoogleStreetview" is set to true, the Streetview API call will be run the with the first script run as well.
- Homeseer installation path, ip address and port are now automatically retrieved from the system for saving Streetview images (reduced the user specific data)
- Streetview device and API call counter device will now only be created when "UseGoogleStreetview" is true.
- DailyDistance event will be run once after the Traccar script is finished.
- When object "Odometer" is not available, the "Totaldistance" object will be taken.
- Added additional device "Moving". When "Motion" is not populated by the gps tracker, it wil track other devices and set "Moving" to true.
Script: Traccar_DailyDistance.vb:
- MySQL table "DailyDistance" wil now be created dynamically (based on all GPS tracker names and values).
- DailyDistance event will be run once after the Traccar script is finished. This will add the DailyDistance virtual devices directly. If
- UseMySQLDB" is set to true in DailyDistance script, the MySQL table will be created as well.
- With first script run, the current Odometer/Totaldistance value will be stored in the "Odometer Night" device, which means that the next Traccar.vb script run, can start calculating the "Odometer Daily" right away.
- Store API counters per gps device to DailyDistance table as well (these counters will get a reset as well at script run (end of the day).
27-05-2018
Traccar version 2.01
Main changes are:
21-05-2018
- Virtual device ranges are now created with negative value ranges (important for handling negative coordinates)
13-05-2018
- Kilometers/miles switch.
- Decimal comma/point removed. Script is working fine with decimal point only.
27-01-2019 (version 4.2.01)
Download: https://www.rutg3r.com/download/Traccar_4.2.01.zip
- Query update for getting gps_ids. When a new tracker is added to the Traccar webinterface and don't have uploaded data yet, the Homeseer script was having an error. Now the query will check on "lastupdate" as well. In case "lastupdate" is empty, the tracker id will be skipped.
- Some trackers, like the Teltonika FMB920 with firmware v03.18.16, are providing not all GPS objects in all drivingmodes. Depending on motion, a different amount of objects is available in the "attributes"column in the Positions table. When you let the script creating the devices when the less objects are available, the update value array will get 'confused' when there are more objects present with the next run. Now for every virtual device update, a check will be done if the array key is already present as virtual device. If not, the virtual device will be created dynamically, so a device update can be accomplished. In other words: when new objects are populated by the tracker, the new virtual device(s) will be created automatically with the next script run (when the object is providing data).
- At the end of the first script run, the "Traccar_DailyDistance" script will be run as well, to create the necessary devices directly (and table will be created).
- The "Traccar_DailyDistance.vb" script is changed to save the Root counter value back to the Root device, in case Traccar.vb have to create new virtual devices.
Comment