Yamaha RX Plugin - a/v receiver control

Posted on
Thu Oct 01, 2015 10:24 am
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Hello guys,

Any one had this plugin to work or is working on it?
I own a RX-V779BL and would like to be able to communicate with Indigo.
I'm stuck at the <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'text' error.

Thanks in advance.

Posted on
Thu Oct 01, 2015 10:30 am
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Thanks Ben,

I'm trying to use it with a RX-V779BL.

Cheers,
Alex

Posted on
Thu Oct 08, 2015 1:33 pm
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Hello again,

Experimenting with the plugin, I advanced just a little.
I must say again, that I don't know anything about Python programing. I'm just using trial-an-error method,

Can anyone identify this Python error:

Yamaha RX Receiver Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 104, in putPower
<type 'exceptions.TypeError'>: cannot concatenate 'str' and 'Device' objects


Produced by this method:

def putPower(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>'+val+'</Power></Power_Control></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)


If we ca make it passing this Python error, we might get the plugin to work, even if it is partially.
Thanks for your time guys.

Regards,
Alejandro

Posted on
Thu Oct 08, 2015 5:03 pm
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Yamaha RX Plugin - a/v receiver control

Is line 104 this line?

Code: Select all
root = xmitToReceiver(dev, xml_string)


If so, this function is expecting a string as argument 1, but you're sending it a device type object. We'll have to see the code for that function to be sure.

Also, please use the [ c o d e ] tags for actual code.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2015 5:05 pm
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Yamaha RX Plugin - a/v receiver control

Wait, I missed the "+val+" in your xml string. What's the type of val?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2015 5:15 pm
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Hi Joe,

Thanks for your help.

Depending if you count the first line of code as "0", 104 will be "root = xmitToReceiver(dev, xml_string)"
But if the first line is "1", 104 is the one with the "+val+".

Looks to me that "val" is an integer, but when I tried to use the expression " + vas as string + ", it gave me another error regarding "pluginproperties".

Here are the 4 files composing the plug in:

plugin.py

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import httplib, urllib2, sys, os
try:
import xml.etree.cElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET

def str2bool(v):
return v.lower() in ("yes", "true", "t", "1")

def xmitToReceiver(dev, xml_string):
url = 'http://'+dev.pluginProps['txtip']+'/YamahaRemoteControl/ctrl'

req = urllib2.Request(
url=url,
data=xml_string,
headers={'Content-Type': 'application/xml'})
resp = urllib2.urlopen(req)
status_xml = resp.read()
root = ET.fromstring(status_xml)
return root

class Plugin(indigo.PluginBase):

def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs):
indigo.PluginBase.__init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs)
self.debug = True

def __del__(self):
indigo.PluginBase.__del__(self)


def startup(self):
self.debugLog(u"startup called")

def shutdown(self):
self.debugLog(u"shutdown called")

def deviceStartComm(self, dev):
self.updateStatus(dev)

# helper methods, these mostly serve to facilitate calls to the device

def updateStatus(self, dev):
# get status from receiver, update locals
self.debugLog(u"updating status...")

if dev is None:
self.debugLog(u"no device defined")
return

xml_string = '<YAMAHA_AV cmd="GET"><Main_Zone><Basic_Status>GetParam</Basic_Status></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
#power = root.find("./Main_Zone/Basic_Status/Power_Control/Power").text
#sleep = root.find("./Main_Zone/Basic_Status/Power_Control/Sleep").text
#if(sleep!='Off'): sleep = "n"+sleep
#volume = root.find("./Main_Zone/Basic_Status/Vol/Lvl/Val").text
#mute = root.find("./Main_Zone/Basic_Status/Vol/Mute").text
#inputmode = root.find("./Main_Zone/Basic_Status/Input/Input_Sel").text

#dev.updateStateOnServer("power", power)
#dev.updateStateOnServer("sleep", sleep)
#dev.updateStateOnServer("volume", volume)
#dev.updateStateOnServer("mute", mute)
#dev.updateStateOnServer("input", inputmode)

def putMute(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Vol><Mute>'+val+'</Mute></Vol></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)

def putVolume(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Vol><Lvl><Val>'+val+'</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Vol></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)

def putPower(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>'+val+'</Power></Power_Control></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)

def putSleep(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Sleep>'+val+'</Sleep></Power_Control></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)

def putInput(self, dev, val):
if dev is None:
self.debugLog(u"no device defined")
return

if val is None:
self.debugLog(u"value not defined")
return

xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Input><Input_Sel>'+val+'</Input_Sel></Input></Main_Zone></YAMAHA_AV>'
root = xmitToReceiver(dev, xml_string)
self.updateStatus(dev)

def setInput(self, pluginAction, dev):
self.debugLog(u"setInput called")
val = pluginAction.props['ddlinput'].upper().replace(".","/").replace("_"," ")
self.putInput(dev, val)



Actions.xml

<?xml version="1.0"?>
<Actions>
<Action id="setVolume" deviceFilter="self">
<Name>Set Volume</Name>
<CallbackMethod>putVolume</CallbackMethod>
<ConfigUI>
<Field id="txtvolume" type="textfield" default="-30">
<Label>Level</Label>
<Description>in dB</Description>
</Field>
</ConfigUI>
</Action>
<Action id="increaseVolume" deviceFilter="self">
<Name>Increase Volume</Name>
<CallbackMethod>increaseVolume</CallbackMethod>
<ConfigUI>
<Field id="txtincrement" type="textfield" default="5">
<Label>Increment</Label>
<Description>in dB</Description>
</Field>
</ConfigUI>
</Action>
<Action id="decreaseVolume" deviceFilter="self">
<Name>Decrease Volume</Name>
<CallbackMethod>decreaseVolume</CallbackMethod>
<ConfigUI>
<Field id="txtincrement" type="textfield" default="5">
<Label>Increment</Label>
<Description>in dB</Description>
</Field>
</ConfigUI>
</Action>
<Action id="setMute" deviceFilter="self">
<Name>Set Mute</Name>
<CallbackMethod>putMute</CallbackMethod>
<ConfigUI>
<Field id="ddlmute" type="menu">
<Label>Set Mute</Label>
<List>
<Option value="On">On</Option>
<Option value="Off">Off</Option>
</List>
</Field>
</ConfigUI>
</Action>
<Action id="toggleMute" deviceFilter="self">
<Name>Toggle Mute</Name>
<CallbackMethod>toggleMute</CallbackMethod>
</Action>
<Action id="setPower" deviceFilter="self">
<Name>Set Power</Name>
<CallbackMethod>putPower</CallbackMethod>
<ConfigUI>
<Field id="ddlpower" type="menu">
<Label>Set Power</Label>
<List>
<Option value="On">On</Option>
<Option value="Standby">Standby</Option>
</List>
</Field>
</ConfigUI>
</Action>
<Action id="togglePower" deviceFilter="self">
<Name>Toggle Power</Name>
<CallbackMethod>togglePower</CallbackMethod>
</Action>
<Action id="setSleep" deviceFilter="self">
<Name>Set Sleep</Name>
<CallbackMethod>putSleep</CallbackMethod>
<ConfigUI>
<Field id="ddlsleep" type="menu">
<Label>Set Sleep</Label>
<List>
<Option value="Off">Off</Option>
<Option value="n30">30</Option>
<Option value="n60">60</Option>
<Option value="n90">90</Option>
<Option value="n120">120</Option>
</List>
</Field>
</ConfigUI>
</Action>
<Action id="setInput" deviceFilter="self">
<Name>Set Input</Name>
<CallbackMethod>setInput</CallbackMethod>
<ConfigUI>
<Field id="ddlinput" type="menu">
<Label>Set Input</Label>
<List>
<Option value="tuner">TUNER</Option>
<Option value="multi_ch">MULTI CH</Option>
<Option value="phono">PHONO</Option>
<Option value="cd">CD</Option>
<Option value="tv">TV</Option>
<Option value="md.cd-r">MD/CD-R</Option>
<Option value="bd.hd_dvd">BD/HD DVD</Option>
<Option value="dvd">DVD</Option>
<Option value="cbl.sat">CBL/SAT</Option>
<Option value="dvr">DVR</Option>
<Option value="vcr">VCR</Option>
<Option value="v-aux">V-AUX</Option>
<Option value="dock">DOCK</Option>
<Option value="pc.mcx">PC/MCX</Option>
<Option value="net_radio">NET RADIO</Option>
<Option value="usb">USB</Option>
</List>
</Field>
</ConfigUI>
</Action>
<Action id="getStatus" deviceFilter="self">
<Name>Get Status</Name>
<CallbackMethod>getStatus</CallbackMethod>
</Action>
</Actions>


Devices.xml

<?xml version="1.0"?>
<Devices>
<Device type="custom" id="receiver">
<Name>Yamaha RX Series Receiver</Name>
<ConfigUI>
<Field id="txtip" type="textfield" default="192.168.1.4">
<Label>Receiver IP Address</Label>
<Description>enter the ip address of your reciever</Description>
</Field>
</ConfigUI>
<States>
<State id="power">
<ValueType>
<List>
<Option value="On">On</Option>
<Option value="Standby">Standby</Option>
</List>
</ValueType>
<TriggerLabel>Power</TriggerLabel>
<ControlPageLabel>Power</ControlPageLabel>
</State>
<State id="sleep">
<ValueType>
<List>
<Option value="Off">Off</Option>
<Option value="n30">30</Option>
<Option value="n60">60</Option>
<Option value="n90">90</Option>
<Option value="n120">120</Option>
</List>
</ValueType>
<TriggerLabel>Sleep</TriggerLabel>
<ControlPageLabel>Sleep</ControlPageLabel>
</State>
<State id="volume">
<ValueType>Integer</ValueType>
<TriggerLabel>Volume</TriggerLabel>
<ControlPageLabel>Volume</ControlPageLabel>
</State>
<State id="mute">
<ValueType boolType="OnOff">Boolean</ValueType>
<TriggerLabel>Mute</TriggerLabel>
<ControlPageLabel>Mute</ControlPageLabel>
</State>
<State id="input">
<ValueType>
<List>
<Option value="sirius">SIRIUS</Option>
<Option value="xm">XM</Option>
<Option value="tuner">TUNER</Option>
<Option value="multi_ch">MULTI CH</Option>
<Option value="phono">PHONO</Option>
<Option value="cd">CD</Option>
<Option value="tv">TV</Option>
<Option value="md.cd-r">MD/CD-R</Option>
<Option value="bd.hd_dvd">BD/HD DVD</Option>
<Option value="dvd">DVD</Option>
<Option value="cbl.sat">CBL/SAT</Option>
<Option value="dvr">DVR</Option>
<Option value="vcr">VCR</Option>
<Option value="v-aux">V-AUX</Option>
<Option value="dock">DOCK</Option>
<Option value="pc.mcx">PC/MCX</Option>
<Option value="net_radio">NET RADIO</Option>
<Option value="rhapsody">RHAPSODY</Option>
<Option value="usb">USB</Option>
</List>
</ValueType>
<TriggerLabel>Input</TriggerLabel>
<ControlPageLabel>Input</ControlPageLabel>
</State>
</States>
</Device>
</Devices>


PluginConfig.xml

<?xml version="1.0"?>
<PluginConfig>
<Field id="lblFoo" type="label">
<Label>No items to config.</Label>
</Field>
</PluginConfig>

Posted on
Thu Oct 08, 2015 6:10 pm
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Yamaha RX Plugin - a/v receiver control

See the green bar at the top of the posting window with the button that says "Code" on it? Please use it.

Python counts lines starting with 1. Giving you the exact line that throws the error is always handy.

If 'val' is an integer, change that line of code to
Code: Select all
 ...'+ str(val) + '...


"val as string" is not Python. Is it C++?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Oct 09, 2015 6:47 am
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Thanks again.

I don't really know, it could be C++.
I can barely program some Applescript.
I actually came with that solution as I found it in internet, in a Python forum.
I also don't have a Python editor. I'm using Xcode.

Sorry to bother you with all of this.

Although I can understand the "estructure and concept" of the plugin code, this is trial-and-error for me.
Since this plugin thread and the plugin itself is dead, I was just trying to make it work.

Trying your solution "+ str(val) +" gives the following error:

Yamaha RX Receiver Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 92, in putVolume
File "plugin.py", line 14, in xmitToReceiver
<type 'exceptions.AttributeError'>: 'PluginAction' object has no attribute 'pluginProps'


Line 14: url = 'http://'+dev.pluginProps['txtip']+'/YamahaRemoteControl/ctrl'

Line 92: xml_string = '<YAMAHA_AV cmd="PUT"><Main_Zone><Vol><Lvl><Val>'+ str(val) +'</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Vol></Main_Zone></YAMAHA_AV>'


And that one I don't really have any idea of what could it be.

Posted on
Fri Oct 09, 2015 2:53 pm
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Oh, I'm sorry Joe about posting code as regular text.
I just got it...
I thought you were referring to a Python editor function, since we were talking about lines of code.

Sorry again.

Anyway, just in case it could be better, just downloaded Editra editor.

Regards,
Alejandro

Posted on
Sat Oct 10, 2015 6:08 am
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Yamaha RX Plugin - a/v receiver control

IMO, the best free programming editor for Macs is TextWrangler. It's the free version of BBEdit.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Oct 10, 2015 6:29 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Yamaha RX Plugin - a/v receiver control

FlyingDiver wrote:
IMO, the best free programming editor for Macs is TextWrangler. It's the free version of BBEdit.

+1 for TextWrangler. I use it every day.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Oct 10, 2015 6:31 am
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Yamaha RX Plugin - a/v receiver control

Fun tip for using TextWrangler - you can open the .plugin file wrapper in TextEdit, giving access to all the components of the plugin at the same time. ;)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Oct 10, 2015 8:50 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Yamaha RX Plugin - a/v receiver control

Yes, that's how I do it too. You can also run scripts right in TW to debug, or send them to the shell.

I was just running some UDP broadcast script tests in TW last night to fine tune a setting (running the script thousands of times).


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Oct 18, 2015 1:30 pm
BenX10 offline
Posts: 52
Joined: Mar 10, 2012
Location: Haltern am See, Germany

Re: Yamaha RX Plugin - a/v receiver control

Betacruxis:
Assumed you're using "my" version of the plugin it seems that your RX-V779 needs different command strings for power control than my RX-V775. Does yours have zone control? And if so do you have 3 different power control options in its web interface as shown in the attached screen shot? Did you find any documentation for your model how to control it by http commands?

Cheers,
Ben
Attachments
Bereichsaufnahme 1.png
Bereichsaufnahme 1.png (195.16 KiB) Viewed 19267 times

Posted on
Sun Oct 18, 2015 2:39 pm
Betacruxis offline
Posts: 56
Joined: Apr 03, 2010

Re: Yamaha RX Plugin - a/v receiver control

Hi Ben,

Thanks again for your answer.

I am using the "original" plugin from "discgolfer1138" (Chad Francis / github.com), modified according to his website latest mods (Feb 2015).
Sadly seems that all his threads are dead.

In spite of that, I found that this receivers series share a lot of commands (also IR), so some of them might actually be working for both models.

I don't really know which is "your" version. Will be nice to try it, if you send me a link to download it.

As you mentioned, 779 has 2 zones, therefore 3 different power commands.

Thing is I cannot get the plugin working at all, because in spite I caught several errors, I still get some others regarding the ".py" file, which I have no idea what they are.
(Let me remind you I don't know Python programing)

Also, I couldn't yet find any documentation at all in reference to the http commands. I tried some commands manually (sort of RESTful URLs) and got no results. Just an unrelated "elapsed time" info of net radio.

Cheers,
Alejandro

Who is online

Users browsing this forum: No registered users and 0 guests