Api command to read and write gpio din1 and dout1

I learned here ubus call will replaced with the api.

Can you give me an example in api for:

ubus call ioman.gpio.dout1 update '{"value":"1"}'
ubus call ioman.gpio.dout1 status | grep -q "Low level"

and

ubus call ioman.gpio.din1 status | grep -q "Low level"

Hello,

To read the digital output value and get an integer output, you can use the following command:

/sbin/api GET /io/dout1/status | jsonfilter -e '@.http_body.data.value'

dout1 can be replaced with din1 to get the status of the digital input.
To enable the digital output:

api POST /io/dout1/actions/change_state '{"data":{"value":"1"}}'

And to disable:

api POST /io/dout1/actions/change_state '{"data":{"value":"0"}}'

In case anyone found this post first, I’d like to remind that the API is still in beta and is subject to change in the later releases.

Best regards,

1 Like

This is a big problem for business development.
How can we create now scripts and be sure it is still working in the future?

There are a few steps that our RnD took to ensure future compatibility:

  • Even when v2 of our API comes out, v1 will still work until the release of v3. This means that you will have time to apply any changes, if they will be needed.

  • For now, API is not replacing any major commands (like UBUS GPIO commands) as a lot of users are still using them.

  • UCI commands, which can also be used to change configuration, will still remain in place.

However, I’d suggest migrating to the API, as it will be universal across all families of devices, which will ensure compatibility within the entire fleet. It will also provide possibility to configure the devices remotely using the same API calls (although authentication will be needed).
Hope this resolves any concerns, and if any other advice regarding API is needed, feel free to ask, or check out the tutorials or examples prepared by our RnD team.

Best regards,

1 Like

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