Computed Attributes issues after update

RastreameMX2 months ago

Hi good day.

Yesterday we have updated from Traccar version 5.8 to Traccar 6.4 because since august 20 some devices started to disconnect constantly and freeze apparently because an deprecation on Firebase notification functions. (i think it was fixed from 6.3 to 6.4?)

After update to 6.4 disconnections have fixed, but now we are experiencing troubles with computed attributes that were working fine before update.

We use these settings on traccar.xml :

<entry key='processing.copyAttributes.enable'>true</entry>
<entry key='processing.copyAttributes'>io6,io9,io72,io73,io239,status,blocked,batteryLevel</entry>

<!-- Pruebas atributos calculados de bloqueo de motor -->
<entry key='processing.computedAttributes.localVariables'>true</entry>
<!-- Pruebas atributos calculados en base a dispositivo -->
<entry key='processing.computedAttributes.deviceAttributes'>true</entry>
...

First issue we are experiencing is this on logs :

2024-09-06 11:53:50  WARN: Attribute computation error - org.traccar.handler.ComputedAttributesHandler.computeAttribute:138@1:18 variable 'status' is undefined - Variable (ComputedAttributesHandler:139 < *:150 < ProcessingHandler:173 < MotionHandler:41 < ProcessingHandler:173 < ...)

It appears that copyAttributes is not appying on some cases.

On logs shows this too :

2024-09-06 11:53:45  WARN: Attribute computation error - org.traccar.handler.ComputedAttributesHandler.computeAttribute:138@3:25 variable 'io9' is undefined - Variable (ComputedAttributesHandler:139 < *:150 < ProcessingHandler:173 < MotionHandler:41 < ProcessingHandler:173 < ...)

But when we look into attributes received, io9 appears, but seems like if when computed attributes were calculated, io9 wasn't set. Maybe attributes are being copied after computation of attributes?

Device is teltonika, it reports on binary data, so i cannot decode data to see if attribute was present when computation were done, or it was copied after that.

When i test my computed attribute, it works as expected.

Thank you.

Anton Tananaev2 months ago

Copy attributes is now done after computed attributes.

RastreameMX2 months ago

Thanks for adding highlights to my post, i forgot it, and thank you for your always fast answer.

There is a manner we can configure copy attributes before calculation? This because some devices (like teltonika) sometimes doesn't report elemental attributes we need on calculations on last position received (position that is shown to user most time).

Thank you.

Anton Tananaev2 months ago

You can copy it using another computed attribute using higher priority.

RastreameMX2 months ago

Great, i didn't consider that.

So do you mean to use a Computed attribute that tests if attribute is set, and if it is not, then copy it using last{attribute} to generate it?

Thank you.

RastreameMX2 months ago

Hi again.

I've solved problem doing this on computed attributes :

var io9c = io9 ? io9 : lastIo9;

and using my new var io9c {comprobed} on my calculations.

But, now im facing new issue i didn't noted before :
Since yesterday 17 hrs (when i made traccar update) io attributes are frozen. I mean, it seems like traccar just have copied them from the last one, not considering if positions contains a new value or not.

Screen capture yesterday

Can somebody give me a clue why could be this happening? Just to clarify : I don't have any computed attribute called "io9", that's directly the name of attribute i get on positions. So io9 is not being 'rewrited' by computed attributes.

Anton Tananaev2 months ago

What computed attributes do you have?

RastreameMX2 months ago

Computed attributes assigned to that device are : TanqueL, TanqueR, capacidad, and fuel . The one that works with io9 data is this :
TanqueL
number

var io9c = io9 ? io9 : lastIo9; var tanqueDiametro = TanqueDiametro1; var tanqueLong = TanqueLongitud1; var cn = tanqueDiametro*io9c/5000; var aseg1 = tanqueDiametro/2*tanqueDiametro/2*math:acos((tanqueDiametro/2-cn)/(tanqueDiametro/2)); var atria1 = ((tanqueDiametro/2)-cn)*math:sqrt((tanqueDiametro/2*tanqueDiametro/2)-(((tanqueDiametro/2)-cn)*((tanqueDiametro/2)-cn))); var TanqueL = (aseg1-atria1)*tanqueLong*1000; SensorCombustible ? TanqueL : 0

Fuel is similar, but it calculates both TanqueL and TanqueR and makes a sum of both.

Now i've make another test, disabling copy of io9 on traccar.xml and now io9 is not being received, not appears at all (and computed attributes that requires it doesn't appear too, as expected). But strange thing it's because before yesterday update, it was working fine. We didn't changed any configuration on device.

As i said before, i cannot see raw content of position received on server because is a binary frame, but it should be reporting io9 attribute. When i request parameter configuration on device, is configured correctly.

Will do some more tests and i'll update.

Thank you

RastreameMX2 months ago

Update :
I've set secondary mirror server (Traccar 6.2) and there i'm receiving io6 and io9 correctly. Same settings on both about computed attributes, right now as this :

        <!-- Necesaria para que Teltonika no aparezca fuera de linea entre reportes-->
    <entry key='status.ignoreOffline'>teltonika</entry>
    <entry key='processing.copyAttributes.enable'>true</entry>
    <entry key='processing.copyAttributes'>io6,io72,io73,io239,status,blocked,batteryLevel</entry>

        <!-- Pruebas atributos calculados de bloqueo de motor -->
    <entry key='processing.computedAttributes.localVariables'>true</entry>

        <!-- Pruebas atributos calculados en base a dispositivo -->
    <entry key='processing.computedAttributes.deviceAttributes'>true</entry>

        <!-- Pruebas atributos calculados que no encuentra io's -->
    <entry key='processing.computedAttributes.lastAttributes'>true</entry>

io9 was deleted from processing.copyAttributes. On server 1 (traccar 6.4 updated from 5.8) io9 dissapeared at all, io6 shows as expected. On server 2 io6 and io9 are showing as expected.

Anton Tananaev2 months ago

My guess is that you have some other computed attributes that remove the value.

RastreameMX2 months ago

It seems like that, going to do more tests.

Is there another way to remove an attribute, other than create new computed attribute called like the attribute to delete, and putting null on expression? Something like into another expression :

io9 = null;
{more expressions}

I'll make some tests and update...

Anton Tananaev2 months ago

Returning null will remove the attribute.

RastreameMX2 months ago

Thank you for your help.

I've copied and assigned exactly same attributes on both servers, and same issue. Server 2 shows all attributes as expected. Server 1 shows only attributes that doesn't use io9, and io9 doesn't appear. Same device, same traccar.xml, just different version.

server2 screenshot

server1 screenshot

RastreameMX2 months ago

UPDATE :
I've installed new VPS with clean Traccar 6.4. Restored SQL from my previous instance of traccar 5.8 before update to 6.4.
I've disconnected all computed attributes from device on new instance, and still receiving only io6 not io9.

I've turned to 'false' on "copyAttributes", restarted Traccar 6.4, and still not showing io9, just io6.

I've changed ID on device listed, and created new device (same physical device), and now it receives correctly attributes io6 and io9. For me, seems that there is something on old positions stored that makes traccar to expect new data about io9 as null.

I'm going to look into traccar code if i can find some weird on position storage procedure or copyAttributes, or something like that.

I'll update later.

Anton Tananaev2 months ago

Did you have model name set on the old device?