I’m trying to use RESTful Command
to get my Denon’s current Dynamic Volume setting in a script, but having trouble parsing the value out. I believe RESTful Command
is supposed to be able to convert the XML response into JSON for parsing, but it doesn’t look like it’s working. According to curl, this is the response that comes back:
HTTP/1.0 200 OK
Server: mongoose2.5
Pragma: no-cache
Cache-control: no-cache
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="utf-8" ?>
<rx>
<cmd>
<name>GetAudyssyInfo</name>
<list>
<param name="dynamicvol" control="1">Off</param>
</list>
</cmd>
</rx>
The content type is text/xml
, so the XML should be converted to JSON, right? However, if I log response['content']
, I get the full XML string back. Am I doing something wrong?
If it helps, this is how I’ve configured the command:
rest_command:
denon_get_dynamic_volume:
url: http://192.168.86.27:8080/goform/AppCommand0300.xml
method: POST
content_type: 'Content-Type: application/json'
payload: '<?xml version="1.0" encoding="utf-8"?> <tx><cmd id="3"><name>GetAudyssyInfo</name><list><param name="dynamicvol"></param></list></cmd></tx>'
And testing with this script:
sequence:
- action: rest_command.denon_get_dynamic_volume
metadata: {}
data: {}
response_variable: volume
- action: logbook.log
metadata: {}
data:
name: Dynamic Volume
message: "{{ volume }}"
alias: Test
description: ""
And this is what shows up in Logbook:
Dynamic Volume {'content': '<?xml version="1.0" encoding="utf-8" ?>\n<rx>\n<cmd>\n<name>GetAudyssyInfo</name>\n<list>\n<param name="dynamicvol" control="1">Off</param>\n</list>\n</cmd>\n</rx>\n', 'status': 200} triggered by action Script: test
Thanks in advance!