Hi. I’m a complete newbie to Home Assistant, but have been using traccar for several years relying on the demo servers so was very pleased to see that I could create my own server - Thanks Franck.
It was a struggle pulling together all the snippets of info from the main documentation and various support fora, but I think I’m there. So if it helps other newbies I summarize (my interpretation) what I did to get it going.
I’m running on a dedicate Raspberry Pi 4 Model B 4GB with the 32bit version of Home Assistant on a 64GB micro SD card.
- Installed MariaDb with the config:
databases:
- homeassistant
- traccar
logins:
- username: homeassistant
password: [MYHOMEASSISTANTPASSWORD]
- username: traccar
password: [MYTRACCARPASSWORD]
rights:
- username: homeassistant
database: homeassistant
- username: traccar
database: traccar
At this point nothing is using MariaDb but 2 empty databases are created somewhere on my SD card ready for HA and traccar to use.
- Added the following to the configuration.yaml file:
recorder:
db_url: mysql://homeassistant:[MYHOMEASSISTANTPASSWORD]@core-mariadb/homeassistant?charset=utf8
After restarting HA it seemed to pick up the new database, old stuff was lost (I think) but nothing else new appeared.
3 Installed the traccar ad-in with the config:
ssl: true
certfile: fullchain.pem
keyfile: privkey.pem
log_level: info
The GUI worked but no trackers yet. You can create a new account or login to admin/admin. At this point it is using its own DB I think.
4 Set up my trackers - I added the trackers through the GUI with their ID (I have 2 in cars and the traccar client on my phone). Then I changed the URL in the trackers to my home’s domain name maintained by dynu and the router. I then created the port forwarding rules in the router - one for my cars on Port 5002, and the other for my phone on Port 5055 . The phone suddenly appeared on the traccar map but the cars didn’t.
I then added the tracker port I needed for my cars into the traccar.xml file in the config directory by copying the appropriate entry commented out into the custom configuration area thus:
<!-- Enter you custom configuration below this line -->
<entry key='tk103.port'>5002</entry>
Sure enough, the cars then appeared on the traccar map within their 1 minute refresh rate. They, and the phone, also appear as bars in the HA History page.
5 Get traccar to use MariaDb - The following needed to be added to traccar.xml file in the custom configuration area:
<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://core-mariadb:3306/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>traccar</entry>
<entry key='database.password'>[MYTRACCARPASSWORD]</entry>
Note. I tried localhost and the Pi’s actual IP address but these didn’t work. I had to use core-mariadb, as used in the recorder: bit above. No idea why!
After restarting traccar it all contuniued to work ok. Infact even the traccar history seems to still be there. I’m guessing it’s using MariaDb but not 100%.
My experience wasn’t as straight forward as this, that’s why I’m writing this to help others. I hope I didn’t miss anything out. It’s all my interpretation of what went on.
I now have a few questions.
- Why bother with MariaDb as it all seemed to work regardless?
- Apart from hosting my own traccar server, and getting the tracked devices shown as bars in the HA history, What are the benefits of integrating with HA?
- Should I be able to see the devices on the homeassistant map?
- Can I get cards for the devices on the Dashboard.
Eventually I may want to create rules and stuff based on the arrival of my car at home eg but that’s way off yet as I get to grips with everything!
Thanks to all the contributors.