Keep last computed attributes visible

michalis956 months ago

Hello Traccar,

I would like to use the last value for a computed attribute on display, when the device stops reporting it. For instance, I have the OBD Fuel of a Teltonika FMC003 reported as io390. If the device is online, I can see the value on the dashboard just fine. If the device is offline, the value is lost.

I have enabled processing.computedAttributes.lastAttributes but the code

Io390 ? io390 : lastIo390

does not work. Obviously I am missing something, but I cant wrap my head around what the correct expression has to be

Anton Tananaev6 months ago

The expression doesn't seem to be valid.

michalis956 months ago

I have missed the question mark, but i have put it there now. Nevertheless, I still think the expression is wrong. As a template, given parameter xy can I assume it is

xy ? lastXy
If not, what is the correct template to do this?

michalis956 months ago

Better phrased, keep the last non-null value (therefore ignoring null values)

Anton Tananaev6 months ago

Why not use attribute copying?

michalis956 months ago

Is that the recommended way?

If not this might work:

(io390 != null ? (io390 / 10) : previous(Fuel))

michalis956 months ago

@Anton

How is attribute copying used? After adding

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

to traccar.xml and restarting docker, nothing changes in the web ui to allow for copy attributes with conditions. The GPT model you made suggests i need to add

tracc.png

but this ends up looping my system

Anton Tananaev6 months ago

That's not a valid configuration. Please read the documentation.

michalis956 months ago

That is from the Traccar GPT model you made.

From the documentation :

tracc.png

Which tells me

<entry key='processing.copyAttributes.enable'>true</entry>
<entry key='processing.copyAttributes'>io390,io389</entry>

etc. This is it? The above lines retain the value for io390 and 389 when the device does not send it?

Anton Tananaev6 months ago

Have you tried?