driveruniqueId stays null

Jan4 years ago

I have the following problem, I'm linking a driver to a device via API (api/permissions). When I check if a driver has been linked with the device (api/drivers?deviceId=1) it returns the driver I set with its uniqueId.

I added to traccar.xml:

<entry key='processing.computedAttributes.enable'>true</entry>
<entry key='processing.copyAttributes.enable'>true</entry>
<entry key='processing.copyAttributes'>driverUniqueId</entry>

But when i check in reports the driver is empty, when i check via API last position, api/positions?deviceId=1 there is no driverId attribute. When I check last trip via API (api/trips?deviceId=1....) the driverUniqueId is null.

I think I'm missing something here but I can't find out what it is. Can someone point me in the right direction?

Jan4 years ago

I see what i did wrong, setting a driver is not the same as setting a current driver.

Is there a way to set a current driver? maybe set it on a computed attribute?

Anton Tananaev4 years ago

Yes, you can definitely set it using computed attributes.

Jan4 years ago

Thank you for pointing me in the right direction Anton, I was going completely wrong at it.

fixed it now in app like this:

  • created a computed attribute for driverUniqueId, added this to the device, got ID for this attribute (api/attributes/computed)
  • api/drivers?id=x to populate the list with drivers for this device(id)
  • update the computed attribute to the selected driver from list (api/attributes/computed/ PUT)

This seems to work.