Sony receiver: STR-DN1080 (linked using JSON)
Posted: Tuesday 05 March 2019 11:49
I want to share my struggles with the linking of my Sony STR-DN1080 receiver to Domoticz using JSON.
Since it is quite a popular receiver, someone else might find this information useful.
(I could have used some details when I started this process... could have saved me 10 hours of testing)
My main goal was that I would like to set the Sound settings to "AFD" or "2 channel" instead of "multichannel stereo" which seems to be the default setting when listening to music (which is the only reason that I need the remote). Additionally I would like to be able to set the input to "BD-DVD" for Kodi without having to scroll through them with my TV-remote. The additional downside of my EU model is that I cannot "Power on" using JSON, so I still have to get WOL working (next project, since it doesn't seem to respond yet).
I found out that there are a few Sony receivers/sound bars/speakers that accept instructions using JSON, being:
STR-DN1080
SRS-ZR5
HT-MT500
HT-CT800
HT-ST5000
HT-ZF9
Details on the available instructions can be found on the site below:
https://developer.sony.com/develop/audi ... ew-content
Required tools to test: postman
https://getpostman.com/apps
You should start with fixing the IP address of the receiver (for example using "address reservation" in your router, or in the network settings of the receiver itself).
In postman, start with retrieving the supported API instructions so you get an idea what you can do.
You should use "POST" in all JSON instructions
Address should be: http://192.168.x.xxx:10000/sony/guide (replace with whatever IP you gave the receiver)
Use: raw
Type: JSON (application/json)
Save the output for future reference.
After testing using Postman I got "setting soundfield" working (it is so sensitive about everything).
Below my raw postman code.
Address:
POST / http://192.168.x.xxx:10000/sony/audio
How to get this working in Domoticz. I'm not too good at scripting, but I at least managed to get it working.
You need to create a curl script for every JSON action (there must be smarter solutions, so enlighten me if you know some).
In Postman when you click on "Code", you can select to see the cURL code for the JSON instruction.
In this case you will get the following code (of course I removed the IP address and token).
Since I've got Domoticz (latest beta) running on a Rpi, I went to the scripts folder and created a script named "sony-afd.sh) using.
To get it working I had to /bin/bash it.
Save the file (CTRL-X / Yes) and make it executable using chmod +x
You can now test it on the commandline using:
Now in Domoticz create a virtual button ("switch selector" in my case, since I want to use multiple scripts).
In "Level Action" you can now link to the script that you created, using:
I hope that someone finds this information useful. Next thing is to get information on the current status into Domoticz.
Please let me know if you have any improvements or suggestions since this is the first time I share something I created and I'm quite sure it can be done better/easier/smarter.
Since it is quite a popular receiver, someone else might find this information useful.
(I could have used some details when I started this process... could have saved me 10 hours of testing)
My main goal was that I would like to set the Sound settings to "AFD" or "2 channel" instead of "multichannel stereo" which seems to be the default setting when listening to music (which is the only reason that I need the remote). Additionally I would like to be able to set the input to "BD-DVD" for Kodi without having to scroll through them with my TV-remote. The additional downside of my EU model is that I cannot "Power on" using JSON, so I still have to get WOL working (next project, since it doesn't seem to respond yet).
I found out that there are a few Sony receivers/sound bars/speakers that accept instructions using JSON, being:
STR-DN1080
SRS-ZR5
HT-MT500
HT-CT800
HT-ST5000
HT-ZF9
Details on the available instructions can be found on the site below:
https://developer.sony.com/develop/audi ... ew-content
Required tools to test: postman
https://getpostman.com/apps
You should start with fixing the IP address of the receiver (for example using "address reservation" in your router, or in the network settings of the receiver itself).
In postman, start with retrieving the supported API instructions so you get an idea what you can do.
You should use "POST" in all JSON instructions
Address should be: http://192.168.x.xxx:10000/sony/guide (replace with whatever IP you gave the receiver)
Use: raw
Type: JSON (application/json)
Code: Select all
{
"method":"getSupportedApiInfo",
"id":5,
"params":[
{
"services":[
]
}
],
"version":"1.0"
}
After testing using Postman I got "setting soundfield" working (it is so sensitive about everything).
Below my raw postman code.
Address:
POST / http://192.168.x.xxx:10000/sony/audio
Code: Select all
{
"method":"setSoundSettings",
"id":5,
"params":[
{
"settings":[
{
"value":"audioFormatDecoding",
"target":"soundField"
}
]
}
],
"version":"1.1"
}
You need to create a curl script for every JSON action (there must be smarter solutions, so enlighten me if you know some).
In Postman when you click on "Code", you can select to see the cURL code for the JSON instruction.
In this case you will get the following code (of course I removed the IP address and token).
Code: Select all
curl -X POST \
http://192.168.0.xxx:10000/sony/audio \
-H 'Content-Type: application/json' \
-H 'Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'cache-control: no-cache' \
-d '{
"method":"setSoundSettings",
"id":5,
"params":[
{
"settings":[
{
"value":"audioFormatDecoding",
"target":"soundField"
}
]
}
],
"version":"1.1"
}'
Code: Select all
sudo nano sony-afd.sh
Code: Select all
#!/bin/bash
curl -X POST \
http://192.168.0.xxx:10000/sony/audio \
-H 'Content-Type: application/json' \
-H 'Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'cache-control: no-cache' \
-d '{
"method":"setSoundSettings",
"id":5,
"params":[
{
"settings":[
{
"value":"audioFormatDecoding",
"target":"soundField"
}
]
}
],
"version":"1.1"
}'
Code: Select all
sudo chmod +x sony-afd.sh
Code: Select all
./sony-afd.sh
In "Level Action" you can now link to the script that you created, using:
Code: Select all
script://sony-afd.sh
Please let me know if you have any improvements or suggestions since this is the first time I share something I created and I'm quite sure it can be done better/easier/smarter.