RUT956 - Send "Startup system" by MQTT after reboot

Hello,

What would be the correct way to send a “Startup system” message via MQTT after a reboot.

Thank you in advance for your support.

Hello,

Thank you for reaching out.

I understand that you would like to receive an MQTT message when the device reboots. Teltonika devices operate with predefined MQTT parameters, meaning only specific parameters outlined in our wiki can be published. Unfortunately, it is not possible to send a custom startup message directly with MQTT.

However, since MQTT operates with predefined parameters, you can determine when the system has restarted by sending the device’s serial number along with its uptime. If the reported uptime is low, this would indicate a recent reboot. While you can send MQTT messages through the WebUI, there is no built-in option to do it automatically, specifically on every reboot, so achieving this would require a custom script. You can define the Startup script by navigating to System > Custom Scripts.

Please take a look at our wiki regarding MQTT:
RUT956 MQTT - Teltonika Networks Wiki
You can find MQTT parameters here:
Monitoring via MQTT - Teltonika Networks Wiki

Could you clarify the specific MQTT messages you would like to send? With more details, we may be able to suggest a suitable workaround.

Additionally, I recommend exploring the Events Reporting feature. This allows you to receive an SMS or email notification when the device restarts. To configure this, navigate to Services > Events Reporting, click Add, set the event type to Reboot, and choose an action such as Send Email or Send SMS. You can also customize the notification message using text and predefined variables, such as the timestamp.

For more information about Events reporting please visit: RUT956 Events Reporting - Teltonika Networks Wiki

Please let me know if you need further assistance.

Best regards,
Kacper

Hi Kacper,

Thank you for your answer.

I think the best way for me is to use “Custom scripts” like “Startup script”.
Example / MQTT Message : {“Code” : 400, “DateTime” : “2025-01-31T08:42:53”}

Did you have a example to write a good script for the RUT product?

Thank you in advance for your support.

Best regards.
Cidrick

Hello,

I hope you are doing well.

We have a few script examples available on our wiki that may prove helpful for your needs. You can explore these examples through the following link: User Scripts Examples - Teltonika Networks Wiki.

Additionally, I encourage you to review the section dedicated to custom scripts on our wiki: RUT956 Custom Scripts - Teltonika Networks Wiki.

If you have any further questions or need additional assistance, please do not hesitate to reach out.

Best regards,
Kacper

Hello Kacper,

Thank you for your message with the “Wiki” link.
However, the link offered is for sending an HTTP message.

Do you have the same type of “Wiki” link to run a script for an MQTT message send?

Nota : I would only like to send an MQTT message with the date and time informations with a small text when “rebooting” the router.

Thank you in advance for your support.

Best regards
Cidrick

Hello,

I hope you are doing well.

While we do not have a wiki example with an MQTT script, I can suggest an alternative approach using Modbus Alarms. The idea is to monitor a register containing the device’s uptime value, and if it is less than 180 seconds (indicating the device has been running for a maximum of 180 seconds), an MQTT message will be triggered.

To configure this setup, please follow these steps:

  1. Enable Modbus TCP Server:
  1. Configure Modbus TCP Client:
  • Go to Services > Modbus > Modbus TCP Client and click Add.
  • Set up the RUT device as a TCP Modbus client:
  1. Configure Modbus Alarm:
  • Scroll down to the Alarms section and click Add.

  • Enable the alarm and configure the following parameters:

    • Function code: Read Holding Registers
    • First register number: 3 (this register stores the uptime in seconds)
    • Condition: Less than
    • Value: 180 (uptime in seconds)
    • Action frequency: First trigger
    • Action: MQTT message
  • In the JSON format, define your MQTT message, for example:

    • "%rn started up at %ts"
    • This will translate to: {Router name} started up at {Local time}.
  1. Set MQTT Message Parameters:
  • Hostname: Specify the receiver of the MQTT message (e.g., a Windows PC with IP 192.168.1.113).
  • Keepalive: 60
  • Topic: “startup”
  1. Enable and Apply Changes:
  • Enable the Modbus TCP device, save the configuration, and apply the settings.
  • Restart the device to test the solution.

For testing, I used a Windows PC as the MQTT subscriber with the following command:

mosquitto_sub -h 192.168.1.113 -p 1883 -t startup

image

After restarting the device, I successfully received the MQTT message.

Please let me know if you have any further questions.

Best regards,
Kacper

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