Could you clarify what variables you are referring to? Could you also share screenshots of the custom templates you have already tried?
In the meantime, here’s a Lua script example that might be useful and demonstrates how to format Modbus responses into JSON:
-- Available variables:
-- data_sender.section - config section name
-- data_sender.version - LUA plugin version
-- env - data to be formatted
--
-- String value must be returned
local json = require("luci.jsonc")
function handle_format_request(data)
local result = {}
result.meterID = data[1]["server_name"]
result.values = {}
for _, modbus_response in pairs(data) do
table.insert(result.values, {
modbus_response["date"],
tonumber(modbus_response["data"]),
})
end
return json.stringify(result)
end