Alexa, switch Audio on!

So, a few weeks ago, Alexa moved in. It was price-reduced on Amazon, so I decided to buy an Echo Dot just for fun. After the first obligatory “Alexa, tell a joke” and “Alexa, play …” attempts, I soon faced the first problem: to improve audio quality I connected the Dot to my Yamaha RX-V475 receiver. Of course then the Dot would not be heard unless I switched the receiver to Audio In.

So there were two topics on the list:

  1. The receiver can be controlled via WLAN using an App, so there must be information on the protocol
  2. How do I connect Alexa and my receiver on the WLAN without creating my own skill?

It turned out that there actually is some information about how to control the RX-V475 via WLAN on the net, but also, that this information is highly incomplete and in some cases even wrong. I actually analyzed the source codes of the FHEM Yamaha-module to get things running.

The solution to the problem of connecting Alexa and my receiver is actually very simple. It’s called HA Bridge. HA Bridge is a piece of Java software you ran run on any machine on your network. It emulates a HUE bridge device and provides a very structured web interface for configuration. It took me about 5 minutes to get it running on the Raspberry PI 3 that I use as a multimedia server on my network.

HA Bridge’s key feature that solves my problem 2) is that you can configure the ON, OFF and DIM commands to issue HTTP requests of any kind to any given URL with configurable payload.  The receiver’s web service URL is simple:

http://<IP Address>/YamahaRemoteControl/ctrl

So the real question was, which payload to send to the receivers web service URL. Turned out that some information on the internet was actually wrong. The following payload worked for me:

Switch on

<YAMAHA_AV cmd="PUT">
<Main_Zone>
  <Power_Control>
    <Power>On</Power>
  </Power_Control>
</Main_Zone>
</YAMAHA_AV>

Switch off

<YAMAHA_AV cmd="PUT">
<Main_Zone>
  <Power_Control>
    <Power>Standby</Power>
  </Power_Control>
</Main_Zone>
</YAMAHA_AV>

Dim (volume)

<YAMAHA_AV cmd="PUT">
<Main_Zone>
  <Volume>
    <Lvl>
      <Val>${intensity.math(int((X / 255.0) * 97.0 - 80.5)*10.0)}</Val>
      <Exp>1</Exp>
      <Unit>dB</Unit>
    </Lvl>
  </Volume>
</Main_Zone>
</YAMAHA_AV>