Trb145 data to server using lua scripts

Hello,

I am trying to figure out how to use lua scripts with the data to server service. Is there an example somewhere on how to use it?

What I am trying to do is to write a lua script that is able to read a value from a modbus RTU unit (for example a digital poweer meter) every 15 seconds and send a POST call or an MQTT data if the last value read differs from the previous value by more than 10%.

Is this feature good for this purpose?

Thanks,

Gabor

Hi, I am working on a similar problem. This is the sample, that could be downloaded from the WebUI. The script can be customized via Visual Studio. However I haven’t tried it yet. Also I don’t know if this specific function has to called at some specific point or if it works on itself.

--Available variabes:
-- data_sender.section - config section name
-- data_sender.version - LUA plugin version
-- env - data to be formated
--
--String value must be returned

function handle_format_request(data)
	local key, value
	local result = ""

	for key, value in pairs(data) do
		result = result .. "\"" .. key .. "\": \"" .. value .. "\","
	end

	return "{" .. result .. "}"
end

Thanks for your reply!

It would be nice if someone from Teltonika would give an answer to my question. Moreover, it would be better if Teltonika would include a full LUA API descritption in its webpages. After all, they claim that the TRB-s can run LUA, but what is the use of it if there is no documentation on how to interact with the system itself…

This topic was automatically closed after 60 days. New replies are no longer allowed.