Need help in passing an item state in a HTTP XML payload

Tried to control my radio using the http binding but I’m unable to pass the state of an item using the binding. So far, I am successful in creating

  • Http URL thing
  • Separate channels using the XPATH expression in the profile configuration section
  • a channel that powered on the radio using the below XML payload
     <?xml version="1.0" encoding="utf-8"?>
     <YAMAHA_AV cmd="PUT">
     <System>
         <Power_Control>
             <Power>On</Power>
         </Power_Control>
     </System>
     </YAMAHA_AV>

What I’m trying to do now is to change the Power element node to either On or Standby but I’m confused on how to item state can be inserted in an element node. I created a switch channel and added the above XML payload in the statecontent and changed the Power element node entry to %2$s. I’m still confused if I need to do a command transformation and if so, how the compose the XPATH expression. So far, the logs says the POST statement is timing out.

UID: http:url:Yamaha-CRX-N560
label: Yamaha CRX-N560
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  headers:
    - ""
  baseURL: http://192.XXX.XXX.XXX/YamahaRemoteControl/ctrl
  delay: 0
  stateMethod: POST
  refresh: 3
  commandMethod: POST
  contentType: text/xml
  timeout: 3000
  bufferSize: 2048
location: Kitchen
channels:
  - id: YamahaBasicStatus
    channelTypeUID: http:string
    label: Yamaha Basic Status
    description: ""
    configuration:
      mode: READONLY
      stateContent: <?xml version="1.0" encoding="utf-8"?> <YAMAHA_AV
        cmd="GET"><System><Basic_Status>GetParam</Basic_Status></System></YAMAHA_AV>
  - id: Presets
    channelTypeUID: http:string
    label: Stereo Presets
    description: ""
    configuration:
      mode: READONLY
      stateContent: <YAMAHA_AV
        cmd="GET"><Tuner><Play_Control><Preset><FM><Preset_Sel_Item>GetParam</Preset_Sel_Item></FM></Preset></Play_Control></Tuner></YAMAHA_AV>
  - id: Power
    channelTypeUID: http:switch
    label: Set Power
    description: ""
    configuration:
      onValue: On
      mode: WRITEONLY
      stateContent: <?xml version="1.0" encoding="utf-8"?><YAMAHA_AV
        cmd="PUT"><System><Power_Control><Power>%2$s</Power></Power_Control></System></YAMAHA_AV>
      offValue: Standby

Not an anwer to your question but have you considered to use the Yamaha binding ?

I have tried the Yamaha binding over the years but it errors out. Several individuals requested support (1st Topic and 2nd topic for the YNC protocol but there has been no responses. I just tried it again before I responded and the binding recognizes the device but fails to initialize and list the appropriate channels.

2021-09-26 06:59:24.740 [INFO ] [openhab.event.InboxAddedEvent       ] - Discovery Result with UID 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' has been added.
2021-09-26 06:59:24.740 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' to inbox.
2021-09-26 06:59:53.046 [INFO ] [openhab.event.InboxRemovedEvent     ] - Discovery Result with UID 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' has been removed.
2021-09-26 06:59:53.054 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' changed from UNINITIALIZED to INITIALIZING
2021-09-26 06:59:53.057 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' changed from INITIALIZING to OFFLINE (CONFIGURATION_PENDING): Waiting for connection with Yamaha device
2021-09-26 06:59:53.231 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler@1393d3bc': null
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.DeviceDescriptorXML.load(DeviceDescriptorXML.java:162) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.DeviceInformationXML.update(DeviceInformationXML.java:100) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.ensureConnectionInitialized(YamahaBridgeHandler.java:384) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.onConnectionCreated(YamahaBridgeHandler.java:363) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLProtocolFactory.createConnection(XMLProtocolFactory.java:50) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.initialize(YamahaBridgeHandler.java:352) ~[?:?]
2021-09-26 06:59:53.242 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff' changed from OFFLINE (CONFIGURATION_PENDING): Waiting for connection with Yamaha device to UNINITIALIZED (HANDLER_INITIALIZING_ERROR)
2021-09-26 06:59:53.242 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'yamahareceiver:yamahaAV:5f9ec1b3_ed59_1900_4530_00a0de1b0fff': null
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.DeviceDescriptorXML.load(DeviceDescriptorXML.java:162) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.DeviceInformationXML.update(DeviceInformationXML.java:100) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.ensureConnectionInitialized(YamahaBridgeHandler.java:384) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.onConnectionCreated(YamahaBridgeHandler.java:363) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLProtocolFactory.createConnection(XMLProtocolFactory.java:50) ~[?:?]
	at org.openhab.binding.yamahareceiver.internal.handler.YamahaBridgeHandler.initialize(YamahaBridgeHandler.java:352) ~[?:?]
2021-09-26 07:01:31.612 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'YamahaReceiverCRXN560_Power' received command ON
2021-09-26 07:01:31.616 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'YamahaReceiverCRXN560_Power' predicted to become NULL

I’m replying to myself to add more details. In order to power the unit on and off, I used a switch channel and enter the entire xml payload to the onValue and offValue fields. It works but I still have an issue if I try to adjust the volume level or select an input source. This is why I’m trying to understand how to use the XPATH command transformation to change an entry in an element node.

    channelTypeUID: http:switch
    label: Set Power
    description: ""
    configuration:
      onValue: <?xml version="1.0" encoding="utf-8"?><YAMAHA_AV
        cmd="PUT"><System><Power_Control><Power>On</Power></Power_Control></System></YAMAHA_AV>
      mode: WRITEONLY
      offValue: <?xml version="1.0" encoding="utf-8"?><YAMAHA_AV
        cmd="PUT"><System><Power_Control><Power>Standby</Power></Power_Control></System></YAMAHA_AV>

.