I want to send the device name, but instead the product code is sent.
Hello,
Could you kindly confirm which firmware version is currently installed on your RUT241?
Best regards,
It’s RUT2M_R_00.07.18.3
Greetings, gguns,
Thank you for your question.
I have removed a couple of screenshots that you posted, because it contained personal information. Next time, please refrain from posting personal details, such as public IP addresses or serial numbers.
The Data to Server feature uses the “mnf_info” command, for example “mnf_info -n” returns the device name linked to the product code, so this is working as designed.
For your use case, you can use our API to retrieve these values more directly. The endpoint you’re looking for is “GET /system/device/status”. The documentation provides details on all available options and parameters:
I hope this helps, and if you need further guidance, feel free to reach out.
Kind regards,
V.
Do I need to write a LUA script in order to use the API? I’m not familiar with LUA scripts yet.
I want to send the device name to our MQTT server
Greetings, gguns,
Thank you for your message.
You don’t need to rely on LUA for this task—any custom script that can perform an API call will work. Just keep in mind that writing custom scripts falls outside our official support scope, but you are free to implement your own solution.
Once your script is prepared, you can run it automatically in two ways:
- On boot: place it in the custom script section so it executes when the device starts.
- On a schedule: add it to crontab to run at specific intervals.
You can find more details about creating and managing custom scripts here:
And for automating execution with crontab, please refer to:
I hope this points you in the right direction. If you have any other questions, feel free to let me know.
Kind regards,
V.
Greetings Vilius,
I still don’t really see how a custom script or a cron job will do what I want to do.
I use Data to Server to send information to our MQTT broker. I would like to include the device name because that’s the field that we use to give the device a unique name (eg. our own serial number or machine identifier).
Do you mean that I should not use Data to server, but write my own script with API calls to get all the information I need and send it to our MQTT broker?
Kind regards,
G.
Hello,
Thank you for your follow-up.
I’d like to clarify that the suggestion to use a custom script with a crontab was offered as an alternative to the Data to Server feature. This approach allows automation of data collection and sending even if you prefer not to use the built-in Data to Server functionality. I apologize if this caused any confusion.
Using Lua script you can extract the needed information (in your case device name) directly within the Data to Server configuration. Here’s how to set it up:
- In Input Data, choose Type: Lua script.
- Add a
.luafile in the Lua script section and select JSON as the format type.
Please note that you can download a .lua file example directly from the WebUI and simply replace its contents with the script I provided. This script will collect the device name and serial number of your device.
function handle_data_request()
local result = {}
-- Read devicename from /etc/config/system
local devicename = "unknown"
local f = io.open("/etc/config/system", "r")
if f then
for line in f:lines() do
local name = line:match("^%s*option%s+devicename%s+'(.-)'")
if name then
devicename = name
break
end
end
f:close()
end
-- Read serial number using mnf_info
local sn
local h = io.popen("mnf_info -s 2>/dev/null")
if h then
sn = h:read("*l")
h:close()
end
result["devicename"] = devicename
result["serial_number"] = sn or "unknown"
return result
end
- Ensure your collection configuration and MQTT settings are correctly set. Enable the collection, then click Save & Apply. Once applied, the device should send the device name and serial number to your MQTT server.
Please let me know how it goes or if you need any additional guidance.
Kind regards,
V.
I tried the Lua script and it works like a charm ![]()
This topic was automatically closed after 60 days. New replies are no longer allowed.

