Re: Yamaha RX-Vxxx (or similar) Ethernet Plugin!
Posted: 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.
Also what model do you have?
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)