OpenMinder™: API
When the OpenMinder binary is running, an API will be available on the default port 3232.
Readings
GET /v1/readings
Provides readings reported from the hardware
Request Headers
Content-Type: application/json
Request Body
There is no request body for this request
Example Request
curl http://localhost:3232/v1/readings
HTTP/1.1 200 OK
Response Object
{
"irrig_adc": 0,
"irrig_ph_raw": 0,
"irrig_ph": 0,
"runoff_adc": 0,
"runoff_ph_raw": 0,
"runoff_ph": 0,
"irrig_tips": 0,
"irrig_volume": 0,
"runoff_tips": 0,
"runoff_volume": 0,
"irrig_ec": 0,
"irrig_ec_raw": 0,
"irrig_ectemp": 0,
"runoff_ec": 0,
"runoff_ec_raw": 0,
"runoff_ectemp": 0,
"runoff_ratio": 0
}
Response Codes
Code | Description |
---|---|
200 | OK |
500 | Internal Server Error |
Calibrations
GET /v1/calibrations
Shows current calibrations.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl http://localhost:3232/v1/calibrations
HTTP/1.1 200 OK
Response Object
{
"irrig_ec": {
"scale": 0,
"offset": 0
},
"irrig_ph": {
"scale": 0,
"offset": 0
},
"irrig_volume": {
"scale": 5,
"offset": 0
},
"runoff_ec": {
"scale": 0,
"offset": 0
},
"runoff_ph": {
"scale": 0,
"offset": 0
},
"runoff_volume": {
"scale": 0,
"offset": 0
}
}
Response Codes
Code | Description |
---|---|
200 | OK |
PUT /v1/calibrations/:field/:scale/:offset
Sets calibrations for readings reported from the hardware
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl -XPUT http://localhost:3232/v1/readings/calibrate/irrig_tb/5.0/0.0
HTTP/1.1 204 No content
Response Object
There is no response object for this endpoint.
Response Codes
Code | Description |
---|---|
204 | No Content |
400 | Bad Request |
500 | Internal Server Error |
Errors
GET /v1/errors
Shows current errors and how long ago they were last active. This allows one to know about errors without needing to check the log output of the service. The errors are cleared out once they are 10 mins old.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl http://localhost:3232/v1/errors
HTTP/1.1 200 OK
Response Object
{
"can't find calibration constant for irrig_ec": "1m30s",
"can't find calibration constant for irrig_ph": "1m30s"
}
Response Codes
Code | Description |
---|---|
200 | OK |
Config
GET /v1/config
This will simply show the current config loaded by the service and should be the same as the config.json file.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl http://localhost:3232/v1/config
HTTP/1.1 200 OK
Response Object
{
"irrig_tb_gpio": "GPIO5",
"runoff_tb_gpio": "GPIO6",
"port": "3232",
"scan_timeout": 300,
"irrig_ec_probe": "ASLSC15108556",
"runoff_ec_probe": "ASLSC15108111",
"tty": "/dev/ttyUSB0"
}
Response Codes
Code | Description |
---|---|
200 | OK |
Bus
GET /v1/bus
This shows some information about the bus.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl http://localhost:3232/v1/bus
HTTP/1.1 200 OK
Response Object
{
"available": [
"ASLSC15108556",
"ASLSC15108111"
],
"configured": {
"irrig": "ASLSC15108556",
"runoff": "ASLSC15108111"
},
"last_scan_done": null,
"last_scan_start": null
}
Response Codes
Code | Description |
---|---|
200 | OK |
PUT /v1/bus/swap
This swaps the EC probes used for the irrigation side and runoff side. As there isn't really a way to tell which probe is attached to which side in the openminder software (serial numbers are not printed on the probes) then you can remove a probe from liquid causing it to report an EC of zero. You can then correlate it with the API as you will see one of the EC readings go to zero as well.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl -XPUT http://localhost:3232/v1/bus
HTTP/1.1 200 OK
Response Object
{"bus_url": "/v1/bus"}
Response Codes
Code | Description |
---|---|
200 | OK |
PUT /v1/bus/scan
This will cause a scan of the bus to be done, in order to find attached EC probes. As this can
take an unknown amount of time to complete (or fail to complete at all if the scan timeout threshold
is reached) it will return immediately but continue to scan the bus in the background. The /v1/bus
endpoint will show when a scan started and ended, with the available probes.
When this endpoint is called, the current known probes will be cleared and the bus endpoint will show
an empty array under available
until some probes are detected.
Request Headers
Content-Type: application/json
Request Body
{}
Example Request
curl -XPUT http://localhost:3232/v1/bus
HTTP/1.1 202 Accepted
Response Object
{"bus_url": "/v1/bus"}
Response Codes
Code | Description |
---|---|
202 | Accepted |