Traccar.org (GPS/GPRS Tracker) custom platform

No problem! Glad the component is off use to someone. I no longer use it because im currently out of data Sim contract :slight_smile:

Hi

I have this up and running and monitoring the location of a Teltonika LTE Router and a Iphone using the traccar client.

The devices show up on the HA Map and update accordingly.
However there is nothing in know devices list. How can i link the devices to known device so i can give custom name etc. an example would be ideal if anyone can post one.

Thanks

You can add the Traccar devices manually in the known_devices.yaml… works for me.

example tracker in known_devices.yaml

nomad:
hide_if_away: false
icon:
mac:
name: nomad
picture: /local/bike-ride.png
track: true
vendor:

Thanks, i realised my known_devices file was not writable, working ok now and its automaically populating it.

Hi All,

I have the following error appearing in my log when trying to add this component:

Error setting up platform traccar
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/device_tracker/traccar.py", line 28, in setup_scanner
    TraccarDeviceScanner(hass, config, see)
  File "/config/custom_components/device_tracker/traccar.py", line 41, in __init__
    self._update_info()
  File "/config/custom_components/device_tracker/traccar.py", line 58, in _update_info
    _gps_accuracy=position_id['accuracy']
KeyError: 'accuracy'

Can someone help?

Thanks

ok solved this by following these steps as laid out above in reply #128

Hi,

This is awesome! Thanks! I just wanted to check something. I am trying to get the speed and the total distance as entities in HA. I have created a template sensor as follows but can’t seem to get it working… am I on the right track or totally off the mark?

golf_speed:
  friendly_name: 'Golf Speed'
  value_template: '{{states. sensor.device_tracker.golf.attributes.speed}}'
  unit_of_measurement: mph

golf_odometer:
  friendly_name: 'Golf Odometer'
  value_template: '{{states. sensor.device_tracker.golf.attributes.totalDistance}}'
  unit_of_measurement: miles

Solved. Removed “sensor”…

Anyone get this working on Hassio?

Mine is working just fine… what is not working for you?

Was able to get this working in Hassio, thanks.

Working great here. Thanks!

I set this up and everything appears to be working except the totalDistance parameter is somehow coming over incorrectly. In traccar I have 55423.01 mi for totalDistance, but in HASS it shows totalDistance: 89194719.17.

I’m not sure why… has anyone else seen this or know what might cause it?

This is how I have the sensor defined.

mini_odometer:
friendly_name: ‘Mini Odometer’
value_template: ‘{{ states.device_tracker.mini.attributes.totalDistance }}’

Disregard the previous question. I figured out the traccar api is sending meters and I converted to miles in the template.

Great to see this implemantation! I allready using Traccar and tried your instructions above on how to make it work and i get this error:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 184, in async_setup_platform
disc_info)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/device_tracker/traccar.py”, line 27, in setup_scanner
TraccarDeviceScanner(hass, config, see)
File “/config/custom_components/device_tracker/traccar.py”, line 40, in init
self._update_info()
File “/config/custom_components/device_tracker/traccar.py”, line 47, in _update_info
self._devices = requests.get(self._host + ‘/api/devices’, auth=(self._username, self._password))
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 524, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 631, in send
adapter = self.get_adapter(url=request.url)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 722, in get_adapter
raise InvalidSchema(“No connection adapters were found for ‘%s’” % url)
requests.exceptions.InvalidSchema: No connection adapters were found for ‘192.168.200.60:8082/api/devices’

@papakigr: I guess you didn’t add ‘http://’ to the URL in the configuration?

I have tried before and didn’t work.

I set it up again with this configuration:

device_tracker:

and this is the result:

2018-11-06 10:42:34 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 184, in async_setup_platform
disc_info)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/device_tracker/traccar.py”, line 27, in setup_scanner
TraccarDeviceScanner(hass, config, see)
File “/config/custom_components/device_tracker/traccar.py”, line 40, in init
self._update_info()
File “/config/custom_components/device_tracker/traccar.py”, line 60, in _update_info
‘ip’: position_id[‘attributes’][‘ip’],
KeyError: ‘ip’
2018-11-06 10:42:43 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.
2018-11-06 10:42:49 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 346, in _async_add_entity
msg)

Try this version:

Can’t edit the first post. This is the latest version. The one in de first post contains extra attributes that not all devices support.

That worked!!!

Thank you so much!