You should be able to do something like that using computed attributes.
Hello Anton.
I have tried to add the following code in computed attributes but still not work.. unless there's another place in I need to adjust also , kindly advise..
Tracking device I use is Telktonika fmb140
var ign = attributes.get('io_239');
var lastIgn = device.getAttribute('lastIgn');
var count = device.getAttribute('counter');
var newCount;
if (ign == true || ign == 'true' || ign == 1) {
if (lastIgn == null || lastIgn == false || lastIgn == 'false') {
newCount = 1;
} else {
newCount = (count != null ? count : 0) + 1;
}
} else {
newCount = 0;
}
device.setAttribute('lastIgn', ign);
device.setAttribute('counter', newCount);
newCount
This code is definitely invalid. Where did you get it from?
Hello
Anton
The code I get from the internet, can I have the correct one from your side so that I can achieve what I want ?. Because every code I get from internet I tried to modify it to make a logic but nothing works.
Please provide a link where you found it and any other ones you tried.
Ooh sorry Anton, from internet I was referring DeepSeek and Whatsapp ChatGpt.. they support only copy and paste they can not provide links
Hello Team,
I am exploring if Traccar has the capability to reset a sequential record counter based on a specific event trigger.(In my case is ignition state).
My use case is as follows:
· I have a custom attribute (io_239) that reports the vehicle's ignition status.
· I would like a record counter to reset to 1 each time a new ignition-on event is received (i.e., when io_239 is true or 1).
· Following the reset, the counter should then increment with each subsequent record until the next ignition-on event is detected, at which point it would reset to 1 again.
Any one with idea on how to achieve this