Device updates through the API don't appear un the web interface unless it's reloaded

Armstrong7 years ago

Hello,

Title says it all:

  • I can update a device (name, category, ...) through the API, but
  • Those changes do not appear in the web interface unless the page is reloaded

Aren't updates supposed to go through the websocket ? I thought it'd be the case, seems it's not ?

Anton Tananaev7 years ago

No, it's not the case. Only location data and events are pushed via WebSocket.

Armstrong7 years ago

Looking at traccar/api/AsyncSocket.java, devices' data is sent via WebSocket (to initialize the Devices store in the web application),
so updating a device should not be difficult ? Or is it ?

If one changes eg. the name of the device, or the category via the API, one expects to have those modifications reflected on the web-side (especially since it's WebSocket, there should be no need to reload the application). Or is there a reason for keeping devices out of sync ?

Is this feature planned in the future ?

Any pointers to the relevant parts of the code would be appreciated

Thanks,

Anton Tananaev7 years ago

It's definitely possible. Not sure how much effort it is. I don't recall many requests for this feature, so there is no plan to implement it at this point.

Armstrong7 years ago

Ok, say I want for example to update the device name and marker depending on the category, to give a try.
What are the files or functions that would need changes (so I can start at good places) ?
Code is not that documented..

maxw3ll6 years ago

+1
Please send new devices on the websocket

Armstrong6 years ago

@Anton can you pretty please give us some hints about where to look ?

Everyone is wondering why any change done via the API is not pushed to the clients (Web interface in this case)

https://en.m.wikipedia.org/wiki/Principle_of_least_astonishment

If one does a change through the API, THEN it MUST be propagated everywhere, or there is no point

Or rename this as a write-only API ?

That's a considerable lose in interest for this great product for many people

Anton Tananaev6 years ago

Just look at how device status updates are implemented and do the same for other models.

Armstrong6 years ago

At least one filename would be a good start ?

Thanks

https://www.openhub.net/p/traccar/factoids#FactoidCommentsLow

Anton Tananaev6 years ago

File name for what? There are many classes involved. You can start with Device model class and see where and how it's used. It should lead you to the right places.

Armstrong6 years ago

OK

Luc VDN2 months ago

Hi @Armstrong and @maww3ll, 6 years later I need the same thing :)

If I open 2 web clients, when I change the name or the category of a device, it's not updated on the second web client.

Did you find a way and could you explain it to me ?

Thank you :)