Use a Raspberry Pi Zero to expose an API to my Onkyo Receiver for an iOS app or bOS integration.
Defaults by assuming the receiver is at 192.168.0.162, but can be updated using the /onkyo/discover
$ python -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ ./app.py
GET /onkyo/status
$ curl "http://localhost:8080/onkyo/main/status"
{
"status": {
"main": {
"source": "tv",
"status": "on",
"volume": 55
},
"zone2": {
"source": "appletv",
"status": "standby",
"volume": 0
}
}
}
Will also set the first device found as default
POST /onkyo/discover
$ curl -X "POST" "http://localhost:8080/onkyo/discover"
POST /onkyo/<zone>/power/<value>
$ curl -X "POST" "http://localhost:8080/onkyo/main/power/on"
$ curl -X "POST" "http://localhost:8080/onkyo/main/power/standby"
PUT /onkyo/<zone>/volume/<level>
$ curl -X "POST" "http://localhost:8080/onkyo/main/volume/55"
{
"volume": 55,
"zone": "main"
}
PUT /onkyo/<zone>/tunein/preset
$ curl -X "PUT" "http://localhost:8080/onkyo/main/tunein/2"
{
"preset": 2,
"zone": "main"
}
Run on startup on the Raspberry Pi as a task in crontab
$ crontab -e # edit cron table
@reboot /home/pi/.pyenv/shims/python3 /home/pi/bin/onkyo-server/app.py > /home/pi/logs/onkyo-server.log 2>&1 &
Wout Weijtjens, Original repo forked from Daniel Bowden