Need help with a RESTful Command with an XML response

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!

I got around this for now by creating a rest-based sensor and forcing a sensor update in my script, but it would still be nice to know how to get this to work with RESTful Command for future reference.

I’m having the same problem, getting an XML response from a rest_command. How do I parse that into a dictionary?

I am using a different url and this one works for my x3800. I actually use it for other purposes. Can you possibly explain why you want to know DynamicVolume as this is (at least for me) almost 100% stable

sensor:
  - platform: rest
    name: denon dynamic volume
    scan_interval: 60   
    value_template: "{{ value_json.Device_Info.DeviceCapabilities.Setup.Audyssey.DynamicVolume.Control }}"    
    resource: http://192.168.1.101:8080/goform/Deviceinfo.xml

Considering that is not mentioned anywhere in the documentation, I’d say your belief is incorrect. A RESTful Sensor will do that, but not RESTful Command.

Also the information you’re sending as content-type is not correct. It should not include “Content-Type:” as part of the string, and it should specify the content-type of your request, not what response you are expecting. The latter would be specified as an Accept header.