Control AV Receiver Zone 2 with Harmony Hub (and Alexa)

Home Theater, Smart Home

I recently upgraded to a 4K-capable AV receiver and had to update my Harmony Hub devices and activities. When I did, I noticed that the commands for controlling zone 2 of the new receiver were not available in the Harmony app (whereas they were available for my previous receiver). Initially I thought I’d just need to add the missing commands via the app by “teaching” the hub with the receiver’s remote. However, it turns out that the Harmony Hub handles multi-zone devices by adding the additional zones as separate devices in the Harmony app. I don’t know how long this has been a standard practice, but I never had to do this with my previous two receivers—just with this new receiver. Once I added the “zone 2” version of my receiver all the zone 2 commands were available for that “device.”

I actually kind of like this approach, because it creates a clear separation between controls. It also allows for more potential in tracking device state. The instructions I linked to also explain how to set things up so that you can use activities to play content in multiple zones. This is probably a great solution for many users. I dabbled with this, but ultimately I decided that I simply want to be able to turn on/off zone 2 using Alexa or the receiver controls in the Harmony app, not start or switch activities to control zone 2.

Using Alexa to Control Zone 2

I’ve been using Home Assistant running on a Raspberry Pi for a lot of home automation goodness, so I decided to leverage it to allow Alexa to control my patio speakers using the Emulated Hue Bridge component and the Harmony Hub Remote component. My goals are:

  • Have a toggle switch in the Home Assistant UI for turning zone 2 on and off
  • Expose this toggle switch to Alexa so I can use voice commands to turn zone 2 on and off
  • Avoid relying on or interfering with Harmony activities (i.e. if I turn off zone 2 I don’t want my Watch TV activity to turn off if someone is watching it)

To start with, my Harmony Hub was automatically discovered by Home Assistant because I left the discovery component in the configuration.yaml file (it’s there by default I believe). This creates a harmony_harmony_hub.conf file in the same directory as the configuration.yaml file (your file may be named slightly different if you assigned a different name to your Harmony Hub via the Harmony app). This file lists all of the activities, devices, and commands that are available to use. I looked in this file for the commands to turn on and off zone 2. They should look something like this:

Device Commands
  ...
  48214390 - Onkyo AV Receiver (2)
    PowerOff
    PowerOn
    PowerToggle
    Mute
    VolumeDown
    VolumeUp
    ...

The numbers before the device name are what you use to send commands, sort of like an entity_id in Home Assistant. The commands below it are the actual commands to send, and they are human-readable which makes them easy to refer to.

Next I added an input boolean to my Home Assistant configuration.yaml file that I will use to switch zone 2 on and off:

input_boolean:
  toggle_patio_speakers:
    name: Patio Speakers
    initial: off
    icon: mdi:speaker

I also exposed this input boolean to the Emulated Hue Bridge component in my customize.yaml file:

input_boolean.toggle_patio_speakers:
  emulated_hue_hidden: false
  friendly_name: Patio Speakers

This enables Alexa to toggle the input_boolean on and off. To make that actually do something, I set up two automations to watch for changes to the input—one for turning on and one for turning off—and send the appropriate commands. I used the Automations UI which generated the following code in automations.yaml:

- action:
  - data:
      command: PowerOn
      device: 48214390
      entity_id: remote.harmony_hub
    service: remote.send_command
  alias: Utility - Turn on Patio Speakers
  condition: []
  id: '1508113229041'
  trigger:
  - entity_id: input_boolean.toggle_patio_speakers
    from: 'off'
    platform: state
    to: 'on'
- action:
  - data:
      command: PowerOff
      device: 48214390
      entity_id: remote.harmony_hub
    service: remote.send_command
  alias: Utility - Turn Off Patio Speakers
  condition: []
  id: '1508113319106'
  trigger:
  - entity_id: input_boolean.toggle_patio_speakers
    from: 'on'
    platform: state
    to: 'off'

At this point I verified my configuration and restarted Home Assistant. After it loaded I was able to find the new input_boolean via the Alexa app and say “turn on the patio speakers” or “turn off the patio speakers” to control zone 2’s power. For most receivers, turning on zone 2 simply uses the input that it was using when it was last powered off. For my particular receiver (and my previous one), I could instead use the “turn on” automation to set the zone 2 input to the FM tuner, for example, and the receiver would both turn on power to zone 2 and set the input. So the zone 2 input commands are essentially PowerOn commands too.

Final Thoughts

One potential downside to using Logitech’s recommended method of adding/controlling zone 2 as a separate device is that one of your device slots is used up. All of the Harmony remotes/hubs have a limit to the total devices they can control. That’s where adding the zone 2 commands as custom commands to the “main” receiver device instead of a separate device can be useful.

Depending on the receiver, you may not need to use the Harmony Hub at all if you have Home Assistant. My receiver is networked, and there is an Onkyo component for Home Assistant that enables some control, but it does not seem to support zone 2 at this time so I have to go through the Harmony Hub. Hopefully in the future I can bypass the Harmony Hub and simply send commands directly to the receiver over the network.