Yamaha Receiver Binding: GET playback_channels#preset for input TUNER

Hy guys,

since the Yamaha Receiver Binding did not report the current selected preset (in my case it’s 0 every time I change the input) yet, I’ve written a small rule to handle this.

Items file:

Number    Yamaha_Preset    "Preset [%d]"    <video>    { channel="yamahareceiver:zone:receiver:main:playback_channels#preset"}

Rules file:

rule "Yamaha Receiver - Get Tuner Preset"
    Item Get_Yamaha_Preset changed
    logInfo("Rules.YamahaReceiver.InputChange", "Set input settings for {}.", Yamaha_Input.state)

    // Get current preset information
    logDebug("Rules.YamahaReceiver.InputChange", "Get {} preset", Yamaha_Input.state)
    val String urlString = "http://xxx.xxx.xxx.xxx:80/YamahaRemoteControl/ctrl"
    val String contentType = "text/xml"
    val String contentString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><YAMAHA_AV cmd=\"GET\"><Tuner><Play_Info>GetParam</Play_Info></Tuner></YAMAHA_AV>"
    val String result = sendHttpPostRequest(urlString, contentType, contentString)

    // Extract current preset from response string
    val Number startIndex = result.indexOf("<Preset_Sel>")
    val Number endIndex = result.indexOf("</Preset_Sel>")
    startIndex = startIndex + 12

    // Post current preset to item
    val Number presetNumber =  new Integer( result.substring(startIndex.intValue, endIndex.intValue) ) as Integer
    logDebug("Rules.YamahaReceiver.InputChange", "Post update for {} preset: {}", Yamaha_Input.state, presetNumber)

I hope this will serve you well until it’s taken over to the official binding.

Best regards

1 Like