Open SurfingSpider opened 3 years ago
Hey Chris! Did you try or could you try to select a specific net radio station with the 'AV Controller' app? I guess you mean opening one which is in your favorites?
If that works within that app, I could have a look how the xml payload has to look like. Paying the subscription would be very nice then because I don't have it myself. Alternatively I could help you to look up the payload by yourself if you want to do that.
I downloaded the MITMproxy thing and got my head around how it works.
I can control the avr from postman by sending POST requests to http://
I am new to this so bear with me...I am not sure if there is a more elegant way of doing it? I would love not to have to send multiple requests for the same thing
First I have to turn the amp on
<?xml version="1.0" encoding="utf-8"?>
<YAMAHA_AV cmd="PUT">
<Main_Zone>
<Power_Control>
<Power>On</Power>
</Power_Control>
</Main_Zone>
</YAMAHA_AV>
Then change the channel to Net radio
<?xml version="1.0" encoding="utf-8"?>
<YAMAHA_AV cmd="PUT">
<Main_Zone>
<Input>
<Input_Sel>NET RADIO</Input_Sel>
</Input>
</Main_Zone>
</YAMAHA_AV>
Then request for the list of favorites. (wont work without this step)
<?xml version="1.0" encoding="utf-8"?>
<YAMAHA_AV cmd="GET">
<NET_RADIO>
<List_Info>GetParam</List_Info>
</NET_RADIO>
</YAMAHA_AV>
receive back the Response
<YAMAHA_AV rsp="GET" RC="0">
<NET_RADIO>
<List_Info>
<Menu_Status>Ready</Menu_Status>
<Menu_Layer>3</Menu_Layer>
<Menu_Name>Bookmarks</Menu_Name>
<Current_List>
<Line_1>
<Txt>BBC Radio 6 Music</Txt>
<Attribute>Item</Attribute>
</Line_1>
<Line_2>
<Txt>BBC Radio 4</Txt>
<Attribute>Item</Attribute>
</Line_2>
<Line_3>
<Txt>Radio X Manchester</Txt>
<Attribute>Item</Attribute>
</Line_3>
<Line_4>
<Txt>BBC Radio 1</Txt>
<Attribute>Item</Attribute>
</Line_4>
<Line_5>
<Txt>BBC Radio 1Xtra</Txt>
<Attribute>Item</Attribute>
</Line_5>
<Line_6>
<Txt>BBC Radio 2</Txt>
<Attribute>Item</Attribute>
</Line_6>
<Line_7>
<Txt>BBC Radio 3</Txt>
<Attribute>Item</Attribute>
</Line_7>
<Line_8>
<Txt>BBC Radio 4 Extra</Txt>
<Attribute>Item</Attribute>
</Line_8>
</Current_List>
<Cursor_Position>
<Current_Line>1</Current_Line>
<Max_Line>11</Max_Line>
</Cursor_Position>
</List_Info>
</NET_RADIO>
</YAMAHA_AV>
Then request Favorite 1
<?xml version="1.0" encoding="utf-8"?>
<YAMAHA_AV cmd="PUT">
<NET_RADIO>
<List_Control>
<Direct_Sel>Line_1</Direct_Sel>
</List_Control>
</NET_RADIO>
</YAMAHA_AV>
Well done, looks really nice! I would guess that's the most elegant way of doing this - if not even the only one. But this could surely be automated somehow. I'm only using Home Assistant for a short amount of time myself and only using volume and input switch and wasn't aware the yamaha plugin offered more than that. Which plugin have you been using which worked in the past and how did you configured it?
Turned out when I tried to automate it it gets a bit more complicated (as always) There are three menus you need to select the right input.
[{"id":"01c738743d199034","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1810,"y":4280,"wires":[["845971e20de6eb69"]]},{"id":"217d10470dea87a9","type":"change","z":"3d9125fd.0a2f6a","name":"Send turn on amp http request","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"PUT\"> <Main_Zone> <Power_Control> <Power>On</Power> </Power_Control> </Main_Zone> </YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":4280,"wires":[["01c738743d199034"]]},{"id":"75cdcf5d4d5029d2","type":"inject","z":"3d9125fd.0a2f6a","name":"Favorite 2 (BBC Radio 4)","props":[{"p":"fav","v":"2","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":4380,"wires":[["64b3a1aa24f08ef4"]]},{"id":"845971e20de6eb69","type":"change","z":"3d9125fd.0a2f6a","name":"Send Switch input to NET Radio HTTP Request","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"PUT\"> <Main_Zone> <Input> <Input_Sel>NET RADIO</Input_Sel> </Input> </Main_Zone> </YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":4360,"wires":[["f6438f71a9fccd5c"]]},{"id":"f6438f71a9fccd5c","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1890,"y":4360,"wires":[["ab106eecc3343e3c"]]},{"id":"ab106eecc3343e3c","type":"change","z":"3d9125fd.0a2f6a","name":"Get Menu List (doesnt work without this)","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"GET\"> <NET_RADIO> <List_Info>GetParam</List_Info> </NET_RADIO> </YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":4500,"wires":[["d7be3954e47fa148"]]},{"id":"d7be3954e47fa148","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":550,"y":4500,"wires":[["6269c9b6a5abb1ef","505102e8b5ac31d1"]]},{"id":"de2deb817000c8d4","type":"switch","z":"3d9125fd.0a2f6a","name":"<Menu_Layer> ?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"<Menu_Layer>1</Menu_Layer>","vt":"str"},{"t":"cont","v":"<Menu_Layer>2</Menu_Layer>","vt":"str"},{"t":"cont","v":"<Menu_Layer>3</Menu_Layer>","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1050,"y":4500,"wires":[["ac70beef4a3a5f70"],["ac70beef4a3a5f70"],["0ddeb2bb12f69618"]]},{"id":"6269c9b6a5abb1ef","type":"switch","z":"3d9125fd.0a2f6a","name":"Menu loaded yet?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"<Menu_Status>Ready</Menu_Status>","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":790,"y":4500,"wires":[["de2deb817000c8d4"],["f2c48329dba73d7e"]]},{"id":"f2c48329dba73d7e","type":"delay","z":"3d9125fd.0a2f6a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":260,"y":4580,"wires":[["ab106eecc3343e3c"]]},{"id":"ac70beef4a3a5f70","type":"change","z":"3d9125fd.0a2f6a","name":"Select line 1 of menu","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"PUT\"> <NET_RADIO> <List_Control> <Direct_Sel>Line_1</Direct_Sel> </List_Control> </NET_RADIO> </YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":4500,"wires":[["6dfcab8d82492401"]]},{"id":"6dfcab8d82492401","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1570,"y":4440,"wires":[["ab106eecc3343e3c"]]},{"id":"7ebe2b96cbc8fdfe","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1570,"y":4540,"wires":[["e34a73115e60896b"]]},{"id":"0ddeb2bb12f69618","type":"template","z":"3d9125fd.0a2f6a","name":"Select Favorite from msg.fav","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"PUT\"> <NET_RADIO> <List_Control> <Direct_Sel>Line_{{{fav}}}</Direct_Sel> </List_Control> </NET_RADIO> </YAMAHA_AV>","output":"str","x":1340,"y":4540,"wires":[["7ebe2b96cbc8fdfe"]]},{"id":"64b3a1aa24f08ef4","type":"change","z":"3d9125fd.0a2f6a","name":"Get Amp Basic Status","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <YAMAHA_AV cmd=\"GET\"> <Main_Zone> <Basic_Status>GetParam</Basic_Status> </Main_Zone> </YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":4320,"wires":[["492253c7cb1c371d"]]},{"id":"492253c7cb1c371d","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1050,"y":4320,"wires":[["4da91384494de5ed","06c5b0fb2739bb75"]]},{"id":"4da91384494de5ed","type":"switch","z":"3d9125fd.0a2f6a","name":"Power on?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"<Power>Standby</Power>","vt":"str"},{"t":"cont","v":"<Power>On</Power>","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":4320,"wires":[["217d10470dea87a9"],["845971e20de6eb69"]]},{"id":"83cde9e9b2258591","type":"inject","z":"3d9125fd.0a2f6a","name":"Favorite 1 (BBC 6Music)","props":[{"p":"fav","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":190,"y":4340,"wires":[["64b3a1aa24f08ef4"]]},{"id":"a6884f5f0979ce3e","type":"comment","z":"3d9125fd.0a2f6a","name":"Menu Select","info":"Menu 1 = Bookmarks, Locations, Genres etc\nMenu 2 = Name of your Bookmarks folder on ytuners.com\nMenu 3 = Favorites list\n\nI want Menu 1 \"Bookmarks\" > Menu 2 \"Bookmarks\" > Menu 3 \"fav 1\"\n\nSo for me it was option 1 on the first two menus and then menu 3 takes the msg.fav number to choose which one to play ","x":1030,"y":4440,"wires":[]},{"id":"c710b54ca8beccf4","type":"comment","z":"3d9125fd.0a2f6a","name":"Play 6music on Yamaha v475 amp - Using HTTP POST requests","info":"I was previously using the https://www.home-assistant.io/integrations/yamaha/ integration, and still do for everything apart from turning on the internet radio stations. It did work but I think it must have been updated to use the rest api that comes with more recent models. but the only bit that seemed to break was NET Radio\n\nwith that integration I used to be able to do all this with a service call that just contained...\n\n```\nservice: media_player.play_media\ndata:\n entity_id: media_player.yamaha_rx_v475\n media_content_id: Bookmarks>Bookmarks>BBC Radio 6 Music\n media_content_type: NET RADIO\n```\n","x":290,"y":4180,"wires":[]},{"id":"06c5b0fb2739bb75","type":"debug","z":"3d9125fd.0a2f6a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1210,"y":4260,"wires":[]},{"id":"e34a73115e60896b","type":"change","z":"3d9125fd.0a2f6a","name":"Direct Sound = On","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?><YAMAHA_AV cmd=\"PUT\"><Main_Zone><Sound_Video><Direct><Mode>On</Mode></Direct></Sound_Video></Main_Zone></YAMAHA_AV>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1770,"y":4540,"wires":[["0f9ffc6345b00731"]]},{"id":"0f9ffc6345b00731","type":"http request","z":"3d9125fd.0a2f6a","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.86.36/YamahaRemoteControl/ctrl","tls":"","persist":false,"proxy":"","authType":"","x":1970,"y":4540,"wires":[[]]},{"id":"505102e8b5ac31d1","type":"debug","z":"3d9125fd.0a2f6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":4580,"wires":[]}]
I was previously using the https://www.home-assistant.io/integrations/yamaha/ integration, and still do for everything apart from turning on the internet radio stations. It did work but I think it must have been updated to use the rest api that comes with more recent models. but the only bit that seemed to break was NET Radio
with that integration I used to be able to do all this with a service call that just contained...
service: media_player.play_media
data:
entity_id: media_player.yamaha_rx_v475
media_content_id: Bookmarks>Bookmarks>BBC Radio 6 Music
media_content_type: NET RADIO
Thank you so much for you help on this github. I had no idea how to do this, or had ever heard of MITMproxy. It was an enjoyable hole to fall down.
You are very welcome! Nice that it worked out for you. Will keep this issue open until I have time to add your requests to this docs. I am not 100% sure but the official home assistant yamaha plugin should still support this "old" API. As the newer one (MusicCast) has a separate plugin. Maybe you could create an issue on their github issue tracker.
Any chance you can work out how to open a net radio station? It is definatly do able because it has been working via home assistant on my v475. but they seam to have updated there code to use the rest API which newer yamaha avrs but not on my v475.
I think you need a small subscription to make internet radio stations work. https://yradio.vtuner.com If you would like me to buy you this so you can play with it I don't think it it that much.
I would be very grateful Chris