Traccar.org (GPS/GPRS Tracker) custom platform

Well later came sooner than I expected. So far your updated script has worked for 4.5 hours through constant changes. (OK a few) Restarting traccar many time while I figured out where the batteryLevel went, and now I have that too. Great let’s hope it stays up now.

                    'batteryLevel': position_id['attributes']['batteryLevel'],

@Bob_NL I bought one of these from Amazon UK (now out of stock) and after deciphering the rubbish Chinese English instructions it worked perfectly with Traccar. I have just bought a wired in model for another car and looks like the same setup instructions again this is from Amazon UK.

@stevenhorner thanks. I ordered this one: https://www.gearbest.com/obd-diagnostic-tools/pp_320259.html
I’ll report back if it works once I received it.

Does anyone know how much data traccar uses on average?

I’m hoping for you this one works. It doesn’t say which protocol etc. good luck to you getting it to work with traccar.

Data usage depends on update frequency. I have around 300mb a month I think with updates every 30secs.

1 Like

@stevenhorner @koen01 Can you please suggest a device which would not only allow to locate the car in real time but also allow to check the fuel level and if possible a mic to be able to talk to?

I know there are a few on aliexpress.com but I am not sure which one to buy as I want it to work with Homeassitant and in the UK.

Thanks.

I’m still looking for one that can read the fuel level of my Ford Focus mk2 and Toyota Yaris 2006.
The 2 I bought only see ignition status, rpm and throttle %

How about this one? Plug and Play Quad Band Vehicle GSM OBD GPS Tracker GPS306b, 2.4G Attendance Management No box
http://s.aliexpress.com/iEvuMRZr
(from AliExpress Android)

Do you think the protocol of this obd would work with traccar?

Think you would need to ask on the Traccar forum, found the same model on Aliexpress slightly cheaper and included shipping. Also has some reviews one mentions Traccar complaining I think that it requires an IP address and won’t work with a dyndns service ( think that’s what they were trying to say)

Has anyone done the newest Traccar update and had success in using Koen01 script? There have been database changes and the default.xml has been severely slimmed down. Could my issues stem from using the H2 database?
Works by reverting back to the prior version of Traccar.

PS.
It was working with koen01 changes to the added a custom header for the last 6 days with no errors.

 This looks like one I have. No guarantees it will work though 😁

It works with Traccar, haven’t actually connected Traccar to Home Assistant yet. Although in Traccar I keep getting Vibration Alerts, which I think is an error in Traccar similar things mentioned on their forum.

First of all I would like to say thank you to koen01 for this great peace of code. Traccar is by far the best app for HA in my opinion. I tried them all. Best thing about traccar is that you can host it in your server and it just works. At first I was getting errors but after I took out
# 'ip': position_id['attributes']['ip'],
everything start working and its been working for 5 days without any problems.

1 Like

How do you customize it ? in my known_devices.yaml it showes up as
‘3’:
hide_if_away: false
icon:
mac:
name: Person 1
picture:
track: true
vendor:

Homeassistant does not like " device_tracker.‘3’: " this format

@Bob_NL did you already made some progress with the one you bought?

@geoffrey nope, not even close. Funny that you ask today because I just received my replacement which does work (I have succesfully extracted my GPS position via SMS to get started)…

Getting a LOT of errors:

device_tracker:
  - platform: traccar
    username: <redacted>
    password: <redacted>
    host: https://<redacted>.duckdns.org:5001
2017-10-03 19:31:01 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x6c5bc870>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='<redacted>.duckdns.org', port=5001): Max retries exceeded with url: /api/devices (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x6c5bc870>: Failed to establish a new connection: [Errno 110] Connection timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 160, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 28, in setup_scanner
    TraccarDeviceScanner(hass, config, see)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 41, in __init__
    self._update_info()
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 48, in _update_info
    self._devices = requests.get(self._host + '/api/devices', auth=(self._username, self._password),headers = ({'Accept': 'application/json'}))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 502, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='<redacted>.duckdns.org', port=5001): Max retries exceeded with url: /api/devices (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x6c5bc870>: Failed to establish a new connection: [Errno 110] Connection timed out',))

@stevenhorner I bought the exact same as yours. Can’t get it to work though. Can you point me in the right direction? The device reports my GPS coordinates correct whenever I call the number or send and SMS. Also, seting admin number and hostname gives “Ok!” message.

I’ve read several times being mentioned that a DuckDNS URL does not work but that an IP address is required. Not sure if that is what is causing your issues.

@stevenhorner also mentions in an earlier post in this thread.

I thought that only was applicable on this device: http://s.aliexpress.com/mUzUjeMZ

If I set the “adminip” with my duckdns url, I get the following response:

Hostname set ok!
PORT: 5002

If I set the “adminip” with my real IP address, I get the following response:

adminip ok!

Both do not work however.

When I use demo5.traccar.org I get a lot less errors:

2017-10-04 22:34:59 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 160, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 28, in setup_scanner
    TraccarDeviceScanner(hass, config, see)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 41, in __init__
    self._update_info()
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/traccar.py", line 48, in _update_info
    self._devices = requests.get(self._host + '/api/devices', auth=(self._username, self._password),headers = ({'Accept': 'application/json'}))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 633, in send
    adapter = self.get_adapter(url=request.url)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 717, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'demo5.traccar.org:5006/api/devices'