Attribute computation error - Customised copy of master

Joystick7 months ago

On a customised copy of latest master I receive the below error almost in every message.

WARN: Attribute computation error - org.traccar.handler.ComputedAttributesHandler.computeAttribute:151@1:42 variable 'hours' is undefined - Variable (ComputedAttributesHandler:152 < *:178 < ProcessingHandler:161 < MotionHandler:41 < ...)

I have no computed attribute with "hours" included linked to any of the devices or groups.
I also checked replays for some of the devices that flagged the warning and "hours" was present at all times.
I also made sure user "admin" have all computed attributes linked to the user account.

Where else can I possibly check for the reason?
If anyone else experience the same issue and can give me some pointers on other areas to check please assist.

Anton Tananaev7 months ago

We changed the order of some handlers and hours are now calculated after computed attributes.

Joystick7 months ago

Thanks for the response Anton, I just realised I have computed attributes that makes use of hours but it seems like they are not woking anymore after the order was changed.
How will I overcome this?

Anton Tananaev7 months ago

There was already a thread about it recently. Try searching.

Joystick7 months ago

I did a search and also look at the forums often.
Only one I found is https://www.traccar.org/forums/topic/enginehours-not-calculation-after-installing-v61/page/2/
My engine hours are calculating correctly event after the order was changed and I don't have hours or ignition in attributes copying.
I have a computed attribute that calculates average fuel used per km and also per hour that does not seem to work anymore.

hours?10000000-(((totalDistance*0.09)/1000)+((hours)/3600000)):null

Apologies if I have missed a thread

Anton Tananaev7 months ago

Sounds like you have an opposite problem. What version are you using?

Joystick7 months ago

Latest master with some customisation.
All worked fine until the order was changed, and I started to get the variable 'hours' is undefined error.
That's the time the computed attribute stopped working as well looking at reports.

Anton Tananaev7 months ago

That makes sense. The order changed, so your old code doesn't work.

Joystick7 months ago

So one cannot reference hours in the computed attributes anymore?
I.E. testing it I create a computed attribute:
Attribute: test
Expression: hours?1:null
Type: number

If I test it within the computed attributes page it return a 1, but returns nothing after linking it to devices or groups and I get variable 'hours' is undefined error.

Anton Tananaev7 months ago

Yes, but you could calculate the value yourself.

Joystick7 months ago

Not working for me.
My devices sends io449 (Teltonika Ignition Hours) in every message.
Testing it in the Computed Attribute it returns 311, but using below it returns 0
Attribute: Hours
Expression: io449?io449:null
Type: number

Am I doing it wrong here?

Anton Tananaev7 months ago

Does your device actually send it? Check more details screen.

Joystick7 months ago

It does,

IMG_4958.jpeg

Anton Tananaev7 months ago

Looks like you already customized something there.

Joystick7 months ago

Message from log attached,

00000000000000ac8e010000018fc2578e080058b962f3f1d0b29700fb00c9090018012f001b000700ef0100f001001503004501012f01005119005208000b00b5001000b6000a004236510018001800430f7100440000000f03e80054023f00550491005a000000730352000600c7000000000010aa47983901c10011257300530002e69800570a262500006400002b820003000b00000002161e48900065a42f8ee77c92d0ae000e00000000ba36b89600000100007810

Photo attached of messaged parsed,
io449 in seconds

Screenshot by Snip My on 29 May 2024 at 1.28.45 PM.png