You can try using computed attributes, but you would need a formula for that.
So I setup a computed attribute and seems to be working fine. I try using an array, JSON object, JSON Array, and such... but the result was NaN. I am not very familiar with JEXL syntax. I will try some more experiments and learn more hopefully...
So I am just using an if / else if statement. The result works so that is fine.
// Omnicomm LLS 30160
// Maximum reading 1...4095
// Minimum reading 0...1023
// Conversion into Litre
if (lls_lvl_add1 < 1) {
lls_lvl_add1 = 0;
} else if ((lls_lvl_add1 >= 1) && (lls_lvl_add1 < 1200)) {
lls_lvl_add1 = (0.0992493744787 * lls_lvl_add1) + -0.0992493744787;
} else if ((lls_lvl_add1 >= 1200) && (lls_lvl_add1 < 1722)) {
lls_lvl_add1 = (0.1743295019160 * lls_lvl_add1) + -90.1954022989000;
} else if ((lls_lvl_add1 >= 1722) && (lls_lvl_add1 < 2222)) {
lls_lvl_add1 = (0.1620000000000 * lls_lvl_add1) + -68.9639999999999;
} else if ((lls_lvl_add1 >= 2222) && (lls_lvl_add1 < 4070)) {
lls_lvl_add1 = (0.1563852813850 * lls_lvl_add1) + -56.4880952381000;
} else if ((lls_lvl_add1 >= 4070) && (lls_lvl_add1 <= 4095)) {
lls_lvl_add1 = 580.00;
}
The only thing I want to verify is this: Computed Attributes change data saved to the database? I had thought that Computed Attributes were just a front end, no actual changes made to database. Only values that are displayed.
No Computed Attribute::
# id protocol deviceid servertime devicetime fixtime valid latitude longitude altitude speed course address attributes accuracy network
17860 teltonikafmb6 1 2019-08-12 09:35:47 2019-08-12 09:35:38 2019-08-12 09:35:38 1 35.7388516 -5.8476883 61 0 200 Tanger طنجة, MA {"priority":0,"sat":15,"event":0,"io71":3,"io21":5,"io178":1,"ignition":false,"lls_temp_add1":32,"pdop":1.2000000000000002,"hdop":0.6000000000000001,"lls_lvl_add1":2486,"distance":0.0,"totalDistance":5.9860421614E8,"motion":false,"hours":94242950} 0 null
"lls_lvl_add1":2486
With Computed Attribute::
# id protocol deviceid servertime devicetime fixtime valid latitude longitude altitude speed course address attributes accuracy network
18958 teltonikafmb6 1 2019-08-17 13:03:57 2019-08-17 13:03:48 2019-08-17 13:03:48 1 35.7389383 -5.8479333 109 0 349 Tanger طنجة, MA {"priority":0,"sat":17,"event":0,"io71":3,"io21":5,"io178":1,"ignition":false,"lls_temp_add1":37,"pdop":1.0,"hdop":0.6000000000000001,"lls_lvl_add1":"334.63151629000004","distance":0.0,"totalDistance":5.9861197244E8,"motion":false,"hours":94242950} 0 null
"lls_lvl_add1":"334.63151629000004"
I suspect the Fuel usage might not be calculated, I am assuming that the fuel usage is taken from Position.KEY_FUEL_LEVEL "fuel"... So perhaps another Computed Attributte to do a sum of all LLS Sensors = "fuel"... Or just a simple
fuel = lls_lvl_add1
I will watch and see what happens... :-)
Hi Najmuddin, I'm planning to use Traccar with Omnicomm sensors can you please share with me your results?
Good day,
First I would like to say Traccar is a wonderful platform and has a strong community and following.
I have recently came across an issue with Omnicomm LLS Sensors (I have more than 30 of these Omnicomm LLS 30160 Fuel sensors)...
Traccar is reading the value but it is the RAW value.
I admit my understanding of the Java language is... Well I am an old computer guy and I predate Java - hahaha back in the days when it was new language and the question was if it would succeed or fail... Anyhow...
I reading from this site:: Calculation Table
It is documenting what I am writing about.
here is one of my tables for a Omnicomm LLS 30160::
var sensorsData = JSON.parse('{"sensors":[{"sensor":"lls_lvl_add1","tbl":[{"a":0,"b":0,"x":0},{"a":0.0992493744787,"b":-0.0992493744787,"x":1},{"a":0.174329501916,"b":-90.1954022989,"x":1200},{"a":0.162,"b":-68.964,"x":1722},{"a":0.156385281385,"b":-56.4880952381,"x":2222},{"a":0,"b":580,"x":4070},{"a":0,"b":580,"x":4072},{"a":0,"b":580,"x":4094}]},{"sensor":"lls_lvl_add2","tbl":[{"a":0,"b":0,"x":0}]},{"sensor":"lls_lvl_add3","tbl":[{"a":0,"b":0,"x":0}]},{"sensor":"lls_lvl_add4","tbl":[{"a":0,"b":0,"x":0}]},{"sensor":"lls_lvl_add5","tbl":[{"a":0,"b":0,"x":0}]},{"sensor":"lls_lvl_add6","tbl":[{"a":0,"b":0,"x":0}]}]}') var sensorName = 'lls_lvl_add1'; var SensorValue = 2495; var Fuel = 0.0; for (sensorIndex = 0; sensorIndex < sensorsData['sensors'].length; sensorIndex++) { if (sensorsData['sensors'][sensorIndex]['sensor'] == sensorName) { console.log(sensorsData['sensors'][sensorIndex]['sensor']) for (tableIndex = 0; tableIndex < sensorsData['sensors'][sensorIndex]['tbl'].length-1; tableIndex++) { if ((SensorValue >= sensorsData['sensors'][sensorIndex]['tbl'][tableIndex]['x']) && (SensorValue < sensorsData['sensors'][sensorIndex]['tbl'][tableIndex+1]['x'])) { Fuel = (sensorsData['sensors'][sensorIndex]['tbl'][tableIndex]['a'] * SensorValue) + sensorsData['sensors'][sensorIndex]['tbl'][tableIndex]['b']; Fuel = Fuel.toLocaleString('fr', { minimumFractionDigits:2, maximumFractionDigits: 2 }) break; } } } }
A sample value displayed by Traccar:: 2456 (referred to as X value)
I am working on trying to add calculation table, but my knowledge of Java is novice...
I put together a small program in windows to connect to the server and translate it... But I would prefer to also have the web interfase show the correct value.
Is there any possibility of this being added in a future release of Traccar?
Perhaps a dialog under [Device Menu] >> [Calculation Table]
Please and thank you :-)