Used to control raspberry pi GPIO pins via API.
1.3K
Please visit https://github.com/randysimpson/pi-relay
Start the container, must be privileged to actually control the gpio pins
docker run --privileged -p 8080:8080 -d randysimpson/pi-relay:latest
To get the status issue curl -i -H "Content-Type: application/json" -X GET http://localhost:8080/api/v1/gpio:
curl -i -H "Content-Type: application/json" -X GET http://localhost:8080/api/v1/gpio
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Wed, 22 Jul 2020 04:10:15 GMT
Content-Length: 67
{ "status":"Success", "date":"2020-07-22T04:10:15ZZ", "result":[] }
To create the id and the gpio and initial state send a post curl -i -H "Content-Type: application/json" -d '{ "id": "50", "gpio": 17, "state": false}' -X POST http://localhost:8080/api/v1/gpio:
curl -i -H "Content-Type: application/json" -d '{ "id": "50", "gpio": 17, "state": false}' -X POST http://localhost:8080/api/v1/gpio
HTTP/1.1 201 Created
Content-Type: application/json; charset=UTF-8
Date: Wed, 22 Jul 2020 04:10:29 GMT
Content-Length: 100
{ "status":"Created", "date":"2020-07-22T04:10:29ZZ", "result":{"id":"50","gpio":17,"state":false} }
To change the state of the gpio pin issue new state in the body of the put curl -i -H "Content-Type: application/json" -d '[{ "id": "50", "gpio": 17, "state": true}]' -X PUT http://localhost:8080/api/v1/state:
curl -i -H "Content-Type: application/json" -d '[{ "id": "50", "gpio": 17, "state": true}]' -X PUT http://localhost:8080/api/v1/state
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Wed, 22 Jul 2020 04:10:38 GMT
Content-Length: 99
{ "status":"Updated", "date":"2020-07-22T04:10:38ZZ", "result":{"id":"50","gpio":17,"state":true} }
Check the documentation on github for more api definitions.
Content type
Image
Digest
Size
79.4 MB
Last updated
about 7 years ago
docker pull randysimpson/pi-relay