Traccar.org (GPS/GPRS Tracker) custom platform

custom_components vs custom_componets, did you copy paste this from your actual install? than there is a typo in your folder structure…

Thank You, I’m a idiot, I proofread multiple times and missed that.

New error:

2017-08-11 17:07:30 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 160, in async_setup_platform
disc_info)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 55, 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 49, in _update_info
self._device_data = json.loads(self._devices.text)
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

i’m guessing the port number you supplied is incorrect?
try:
http://demo4.traccar.org:80

Tried with many other ports and they all spewed a larger amount of errors. I’m asking at traccar if there is a specific port I need to use for that demo server. Of course it could be my sonicwall blocking the ports, and or hass.io will not support your script.

Just heard from Anton and all web servers service port are 80

Now maybe I’m confused but if port 80 was closed on my side would that not prevent most web interactions?

Automagically it started working. :slight_smile:

Hass.io 0.50.2, Intel NUC

Well it works. But I have an issue with google maps. Because I don’t understand where things happen I’m starting my questioning here.

device_tracker.10526 is the entity, in known_devices.yaml it is ‘10256’ if I use 10526 in google api it fails, works fine with the HASS map and button on top of page but not google. The only other difference that I have seen is traccar has 14 decimal places while the other provider is 7 except on iphone it is 14 decimal places and it has worked.
How can I change the entity, and where does it come from?

known_devices.yaml content:

'10526':
  hide_if_away: false
  icon:
  mac:
  name: Randy
  picture:
  track: true
  vendor:

camera.yaml content:
camera 8 works, camera 9 not so much

#camera 8:
  - platform: generic
    name: tester_Randy
    still_image_url: https://maps.googleapis.com/maps/api/streetview?location={{ states.device_tracker.randy_cell.attributes.latitude }},{{ states.device_tracker.randy_cell.attributes.longitude }}&size=456x456&key=mykey
    limit_refetch_to_url_change: true   
#camera 9:
  - platform: generic
    name: traccar_Randy
    still_image_url: https://maps.googleapis.com/maps/api/streetview?location={{ states.device_tracker.10526.attributes.latitude }},{{ states.device_tracker.10526.attributes.longitude }}&size=456x456&key=mykey
    limit_refetch_to_url_change: true           

and entity information:

> device_tracker.10526	Our_Home
> source_type: gps
> latitude: 44.38544986355593
> longitude: -69.40444697877102
> gps_accuracy: 0
> totalDistance: 12152.61
> ip: 45.2.190.13
> protocol: osmand
> speed: 2.0823703860354423
> address: null
> status: online
> lastUpdate: 2017-08-12T05:47:55.486+0000
> friendly_name: Randy

Devices names only consisting of only digits need to be treated differently I think. I’m not sure how? Put it in single quotes maybe?

I tried single quotes, it is why I asked where device name came from hoping it could be changed. I guess i could try double quotes for the fun of it.

It the device id from traccar.

Found the solution:

square brackets and single quote, remove the 1 period between device_tracker and id.

take this:
device_tracker.10526
and make it:
device_tracker[‘10526’]

nice to hear it works :slight_smile:
i’m publishing the traccar location updates to own tracks via mqtt in case anyone is interested, this is the automation i use:

alias: tracker_to_mqtt
trigger:
  platform: state
  entity_id: device_tracker.ford
action:
  service: mqtt.publish
  data_template:
    topic: 'owntracks/ford/ford'
    retain: true
    payload: '
                {"batt": 100,
                "lon":{{ states.device_tracker.ford.attributes.longitude }},
                "acc":{{ states.device_tracker.ford.attributes.gps_accuracy }},
                "p":100.5022277832031,
                "vac":10,
                "lat":{{ states.device_tracker.ford.attributes.latitude }},
                "t":"b",
                "conn":"w",
                "tst": {{ as_timestamp(now()) | int }},
                "alt":25,
                "_type":"location",
                "tid":"sc"}

Can I ask why?
What is it that you accomplish by doing this?
I’m moving to traccar because owntracks is not reliable, are you using this to circumvent owntracks reliability?

And can you give an outline to copy what you did, what files, where, how, why etc…

Was working, but now I get this error and at lost where to look.

2017-08-24 12:20:49 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 160, in async_setup_platform
disc_info)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 55, 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 51, in _update_info
self._positions_data = json.loads(self._positions.text)
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

hm… is traccar server running? or did you reboot the system and hass started before traccar server?

I’m using the demo4 web site, and it hasn’t gone down.

Ok I troubled shooted as much as I can and it still no work:frowning:
Error:

2017-08-26 16:36:23 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform traccar
Traceback (most recent call last):
File “/usr/src/app/homeassistant/components/device_tracker/init.py”, line 160, in async_setup_platform
disc_info)
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 332, in iter
yield self # This tells Task to wait for completion.
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 250, in _wakeup
future.result()
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 55, 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 51, in _update_info
self._positions_data = json.loads(self._positions.text)
File “/usr/local/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/local/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/local/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I have re-installed Hass.io many times, I have changed platforms from NUC to Synology Docker, I have installed a local Traccar Server and still not joy! I can track the devices through traccar sserver but cannot get it to work again on Hass!

Local Server Raw Data:

[{“id”:1,“attributes”:{},“name”:“Randy”,“uniqueId”:“669555”,“status”:“online”,“lastUpdate”:“2017-08-26T20:42:02.692+0000”,“positionId”:17,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:null},{“id”:2,“attributes”:{},“name”:“dummy”,“uniqueId”:“1”,“status”:“offline”,“lastUpdate”:null,“positionId”:0,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:null}]

Traccar Server Raw Data:

[{“id”:10579,“attributes”:{},“name”:“Laurie”,“uniqueId”:“764619”,“status”:“unknown”,“lastUpdate”:“2017-08-26T02:47:09.833+0000”,“positionId”:183769118,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:“helicopter”},{“id”:10597,“attributes”:{},“name”:“Koral”,“uniqueId”:“561764”,“status”:“online”,“lastUpdate”:“2017-08-26T20:29:04.179+0000”,“positionId”:184397486,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:“bicycle”},{“id”:10598,“attributes”:{},“name”:“Kaylee”,“uniqueId”:“220894”,“status”:“offline”,“lastUpdate”:“2017-08-22T17:30:52.000+0000”,“positionId”:181039760,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:“motorcycle”},{“id”:10568,“attributes”:{},“name”:“Kelsey”,“uniqueId”:“460488”,“status”:“online”,“lastUpdate”:“2017-08-26T20:29:37.234+0000”,“positionId”:184397836,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:“pickup”},{“id”:10526,“attributes”:{“web.reportColor”:“#FF0000”},“name”:“Randy”,“uniqueId”:“264334”,“status”:“unknown”,“lastUpdate”:“2017-08-26T18:22:33.549+0000”,“positionId”:184318462,“groupId”:0,“geofenceIds”:,“phone”:“”,“model”:“”,“contact”:“”,“category”:“person”}]

I have tried the dummy device, I just do not know what else to try.
I’m using admin,admin localy and email,password on demo server. This did work at one time but know not so much.

I’m very interested in this platform. Can you confirm that this device is working in Hass?

the json response you pasted is not valid.
Can you do an exact copy/past exact copy of the output from IP:PORT/api/devices and IP:PORT/api/positions

and try to validate it with
http://jsonviewer.stack.hu/

also paste the positions data (you can leave the lattitude and longitude data fields empty).

I do not know what json you think is not right, The traccar demo server must be right as it did work at the time I copied the json. The local has nothing in it as I was trying to get it to work, which is why it has dummy file in it.

I have it all working now, the traccar server locally and hass, my solution was to disable the cover chamberlain myq. Not 100 percent sure it was the issue but seeing as it started working after that and still 6 hours later I’m going with it as it seem to cause intermittent problems with other sensors (domains) like notify. Time now will tell if it is solved, thanks for the reply.

I also asked you why you are still using owntracks, care to respond?