Overview

In this section, we’ll use the groov Manage REST API to interact with an analog channel.

Reading the Status of an Analog Channel

The state of an analog channel can be read with the /api/v1/io/{device}/modules/{moduleIndex}/channels/{channelIndex}/analog/status endpoint.

In addition to the groov EPIC processor’s address and the API key, this endpoint also needs the module and channel indexes. They are specified directly in the URL endpoint.

For example, reading channel 0 on module 2, the request is:

curl -k -H apiKey:3KbLb7yZRxnTBP49nEmobDkrpmPkFoBo https://opto-01-02-03/manage/api/v1/io/local/modules/2/channels/0/analog/status

The response looks like:

{
    "modelType": "AnalogChannelRead",
    "moduleIndex": 2,
    "channelIndex": 0,
    "qualityDetail": 0,
    "value": 0.2266998291015625,
    "minValue": 0.007792472839355469,
    "maxValue": 3.6646242141723633
}

Setting an Analog Output’s Value

To set the value of an analog output channel, we need to use the PUT command, specify the content type as JSON, and pass in the value we wish to set.

The PUT command is set with -X PUT.

The Content-Type is set with -H "Content-Type: application/json".

To set the channel’s output value to 4.5, we need to send this JSON object:

{
    "value": 4.5
}

To do that, we use the -d flag and format the object correctly for the command line, like -d "{ \"value\": 4.5}".

Put all together, the request is:

 curl -k -X PUT  -H apiKey:3KbLb7yZRxnTBP49nEmobDkrpmPkFoBo  -H "Content-Type: application/json" https://opto-01-02-03/manage/api/v1/io/local/modules/3/channels/2/analog/value -d "{ \"value\": 4.5}"

This request will not have a response object.

Conclusion

This concludes our Getting Started with groov Manage REST API section.

There’s much more that can be done with it. Please see the online API Reference for more information.