It should not be a string in the first place. Why is it not a number?
You mean like this?io331 ? ( io331 & 0x00000001 ) == 0 ? 0 : 1 : null
No, I'm talking about the attribute io331
.
It's a hex value - it seems to work when the value is represented by numbers (eg 0044) but not when it isn't (eg 001b)
But it should not be a string in the first place. It should be an integer.
Ok, so is it a bug then?
The Teltonika spec from here: https://wiki.teltonika-gps.com/view/FMB_AVL_ID
Property ID In AVL Packet Property Name Bytes Type Value Range Multiplier Units Description HW Support Parameter Group
331 BLE Sensor 1 Variable HEX 0 256 - - Raw data of BLE sensor Devices: [Expand] Permanent I/O elements
I see. Looks like it's raw HEX data. You should parse it first and convert into an integer. Something like Integer.parseInt(io331, 16)
.
Perfect, thank you I'll give it a go.
I did suspect it would be something like that, but it's trying to search for the right thing... I was looking for cast.
Will try the above and report back.
Thanks again
this errors...
org.traccar.handler.ComputedAttributesHandler.computeAttribute@102![16,35]: 'io331? (Integer.parseInt(io331, 16) & 0x00000001) == 0? 0 : 1 : null;' attempting to call method on null - JexlException (... < ComputedAttributesHandler:102 < AttributeResource:57 < ...)
Got it sorted in the end here's the final computed attribute:
io331 ? ( new("java.lang.Integer", 0).parseInt(io331, 16) & 0x00000001 ) == 0 ? "open" : "closed" : null
http://localhost:8082/api/reports/summary?type=allEvents&page=1&start=0&limit=25&from=2021-03-08T19:00:00.000Z&to=2021-03-09T19:00:00.000Z&deviceId=52,49,44&daily=false
return For input string: "52,49,44" - NumberFormatException (...)
Sharipov you are completely off-topic here.
Hi,
I'm trying to use a computed attribute to display the status of of a BLE sensor for a teltonika FMB device. Most of the time this works, but I am getting periods where it errors.
The teltonika spec says:
So in short, the last (lsb) bit is what shows the status of the sensor.
I figured that I should be able to achieve this with the following computed attribute (spaces added for clarity):
Most of the time this works fine, but it seems that when the counter gets to a certain point I get the following error:
If I and
001b
&00000001
I get 1, which is what I would expect as the sensor is closed, but this seems to error (as above)Any suggestions would be appreciated.