Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Questions and comments specific to a particular plugin should go here.
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by Dragon470 » Sat Mar 30, 2019 12:17 am

Here is a script for testing the "Active Speaker"

You need to set your IPADDRESS in the script near the top.

Code: Select all

# stand alone yamaha sender receiver to do testing.
# this one is checking the "Active Speakers" in "System"  Get_Info
from xml.dom import minidom
import httplib
import socket

#Manual setting to change
IPADDRESS = "192.168.1.161"



# network sender/receiver *** Do NOT touch ***

def do_xml(xml, **kwargs):
    """
    Base function to send/receive xml using either GET or POST

    Optional Parameters:
    timeout, ip, port, return_result, print_error, close_xml, print_xml, retry_count, print_response
    """
    timeout = 3.0
    ip = kwargs.get('ip', "192.168.1.1")
    port = kwargs.get('port', 80)
    return_result = kwargs.get('return_result', False)
    print_error = kwargs.get('print_error', True)
    close_xml = kwargs.get('close_xml', False)
    print_xml = kwargs.get('print_xml', True)
    retry_count = kwargs.get('retry_count', 0)  #used for retry errors
    print_response = kwargs.get('print_response', True)  #used for returning raw xml response

    if close_xml:
        xml = close_xml_tags(xml)
    if print_xml:
        print xml

    conn = httplib.HTTPConnection('{0}:{1}'.format(ip, port), timeout=float(timeout))
    headers = { "Content-type": "text/xml" }
    try:
        conn.request("POST", "/YamahaRemoteControl/ctrl", "", headers)
        conn.send(xml)
        if return_result:
            response = conn.getresponse()
            rval = response.read()
            if print_response:
                print rval
            conn.close()
            return rval
        else:
            response = conn.getresponse()
            rval = response.read()
            conn.close()
            if rval != "":
                if str(rval[25]) == "0":
                    return True
                else:
                    print "Command did not go to Yamaha Receiver, error code " + str(rval[25])
            else:
                print "Command did not go to Yamaha Receiver, error NOT possible to set on this model."
    except socket.error:
        if print_error:
            #eg.PrintError("Unable to communicate with Yamaha Receiver. Will try again for 10 times.")
            kwargs['retry_count'] = retry_count + 1
            if retry_count < 10:
                kwargs['close_xml'] = False #could have potential for further errors if not done.
                return do_xml(xml, **kwargs)
            else:
                eg.PrintError("Need to check communication with Yamaha Receiver.")
                return None
        else:
            raise

def send_xml(xml, **kwargs):
    """
    Communicate with the receiver, but do not wait or return the results
    """
    if not 'return_result' in kwargs:
        kwargs['return_result'] = False
    do_xml(xml, **kwargs)

def put_xml(xml, **kwargs):
    send_xml('<YAMAHA_AV cmd="PUT">{0}</YAMAHA_AV>'.format(xml), **kwargs)

def get_system_pattern_1(param, **kwargs):
    types = ['Front', 'Center', 'Sur', 'Sur_Back', 'Subwoofer']
    speakers = []
    levels = []
    for type in types:
        xml = get_xml('<System><Speaker_Preout><Pattern_1><Config><{0}>GetParam</{0}></Config></Pattern_1></Speaker_Preout></System>'.format(type), **kwargs)
        xmldoc = minidom.parseString(xml)
        value = xmldoc.getElementsByTagName("Type")[0].firstChild.data
        if value != "None":
            if value == "Use":
                speakers.append("Subwoofer_1")
                try:
                    if xmldoc.getElementsByTagName("Type")[1].firstChild.data == "Use":
                        speakers.append("Subwoofer_2")
                except:
                    pass
            elif value[-2:] == "x2":
                speakers.append("Sur_Back_R")
                speakers.append("Sur_Back_L")
            if type == "Sur":
                speakers.append("Sur_R")
                speakers.append("Sur_L")
            if type == "Front":
                speakers.append("Front_R")
                speakers.append("Front_L")
            if type == "Center":
                speakers.append("Center")
    if param == "Active Speakers":
        return speakers
    #This is then also done only if levels are requested
    else:
        for speaker in speakers:
            xml = get_xml('<System><Speaker_Preout><Pattern_1><Lvl>GetParam</Lvl></Pattern_1></Speaker_Preout></System>', **kwargs)
            xmldoc = minidom.parseString(xml)
            levels.append([speaker, float(xmldoc.getElementsByTagName(speaker)[0].firstChild.firstChild.data) /10])
        return levels

def receive_xml(xml, **kwargs):
    kwargs['return_result'] = True
    return do_xml(xml, **kwargs)

def get_xml(xml, **kwargs):
    return receive_xml('<YAMAHA_AV cmd="GET">{0}</YAMAHA_AV>'.format(xml), **kwargs)




# stuff that can be edited are below this

print get_system_pattern_1("Active Speakers", ip = IPADDRESS)
Also what model do you have?

therealbiglou
Experienced User
Posts: 125
Joined: Sat May 19, 2012 4:33 am

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by therealbiglou » Sat Mar 30, 2019 2:12 am

Here's the log after I run that script:

Code: Select all

   <YAMAHA_AV cmd="GET"><System><Speaker_Preout><Pattern_1><Config><Front>GetParam</Front></Config></Pattern_1></Speaker_Preout></System></YAMAHA_AV>
   <YAMAHA_AV rsp="GET" RC="2"><System><Speaker_Preout><Pattern_1><Config><Front></Front></Config></Pattern_1></Speaker_Preout></System></YAMAHA_AV>
   Traceback (most recent call last):
     Python script "62", line 132, in <module>
       print get_system_pattern_1("Active Speakers", ip = IPADDRESS)
     Python script "62", line 90, in get_system_pattern_1
       value = xmldoc.getElementsByTagName("Type")[0].firstChild.data
   IndexError: list index out of range
My receiver is an RX-V573.

leejk
Posts: 18
Joined: Sun Dec 04, 2016 4:32 pm

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by leejk » Sat Aug 10, 2019 11:55 pm

Hi

Any plans to add support for the RX-Axxxx line of receivers? If not, do you know of any alternatives?

thx

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by Lilak » Sat Sep 21, 2019 5:12 pm

Hello!

I need to change the HDMI out settings. I've downloaded YNC.zip from @Dragon470, and I've found the command, but I can't figure out how to get a command I can use in the plugin.

The commands I need is in row 2625, 2626, 2627, 2628 and 2629 in the document "V671_3071_FuncTree_1.10" in the zip-file.

Is there anyone who can please help me?

Best regards

Jonas

RiseUp
Posts: 17
Joined: Mon Nov 24, 2014 3:28 am

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by RiseUp » Wed Sep 25, 2019 12:44 am

Lilak wrote:
Sat Sep 21, 2019 5:12 pm
Hello!

I need to change the HDMI out settings. I've downloaded YNC.zip from @Dragon470, and I've found the command, but I can't figure out how to get a command I can use in the plugin.

The commands I need is in row 2625, 2626, 2627, 2628 and 2629 in the document "V671_3071_FuncTree_1.10" in the zip-file.

Is there anyone who can please help me?

Best regards

Jonas
Did you see the following post by Dragon470?
Dragon470 wrote:
Sun Sep 21, 2014 1:55 am
You have to use the xls file to see the structure of your receiver (as a reference). It doesn't have to be in the plugin folder.

On the function Tree worksheet you can select either the put or get command. Then select the item in the tree itself. Click on the ether button. Then in notepad or some other text editor you can past the xml string that is needed for the command. I also below is the document that I got from Yamaha for further explanation.


In the plugin action you do not need all what it puts out.

Ex.
<?xml version="1.0" encoding="utf-8"?> Don't need
<YAMAHA_AV cmd="GET"> Don't need
<System><Power_Control><Power>GetParam</Power></Power_Control></System> Yes, need
</YAMAHA_AV> Don't need

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!

Post by Lilak » Sat Oct 05, 2019 6:49 am

Yes I did see that, and I don't understand.

Best regards

Jonas

Post Reply