I have a lua script for a data to server connector on a TRB256. There’s a division of integer numbers, and after that I’m unable to round the decimals to one or two, I always get “temperature”:25.949999999999999” however I try to accomplish this.
What method would work on TRB256?
Another question: the sales person who’s assigned to our region is blocking access to your technical support, saying we didn’t buy your products directly from you (???). Apparently only your sales can give access to your helpdesk and forward support requests. Is there anyone else we can contact for technical issues, or this bbs is the only form of support you provide?
Regarding the Lua script, could you please clarify which integers or parameters you are dividing in your script? As Lua plugins and scripting go beyond our direct support scope, it would be very helpful if you could share the script you are using so that we and other community members might better understand how you are currently attempting to round the values and possibly suggest improvements.
Regarding access to the HelpDesk: if you purchased Teltonika products through a local distributor, technical assistance should be requested via that distributor, who will then escalate to our support engineers if needed. Could you please confirm whether you are a direct B2B customer or if you obtained the devices through a local distributor?
I’m reading Modbus registers that need to be divided by 1000 and rounded to two decimals. Here’s the rounding I use:
local val = numeric * scale
local rounded_val = round_number(val, 2)
readings[key] = tonumber(string.format("%.2f", rounded_val))
I’m an engineer. I have no idea (and frankly don’t care) where this unit is coming from, but it was designed and produced by Teltonika, not by the webshop we bought it from (most likely). With this support policy, you’re basically forcing engineers to get involved in purchasing (and then get chased on the phone by your arrogant sales manager). In the end, you’ll just push us away from Teltonika and toward other vendors who actually provide decent support. I definitely won’t be recommending your products in the future.
Regarding your Lua script, it’s difficult to fully reproduce the behavior without having the complete plugin code, but at first glance, the issue seems to be related to the use of the tonumber function, which converts the formatted string back into a numeric value, and Lua then restores its internal floating approximation.
Instead, you can leave the value as a string. If your server accepts numeric values in JSON strings, a more reliable approach would look like this:
local val = numeric * scale
local rounded_str = string.format("%.2f", val)
readings[key] = rounded_str -- don't convert back with tonumber
This ensures that the value is formatted consistently to two decimals without rounding drift when transmitted.
Regarding your comments on our support policy, we sincerely apologize for the unpleasant experience you’ve had with our sales process. Could you please confirm whether the device(s) was purchased through a local reseller or distributor? If so, please note that technical assistance is always available through this forum, and when needed, we can also provide help via private communication channels or our customer support hotline.