When are computed attributes calculated?

Thiritin3 years ago

Hey, I'm trying to set an alarm status if the device is offline for 4 hours.

if(deviceTime.toInstant().plusSeconds(14400) < serverTime.toInstant().now()) {
return "powerOff";
}

This is my code, it correctly validates. My fear is that computed attributes are validated when the device reports it's status to the Server. Is that true? Perhaps someone knows a different solution.

TL;DR
Trigger alarm/Notification when Device is offline for 4 Hours. Some trackers have some connectivity issues and shouldn't immediately trigger an offline event.

Anton Tananaev3 years ago

Computed attributes are calculated for every position, which means it happens when device reports something useful.

But what you are trying to implement is already available out of the box. Traccar already has an event for when device hasn't reported anything for selected amount of time.

Thiritin3 years ago

Hi Anton, sadly I couldn't find this under notification. Could you clarify where I can find this event? Is it a notification?

Anton Tananaev3 years ago

It's called "Device inactive". What version are you using?

Thiritin3 years ago

I found Device inactive in the notifications menu, but no option to define a timeframe. I am using the latest 4.13 version :-)

Anton Tananaev3 years ago

The options are in the device attributes.