Home Assistant Community

Traccar.org (GPS/GPRS Tracker) custom platform

#48

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?

#49

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.

#50

It the device id from traccar.

#51

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’]

#52

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"}
#53

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…

Community Hass.io Add-on: Traccar
#54

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)

#55

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

#56

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

#57

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.

#58

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

#59

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).

#60

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?

#61

I’m still using owntracks on my/wife iphones for presence tracking.
i’m also using ot-recorder to log all tracks for future (statistics) projects.
Exporting the traccar data to ot-recorder makes sense in this scenario.
ot-recorder can receive traccar data sent via the traccar app directly i believe but havent looked in to it.

#62

I you have a device that is working with traccar server this component will fetch the location data from the traccar server.
Check the traccar forums for supported gsm/gprs trackers.

#63

I was curious as my experience with owntracks was not very reliable, and traccar works well with iphone.
I was going to ask if you had any suggestions for trackers (realtime) vehicle or personal

#64

It’s broken again!

Not sure if the bug is yours or core. How do I submit a bug report. I believe it has to do with tcp connection/package.

I attached my log, but have no idea where it is.

#65

Do you think that you will merge this into the master home assitant git?

#66

Another install, and still no luck.

- platform: traccar
  username: !secret traccar_username
  password: !secret traccar_password
  host: http://192.168.2.41:8082

Traccar server runs fine, Traccar UI works as expected, but continuous error. (fresh start and this is the error)

2017-08-29 02:12:13 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=11 from 2017-08-26 00:44:27.161237)
2017-08-29 02:12:16 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)
2017-08-29 02:12:57 WARNING (MainThread) [homeassistant.helpers.entity] Update for media_player.lounge is already in progress
2017-08-29 02:13:02 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.

Not all clients are active, it is 2:30 am

[
{
“id”: 1,
“attributes”: {},
“name”: “Randy”,
“uniqueId”: “669555”,
“status”: “online”,
“lastUpdate”: “2017-08-29T06:22:09.768+0000”,
“positionId”: 1707,
“groupId”: 0,
“geofenceIds”: [],
“phone”: “Samsung”,
“model”: “Note 5”,
“contact”: “”,
“category”: “person”
},
{
“id”: 3,
“attributes”: {},
“name”: “Koral”,
“uniqueId”: “561764”,
“status”: “unknown”,
“lastUpdate”: “2017-08-29T05:07:54.282+0000”,
“positionId”: 1694,
“groupId”: 0,
“geofenceIds”: [],
“phone”: “Samsung”,
“model”: “G4”,
“contact”: “”,
“category”: “animal”
},
{
“id”: 4,
“attributes”: {},
“name”: “Kelsey”,
“uniqueId”: “460488”,
“status”: “offline”,
“lastUpdate”: “2017-08-28T17:07:50.359+0000”,
“positionId”: 1297,
“groupId”: 0,
“geofenceIds”: [],
“phone”: “Apple”,
“model”: “?”,
“contact”: “”,
“category”: “van”
},
{
“id”: 5,
“attributes”: {},
“name”: “Kaylee”,
“uniqueId”: “220894”,
“status”: “unknown”,
“lastUpdate”: “2017-08-29T03:35:10.385+0000”,
“positionId”: 1676,
“groupId”: 0,
“geofenceIds”: [],
“phone”: “”,
“model”: “”,
“contact”: “”,
“category”: “animal”
},
{
“id”: 6,
“attributes”: {},
“name”: “Laurie”,
“uniqueId”: “764619”,
“status”: “online”,
“lastUpdate”: “2017-08-29T06:21:24.338+0000”,
“positionId”: 1706,
“groupId”: 0,
“geofenceIds”: [],
“phone”: “”,
“model”: “”,
“contact”: “”,
“category”: null
}
]

#67

Are you sure you are using the latest version?

Could you paste your positions json repsonse?
I’m guessing somethings going wrong there…
The first line “#-- coding: utf-8 --” in the compent is important for the component to work with ü and á like characters in adresses and stuff.