Update device attribute value when new position record arrives

Victor Butlera year ago

Is this possible to do in Traccar:

  1. Set new device attribute called "Test". Value can be 10, for the example purpose.

  2. New record arrives containing "io12":100

  3. Then use the io12 to update the "Test" device attribute to 100 like:
    io12 ? Test = io12 : null

Can this be done?

Note: I have seen that we can use device attributes in computed attributes but is the other way around possible too?

Cristiana year ago

it should be something like this

https://ibb.co/MBhRbQM
https://ibb.co/MN8mNM7

if the data is not reported you must always add io12 to the attribute copy to keep the last value reported.

Anton Tananaeva year ago

You cannot set device attributes from computed attributes.

Victor Butlera year ago

Thank you both for the feedback!

I think Christian's response is related to computed attributes, not device attributes.

Question 1: If device attributes cannot be set via computed attributes, is there any out of the box way to record the io12 as a separate variable and retrieve it at a later stage?

I thought I can make a custom Alarm/event using computed attributes and retrieve it via events report.
The problem with this approach is that I have to provide start and end dates for the events report. If the window is too narrow the last io12 might be outside. If the window is too large, this will impact performance.

Question 2: Is there any way to search for the last record of a specific event (i.e. deviceOffline) via API without providing start and end dates?

Victor Butlera year ago

Seems like none of that is possible.