SmartThings Community

[RELEASE] Yamaha Network Receiver Basic Integration



Can you explain exactly where I should put this code ?

The app works perfect :slight_smile: but without the possibility to start music it`s useless.
I want it to be able to start a station from NET radio and play it at volume 20%

The way it works now, I still have to use my YAMAHA App to select NET station from bookmark and then PLAY.

If someone can help me explain where I can put the code to create the possibility to start a NET station I would be very happy :smile:

(cjcharles) #123

If you do a comparison between the DH version which I have installed at the moment and the version at the top of the page you will see the customisations. I think it is important to understand them so that you can customise yourself - in particular choosing the sources that you want to use/display.

The only point where these modifications fall down, is if you try and use Zone 2 only for the radio (without Main zone on), since the Line_X commands only work when Main zone is being used. Hence I often start Main and Zone_2, then choose NET, then radio station, and then turn off main. From this point onwards the Line_X commands work, its just at the start (since Main is probably set to another source). Havent got around to investigating yet as it doesnt bother me too much.


Thank you very much.

I will try to see what I can do.
I did a compare from your file and mine, but there was much more than just some small changes :expressionless:

I find some color changes, settings changes, and alot of Sone_B (I have Sone 2 on mine)
In fact there was 157 changed lines from your to mine…

I will try to see what happen :slight_smile:


Well, I think I manage to get it working (sort of) .
I added all the code I needed, from ST I must first turn ON sone2, then select NETradio, then I can enter one of your 3 NET station channels.

But when I press #1 it goes to “My Favourite” that is line number 1 on my NET radio list.
So how do I add it to enter first Line 1, then Line 1, and at last Line 3.

Would be like this: Bookmark\My_Favourites\Channel 3

is this for all 3 button, or is this code only for 1 action:

def NetRadioStation1() {
sendCommand("<YAMAHA_AV cmd=“PUT”><NET_RADIO><List_Control><Direct_Sel>Line_1</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>")
//runIn(2, NetRadioStation2)
def NetRadioStation2() {
sendCommand("<YAMAHA_AV cmd=“PUT”><NET_RADIO><List_Control><Direct_Sel>Line_4</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>")
//runIn(2, NetRadioStation3)
def NetRadioStation3() {
sendCommand("<YAMAHA_AV cmd=“PUT”><NET_RADIO><List_Control><Direct_Sel>Line_5</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>")


I think this is the piece I am missing. Currently I can get Alexa to change my volume to a positive value but as the standard range is -80dB to 16 (I think) of course this is a problem.

So, is it this you changed? If so, how? My apologies - I’m still learning.

def setLevel(value) {
  //sendCommand("<YAMAHA_AV cmd=\"PUT\"><${getZone()}><Volume><Lvl><Val>${(Math.round(value * 9 / 5) * 5 - 800).intValue()}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></${getZone()}></YAMAHA_AV>")
  sendCommand("<YAMAHA_AV cmd=\"PUT\"><${getZone()}><Volume><Lvl><Val>${(value * 10).intValue()}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></${getZone()}></YAMAHA_AV>")
  sendEvent(name: "volume", value: value)


I did solve problem how to make my YAMAHA play from NET radio :slight_smile:

But sometimes it want turn ON.
Any idea what this LOG from IDE is:

20:59:27: error java.lang.NullPointerException: Cannot invoke method children() on null object @ line 67

Edit: Problem did go away and it would now turn ON OFF.

But I can`t manage to SET VOLUME using CoRE.
Anyone else manage to resolve this ?


This is what I have:

def setLevel(value) {
  def zone = getZone()
  def int volLevel = (Math.round(value * 9 / 5) * 5 - 800).intValue()
  //def int volLevel = (value * 10).intValue()
  def cmd = (zone != "Zone_B") ?
"<YAMAHA_AV cmd=\"PUT\"><${zone}><Volume><Lvl><Val>${volLevel}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></${zone}></YAMAHA_AV>" :
"<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Volume><Zone_B><Lvl><Val>${volLevel}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Zone_B></Volume></Main_Zone></YAMAHA_AV>"
  sendEvent(name: "volume", value: value)



The Set Volume does not work for me from CoRE, does it work from anyone else ? (is it supposed to work)

I also feel like there is a bug somewhere in my system, I make a Piston in CoRE to turn ON amp, then SET INPUT NETradio, then start playlist etc…

First time it works, second time it works, but then suddenly it will not start anymore :frowning:
I try to start the AMP from ST, and it will turn ON, but from the CoRE piston it will not turn ON no matter how often I try.

Is there any reason why it appears like this, is it a common problem ?

A supergreat app, that have given me many ideas, but I wonder if a Harmony Hub will be more stable and work all the time?


Can you explain how you are setting the volume in CoRE? Provided you have the “Switch Level” capability defined in the Device Handler then CoRE should recognize the Yamaha device as a “dimmer”, which you can then set between 1 & 100.


In CoRE after IF, THEN “Using YAMAHA ZONE2” i choose SET VOLUME % .
is that wrong way to do it ?


Here is my CoRE command:

◦ button switch is on
Using Yamaha Stue…
► Turn on
► ⌂ source0()
► Wait 5 seconds
► ⌂ NetRadioStation1()
► Wait 5 seconds
► ⌂ NetRadioStation1()
► Wait 5 seconds
► ⌂ NetRadioStation1()
Using Subwoofer…
► Turn on
Using Yamaha Stue…
► Set level to 50%

But the bad part is that I can test it first, and when I add one line in CoRE to test it again, nothing works. It`s really annoying.


Have you tried before selecting YAMAHA ZONE2, for the THEN action select to “Control dimmable lights or dimmers”? YAMAHA ZONE2 devices should be listed as a dimmer.


I have removed the SET VOLUME from controlling MediaPlayers, and addet a Control Dimmers, and from there added action “Set Volume” 50% .

But like I said in the last reply, the Piston stop working after I use it 1-2 times !!
So I need to delete it and create a new one with the same settings and test again…

I really dont understand why the piston should stop sending commands to the receiver!!?

EDIT: Have not yet manage to get any piston from CoRE to talk to the Receiver yet !!! :angry:
But when I start the piston, I can see on the ST Yamaha sone2 that the action is started.
And I notice it tells the Yamaha to SET VOLUME 50 !
But when I adjust the slider inside ST it sets volume to -50

Can the problem be that CoRE use number from 0-100 but the Receiver use number -80 to +3 ?


Yes, see the post below to change the handler to use 1-100…


Thanks for help and the instructions. Worked out and I now have the 0-100 slider. The limiter is also very handy.
After looking at the (really simple) fix, I feel bad for even asking. But really appreciated nonetheless. In fact the extra amount of unnecessary time I spent on this gave me some good working knowledge to possibly code my own apps in the future.


@StuartW sorry for being an idiot.
But I understand that I needed to change the // on the first code and replace it on line 2 … (it took me some time though) …
Anyway, I cant find out about the second:

ef setLevel(value) {
def zone = getZone()

  if (value > 50){
  value = 50
  def int volLevel = (Math.round(value * 9 / 5) * 5 - 800).intValue()
  //def int volLevel = (value * 10).intValue()
  def cmd = (zone != "Zone_B") ?
"<YAMAHA_AV cmd=\"PUT\"><${zone}><Volume><Lvl><Val>${volLevel}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></${zone}></YAMAHA_AV>" :
"<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Volume><Zone_B><Lvl><Val>${volLevel}</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Zone_B></Volume></Main_Zone></YAMAHA_AV>"
  sendEvent(name: "volume", value: value)

This is my code:

def setLevel(value) {
//sendCommand("<YAMAHA_AV cmd=“PUT”><${getZone()}>${(Math.round(value * 9 / 5) * 5 - 800).intValue()}1dB</${getZone()}></YAMAHA_AV>")
sendCommand("<YAMAHA_AV cmd=“PUT”><${getZone()}>${(value * 10).intValue()}1dB</${getZone()}></YAMAHA_AV>")
sendEvent(name: “volume”, value: value)

I see in my code there is a // on the first “sendCommand” , and on the code I should change it says md=“PUT”><${zone}> but in my code it says: <${getZone() …

I dont understand, why is there so much difference, and what code is the correct one for me to use ?
I want to add the volume limit to >50 .

And last, the third change (for what?) , * Zone Volume
val = (zone != “Zone_B”) ?

I cant find anywhere in my code that I have this code, Zone_B is not used on my YAMAHA anyway, so do I need to change this ? :cold_sweat:

Edit: Change the code (first line ) and now the Volume is MAX TO MAX no matter if I slide the volume control OMG.
Glad I did not have any music turned On.


On what Line number should I input the Volume UP\DOWN code?
Or does it not matter.


I would suggest putting it after the other command definitions i.e. def on() … def off() … def setLevel(value) etc.


Ok… day 3 and I manage to get almost everything up now.
Had to start reading Code for Beginners chapter One lol…

I fixed Network playing from ST, fixed 0-100 volume from ST :slight_smile:

But adding

def setLevel(value) {
def zone = getZone()

  if (value > 50){
  value = 50

give me an error, I cant make a limit to the volume.

Another bug that I still have not found any fix for, does the YAMAHA Script have a timeout LOCK between each time it will run a command, or the YAMAHA Receiver?

I made a working piston from CoRE that is turing ON receiver and start music + turn on Subwoofer.
It worked perfect 2 times, but the 3rd time it want start.
Same thing everyday, but the next day I give it a try it will run.

is there a time limit I dont know about ?

(Pete) #141

Brand new to this so please forgive stupid questions. I have an Echo Dot and now Smartthings hub, can I still use this?