Server device id, given during device registration

rise4 years ago

Good Day, thank you for your job. This product very very good.

New device, during first connection to server, sends json to http://traccar:8082/api/devices/:

{
  "uniqueId": "84:0D:8E:8A:7F:EC",
  "name": "esp8266-iotm",
  "model": "240"
}

Its working well for me. After receiving this json, server will reply:

{
  "id": 1542,
  "attributes": {},
  "groupId": 0,
  "name": "esp8266-iotm",
  "uniqueId": "84:0D:8E:8A:7F:EC",
  "status": "offline",
  "lastUpdate": null,
  "positionId": 0,
  "geofenceIds": [],
  "phone": null,
  "model": "240",
  "contact": null,
  "category": null,
  "disabled": false
}

As you see first parametr in reply json is id.

After this, if you need update device information in device list or delete device needed to use this id again. For examle if i want to update information i need to send json http://traccar:8082/api/devices/{uniqueId}/:

{
  "id":1542,
  "uniqueId": "84:0D:8E:8A:7F:EC",
  "name": "esp8266-iotm",
  "model": "240"
}

Id in new, updated device, json shold be execly the same with id wich was given by server during device registration.

In this case i need to save this id, and keep saved in remoute device, to have any time acsess to deleting device from list or updating device list functions.

Sometimes keeping this id in memory of remote device very difficult.

Are you have any other way of editing list of device from remote device without using of id? For example only by using uniqueId. I tryed to send json without id and server reject my request.

Thank you so mach. Dmitry Borisenko.

Anton Tananaev4 years ago

No other way. You always have to use internal device id.

By the way, this is incorrect: http://traccar:8082/api/devices/{uniqueId}/.

rise4 years ago

Sorry, please show me correct way. But i using now this and it fully working for me! All json above working for me fully...

Anton Tananaev4 years ago

Instead of uniqueId you should be using id.

rise4 years ago

Ok thank you for information. I will change request url end to id. (http://traccar:8082/api/devices/{id}/) And in json i should also keep id? Or it is not mandatory?

Anton Tananaev4 years ago

In JSON you have to have both.

rise4 years ago

I have suggestion. I would like to ask you to make the device list fields dynamic as well. So that when a new field is sent, it appears immediately in the list of devices. The system will be more flexible. Now you have dynamic fields only in another list, in the list of device parameters. Sometimes it is necessary to sort devices according to certain specific parameters. If the list of devices is dynamic and the user can add his own fields to it by direct request from the device, then this will solve many problems. Sorry and thank you.

Anton Tananaev4 years ago

This is not the right place to put feature suggestions. Also, you would have to be more specific with use cases.

rise4 years ago

Case of using traccar for monitoring your iot devices for example. Any case where you need to sort items in list according to certain specific parameters. Any way great thanks for this best solution!