TRB141 work around for sending MQTT modbus relay control commands?

I’m looking for a way to control the relay of a TRB141 via MQTT command, where I specifically need the relay to return to its normal state after x seconds - which I also want to provide as variable in the same mqtt message. Is there a way to programatically change what the TRB141 does when it receives the mqtt payload? A script that I can change so that it checks for an extra value in the mqtt payload and sets the relay back to 0/1 after x seconds? Maybe using a python script to listen for the incoming payloads of the MQTT modbus gateway?


As you may know, MQTT operates on a publisher-subscriber basis and doesn’t send commands by default. In this system, a subscriber subscribes to a specific topic and listens for messages, while a publisher publishes messages to the same topic through a broker, facilitating communication between the two.

To implement your desired solution, you’ll need to create a script that listens on a specific MQTT topic. Depending on the received message, the script will execute a command (like a UCI command) to switch a relay and return its state after a certain duration (x seconds).

You can achieve this using ash, bash, or even Python. If you opt for Python, you’ll need to install additional packages using our Python manager and handle MQTT-related dependencies. However, for simplicity, I recommend using ash/bash scripting to minimize complications.

Best regards,


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