org_traccar_manager_w250In earlier posts I’ve written about different GPS trackers, and even a small preview was shown about retrieving the Traccar data into Homeseer3. In a nutshell: After a few Xexun GPS trackers and even some clones, I’ve running for almost 2,5 years the Meitrack MVT340 GPS tracker with success running in my car. A pre-paid sim-only card is inserted and it uses in my case appr 3-4 MB a month (20.000 km a year). Advantage of this MeiTrack GPS tracker is the setup for 2 time intervals. One for “ignition=ON” and the other when the “ignition=OFF”. Both intervals are configured, so during driving the gps tracker will send more frequent an update, then when the car is not used.

Cloud software was not good enough for me, or the API was not good enough to retrieve realtime data of gave data then I want to have. Mobile phone apps drained the battery too much. Therefor the Traccar GPS tracking software is now in use for several years.  A lot of gps trackers are supported and documentation and support is very good. I don’t use the webinterface at all, or use the options from the webinterface, like Geofence, overspeed alarms, etc. I use only the server side for retrieving the gps data into a MySQL database. In the at the bottom of the page, I’m using my own geofences and a lot more.


Traccar configuration

In the Traccar installation folder: C:\Program Files (x86)\Traccar\conf the traccar.xml file is changed for using my own MySQL database:

Old entry:

<entry key=’database.driver’>org.h2.Driver</entry>
<entry key=’database.url’>jdbc:h2:C:\Program Files (x86)\Traccar\data\database</entry>
<entry key=’database.user’>sa</entry>
<entry key=’database.password’></entry>

New entry (login credentials are removed)

<entry key=’database.driver’>com.mysql.jdbc.Driver</entry>
<entry key=’database.url’>jdbc:mysql://localhost:3306/traccar?allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=ANSI_QUOTES</entry>
<entry key=’database.user’>******</entry>
<entry key=’database.password’>******</entry>

In the section “Protocol Config”, I’ve disabled all ports for other GPS trackers (changed to comments with tags). It’s not neccessary to keep those ports open on the server, while they are not used.

<!–<entry key=’tr20.port’>5018</entry>
<entry key=’navis.port’>5019</entry>–>
<entry key=’meitrack.port’>5020</entry>
<!–<entry key=’skypatrol.port’>5021</entry>
<entry key=’gt02.port’>5022</entry>–>

Further settings are:

<entry key=’geocoder.enable’>true</entry>
<entry key=’geocoder.type’>google</entry>

<entry key=’web.port’>****</entry>

The web port is changed too. The Traccar software is running on my home automation server with several other web interfaces, so for this I’ve changed to port number to a free one.


MySQL database

For basic setup, installation and configuration see Traccar website.

In the end, Traccar will create all the MySQL tables like this:


For me the table “postitions” contains the most important data. Here in every row, the GPS data will be stored, for every interval:


Traccar config file

Because in the traccar.xml config file, the option for Geocode is enabled, the address is visible too, based on latitude and longitude of the current location.

In the last column “attributes” additional gps device is visible (could be different per gps device), examples are:

  • Event (based on Meitrack, for example if car is moving, or ignition status is changed)
  • How many satellites are connected
  • How good the GPS reception is
  • Odometer (total distance done with that gps tracker)
  • Battery power level
  • Car battery level (not in volts)
  • IP address of GPS trackers
  • etc


vb.NET scripting

Now the data is accessible via MySQL, I’ve created a .vb script to retrieve the data into Homeseer. In my case the Homeseer event will retrieve every 20 seconds the Traccar data. This will give more then enough “realtime” data to act on it.

The script is originally used for several GPS devices, but in this post, it’s reduced to only one tracker. A lot of debug information can be displayed, with changing just one setting (debug = 1). All relevant data will then be shown in the Homeseer log.

All virtual devices has to be created manually (no script is provided for this).

Below some examplanation what is happening in the script:

  • In script line 46: The last record from the MySQL table will be retrieved.
  • In case data is found, then every column from that row, will be ‘displayed’ as a row in the result.
  • For every row, the data will be retrieved and stored in a virtual device: address, altitude, course, latitude, longitude, speed, servertime.
  • In script line 115: the last entry date from MySQL will be retrieved and stored in Homeseer:


  • In script line 117: an url will be generated for providing the realtime location on Google Maps, with marker. The devicestring of the Homeseer virtual device, will contain the Google Maps url, and below this, the clickable url to an image with Google Maps location (will be opened in new browser window):


  • In script linne 122: a similar url is generated as in line 117, based,on realtime location and course, so a nice image of streetview can be generated, facing the direction of the car. In this case a Google API is used. In Google’s developer console a project can be created with a API key. The result is:


  • In script line 129 and 130 the location of my work address is defined.
  • In script line 139, an old calculation is visible, to calculate the distance between 2 locations, via the air (not via road). This calculation was used before I became familiar with the Google DistanceMatrix API to calculate traffic duration via road in normal traffic and with live traffic delays (the setup of this API key and script  will be handled in a different blog post).


In script line 157, the distance from home will be calculated. if it’s less then 100 meters, then a virtual device will be set to ON, otherwise the virtual devices will be set tot OFF. In this case I now if my car is at home..or not.


  • In script line 165: the distance as above will be calculated, based on location to my work address, with a different virtual device.
  • In script line 196, the last row/column of the MySQL record will be read out, in this case some attribute values.

The result from the MySQL can be something like:


The following attribute values are read out:

  • event
  • sat
  • gsm
  • battery
  • odometer
  • power
  • ip


For the odometer an extra calculation is done.

A seperate event in Homeseer is running once a day, around 23:59 hours, to store the current odometer value in a different virtual device. In my case I retrieve the odometer value from MySQL, but a simpel direct script command to store the current value in another device is possible too.


In script line 251, the daily drive distance is calculated, based on the above sperately stored odometer at 23:59 hrs at the previous day, compared to the current odometer value. (current value – last night = today’s distance)



To use the MySQL_Traccar.vb script, two dll files has to be placed in the root folder of Homeseer3 (both files are provided in the download):

  • MySql.Data.dll (=version 
  • Newtonsoft.Json.dll (=version

(See first 2 replies in this blog post if you have issues with crashing other plugins. In that case, the Newtonsoft dll has to be placed in the \bin folder).

The file “settings.ini” in folder \Config, has to be supplemented with at least:




  MySQL_Traccar (369.7 KiB, 62 hits)