Traccar – Track your devices


Not long ago a friend asked if i know a system that can help him keep tracking his fleet of trucks and drivers. He wanted to track
Their  Current location, if they are on the right track and more.
so i did a little research and found this system called Traccar.

The system has the following futures:

  • Support of many GPS protocol and devices.
  • Friendly User Interface (Web based)
  • Very simple to configure.
  • Real time tracking.
  • Very Accurate.
  • Creating reports.
  • Send alert to devices.
  • Home assistant integration.

Traccar is small system, written in Java that is running on your local network or cloud and made to help you keep tacking of your mobile devices. in this guide i will show you how to use and install Using Docker-Compose.

Part A – Installation:

The first step is creating a new docker-compose.yaml for the Traccar installation. in order to that write down this commands:

cd ~/docker
mkdir traccar
cd tracar
sudo nano docker-compose.yaml

And paste the following Code:

version: "3.6"
    image: mariadb:latest
      - "3306:3306"
    container_name: mysql
      - MYSQL_ROOT_PASSWORD=YourSecureMySqlPassword
      - "./mysql:/var/lib/mysql"
    restart: always

    image: traccar/traccar
    container_name: traccar
      - 8082:8082
      - 5000-5150:5000-5150
      - ./traccar.xml:/opt/traccar/traccar.xml
      - MYSQL_DATABASE=traccar
      - MYSQL_USER=traccar
      - MYSQL_PASSWORD=YourSecureMySqlPassword
      - MYSQL_HOST=mysql

save the file by pressing Ctrl + X, Y and enter.
and run this command to deploy the containers.

sudo docker-compose up -d

Now, after the deployment has done, open your browser and browse to your server ip: http://server_ip:8082.

the first screen you’ll see will be the registration form that will allow you create the admin Account:

Traccar Login Page

Hit The Register button, fill up your information and Hit Save.

Traccar User Registration - תומר קליין

Traccar Logon Page -

Now you can hit Login and continue to system setup

Part B – Install Traccar Application and configure

Now, after we have installed the server we need to install Traccar application on your mobile devices, Download instructions can be found Here .

Traccar Mobile Applications

After you have installed the app, open it and go to settings. in the server url enter your serve ip address / domain and port. the default (and most common is 5055).

Traccar Server URL

now you will have to set up device Unique id that will identify you device on the system.

Traccar Device ID

Next we will setup the Location update Frequency, the default is 360 seconds, i changed it to 60.

Traccar Send Frequency

and the last Parameter will be the GPS Location Accuracy.

Traccar Location accuracy

Now, after we have configured the application side, lets go back to the server and add our mobile device to the tracking list.
in order to do that, click the “+” sign on the left side.

Traccar - Add Device
מתוך הבלוג של תומר קליין

A window will popup. fill the details of the device (in this stage will fill only the basic Required fields).

Hit the save button, and than in the application start the service by clicking the switch.

Traccar - Connect to server

If you’ll click the “status” label on the top right corner you will able to see if there are connection errors and the connection log.

Traccar  - Connection Status

Waite a few moments and get back to the server interface, you should be able to see a small green dot which is your current position.

Part C – Configure Traccar as Home-Assistant device tracker

In this section I will explain how to use Traccar as Home-Assistant device tracker. since version 83.0 Home-Assistant has officially included Traccar in the components list (you can read more Here) and that made the integration very easy.

So, in order to add Traccar into Home-Assistant all you have to do is to add the following section into your configuration file and restart Home-Assistant

  - platform: traccar
    host: [traccar server address]
    port: [port]
    username: [email]
    password: [password]

Be sure to replace:

  • host – Your Traccar Server IP Address
  • Server Port (Optional)
  • username – the email address you use to logon the system.
  • password – the password you use to logon the system.

If known_devices.yaml does not exists Home-Assistant will create it for you, if the file does exist Home-Assistant will auto add the following lines:

  hide_if_away: false
  name: my device
  track: true

and you will able to see your device on the map

Part D – Using Nginx

Using Nginx as reverse proxy will help you to secure your system a bit.
instead of using Port Forwarding you will be able to use Custom domain or sub domain under http/https protocol.

simply add the following lines into your Nginx configuration and be sure to set your sub domain, server address and ports correctly.

server {
    server_name [web interface domain like];
    listen 80;
    location / {
        proxy_pass http://192.168.x.x:8082;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For;
        proxy_set_header X-Forwarded-Proto $scheme;
        # the next 3 lines are for cocket protocol nedded both for web ui and mobile app
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
	server {
    server_name [location update domain like];
    listen 80;
    location / {
        proxy_pass http://192.168.x.x:5055;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For;
        proxy_set_header X-Forwarded-Proto $scheme;
        # the next 3 lines are for cocket protocol nedded both for web ui and mobile app
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

Good luck!

Be the first to comment

Leave a Reply

Your email address will not be published.