Control RUT241 I/O Output via CLI / Remote API while using the Device

Hello,

I am working with a Teltonika RUT241 and I would like to remotely control the device’s I/O output (turn it ON/OFF) using CLI commands. My use case is the following:

  • The RUT241 will be configured as an OpenVPN client.
  • When needed, I want to remotely trigger the output of the available I/O ports.
  • I need a way to:
    • change/control the output state (ON/OFF),
    • retrieve the current state as feedback.

I am looking for guidance or examples on how to achieve this using:

  • CLI commands, and/or
  • HTTPS / REST API / RPC calls
    to control and monitor the I/O state.

Specifically, I’d appreciate help with:

  • Correct CLI commands or scripts to control I/O output.
  • Whether the built-in API can toggle and read I/O states.

Any recommended secure approach to combine this with OpenVPN for remote access.

If anyone has experience or documentation pointers regarding this setup, that would be very helpful.

Thank you!

Greetings, @mlogothetis,

Welcome to the Teltonika Community!

This functionality can be achieved using both CLI commands and API calls.

Using CLI commands

To check the current output status, you can use the following command:

ubus call ioman.gpio.dout1 status

If the returned value is 0, the pin is low; if the value is 1, the pin is high.

For more information, please refer to this article:

To change the output state, use the following command:

ubus call ioman.gpio.dout1 set '{"value":"1"}'

Using API calls

First, you need to obtain a session-based authentication token by executing the following API call:

curl -k -X POST https://<router_ip>/api/login \
  -H "Content-Type: application/json" \
  -d '{"username":"root","password":"<password>"}'

The response will include a session token, which is then used automatically via cookies or headers.

To read the digital output state, use the following API call:

curl -k https://<router_ip>/api/io/dout1/status

The response should look similar to this:

{
  "value": "0",
  "direction": "out"
}

To change the output state, you can use the following API calls:

Turn ON

curl -k -X POST https://<router_ip>/api/io/dout1/actions/set \
  -H "Content-Type: application/json" \
  -d '{"value":"1"}'

Turn OFF

curl -k -X POST https://<router_ip>/api/io/dout1/actions/set \
  -H "Content-Type: application/json" \
  -d '{"value":"0"}'

For detailed API documentation and available endpoints, please refer to the following link:

Please note that writing custom scripts is outside the scope of our technical support.

If you have any additional questions, feel free to let me know.

Warm regards,
V.

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