Rest api to interact with the consumer electronics control of a hdmi device. Great for turning a raspberry pi into a tv remote.
Get list of all active devices
- Request
curl http://localhost:5000/device
- Response
{
"TV": {
"PowerStatus": "standby",
"PhysicalAddress": "0.0.0.0",
"ActiveSource": false,
"OSDName": "TV",
"Vendor": "Samsung",
"LogicalAddress": 0
},
"Playback": {
"PowerStatus": "on",
"PhysicalAddress": "1.0.0.0",
"ActiveSource": false,
"OSDName": "Roku 3",
"Vendor": "",
"LogicalAddress": 4
},
"Recording": {
"PowerStatus": "on",
"PhysicalAddress": "2.0.0.0",
"ActiveSource": false,
"OSDName": "cec.go",
"Vendor": "Pulse Eight",
"LogicalAddress": 1
}
}
Get details for single device by its physical address
- Request
curl http://localhost:5000/device/0
- Response
{
"PowerStatus": "standby",
"PhysicalAddress": "0.0.0.0",
"ActiveSource": false,
"OSDName": "TV",
"Vendor": "Samsung",
"LogicalAddress": 0
}
Get or set the power status for a device
- Request
curl http://localhost:5000/device/0/power
- Response
{
"status": "success",
"message": "standby"
}
- Request
# state can be "on" or "off"
curl -X POST -d '{"state": "on"}' http://localhost:5000/device/0/power
Set the volume for a amplifier device
This will only work if the device is type Amplifier
- Request
# state can be "up", "down", or "mute"
curl -X POST -d '{"state": "up"}' http://localhost:5000/device/0/volume
This assumes golang has been installed and $GOPATH set
- Install Dependencies
- Ubuntu/Debian
apt-get install libcec-dev cec-utils make
- Get Go Dependencies
go get
- Compile Binary
go build