Timestamp in Data To Server

Hi there,

I have a question about the using the %timestamp% Tag in my customer json string. I like to use the timestring but is there a possibility to send this timestamp only 1 time at my json object? I transfer 20 values from modbus master to my mqtt broker and need only one time the timestamp and not includes in every data point!

I checked the manuals but I didn´t found any helpful documents!

Regads

Markus

Greetings,

Could you please confirm the device model you are using?
Also, what firmware version is currently running on the device?

Does the MQTT broker receive a single message containing an array of 20 objects, or 20 separate MQTT messages?

Would grouping the Modbus registers be a suitable option for you? For example, if the register values are continuous (e.g., from 40001 to 40020)

You could also select the format type as a Lua script and create a script to produce the required format. This would be the most efficient method. Please note that troubleshooting and writing scripts is outside the scope of our technical support.

Best Regards,
Justinas

Hi,

I using the RUT241 and RUT956 aswell! Firmware the lastest stable version 7.21.3.

The broker get the message as an object!

Grouping isnt possible yet.

I´m not familiar with Lua script. You have a manuel to get familiar with Lua and how use this at the used devices?

Best Regards,

Markus

Hi, I trying some scripts in my RUT241 but it´s doesn´t works to read values with lua from my modbus client! Is gernerally posible to read modbus values with lua at the RUT241?

But it makes no sense to provide Lua and not supporting reading modbus values from modbus client!

Best Regards

Markus

Hi, I tryed the Lua script in the RUT956 too, but here I couldn´t read modbus values from my modbus client aswell! so whats the problem?

Regards

Markus

Greetings,

Apologies for the delayed response.

I’d like to clarify how the Lua script functions within the Data to Server configuration. When you select Lua as the format type, the script itself does not read or poll values from your Modbus devices. Register polling is still handled natively by the router. The Lua script’s role is just to format the payload.

Here’s how the process works:

  1. The router polls the Modbus registers.
  2. It then passes the collected data as an object to the Lua script via the predefined function handle_format_request(data). You can find this function in the example script that you can download when you select Lua as the format type.
  3. Your Lua script takes that collected data, arranges it into your desired JSON structure and outputs the final string to the MQTT broker.

Best Regards,
Justinas