Harmony Remote Activities & Media Player

My apologies if the answer is already somewhere, but I’ve done quite a bit of reading and Googling but been unable to find it.

I’ve got my Harmony Hub connected to HASS and it is working. I can turn activities on/off with it.
My next step is to connect HASS to homekit, found a number of examples on this and don’t foresee anything I can’t get figured out.

In the examples, they use switches to map the activities from the Harmony to Homekit. The checking the documentation for HASS with HomeKit I noticed there is also something called mediaplayer.
Looking at that, it not only provides On/Off but using it I could also easily state to play, pause, turn up volume, turn down volume, mute, …

Now my question is, is it be possible to create like a “virtual” mediaplayer without having an actual media player device and then mapping the respective functions to scripts for my Harmony? And thus providing the Harmony activity to HomeKit as a media player instead and not a switch?

Thx.

The switches that are used to turnon/turnoff activities are template switches:

Here’s a few examples pulled from my configuration, this would go into your switch section in the configuration.yaml:

  - platform: template
    switches:
        # XBOX HARMONY ACTIVITY
        xbox_one:
          value_template: "{{ is_state_attr('remote.living_room', 'current_activity', 'Xbox One') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.living_room
              activity: 'Xbox One'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.living_room
              activity: 'PowerOff'
        
        # PLAYSTATION HARMONY ACTIVITY
        ps4:
          value_template: "{{ is_state_attr('remote.living_room', 'current_activity', 'PS4') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.living_room
              activity: 'PS4'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.living_room
              activity: 'PowerOff'

A virtual media player can also be created. I don’t have an example of this, but here is the documentation:

Thx, I have it working with switches as well but for my activities that I have related to media I would prefer it to be as a media player instead. But for that I would need to create a media player similar like you show with the template switches.

I had looked at the Universal, the problem is that it required an ordered list of child media players the entity will control. I do not have child media players in HASS as it is all through my Harmony remote. Hence I would need something similar like a template for media player then I think.

sounds like we need a template media player.

so you just want a media player control inside home assistant, correct?

I think that is indeed what would solve it. Have a media player template allowing one to create a media player entity similar as with the switch. Idea then being that within this template one would define what needs to be done for each action similar like one does for a switch.

This would be nice,

I have a harmony with home companion remote, controlling a TV + Receiver + Kodi media player combo. (+ other inputs to the receiver, like a PC )

What I’d want is a templated media player for each activity, then put all those media players behind 1 universal one that I can call ‘living room’ for example. This way I can make sure that I get 1 media player in the frontend per room (per harmony hub), and that the media players controls get passed to kodi, and the volume to my receiver.

Did anything ever come of this?

I’d love to be able to expose a harmony hub to Alexa so I can issue commands such as “turn up the living room TV” and have them routed to the media player template so that the AVR turns the volume up.

You can do that without home assistant

Yes, you can do this with Alexa. However, I’m looking to do it for Homekit, which does support mediaplayer and televisionmediaplayer device types. I would hate to have 20 switches between my two units when it could be feasible to have one object each in as a televisionmediaplayer as described in the HomeKit page:

“All media players that have tv as their device_class. Represented as Television and Remote accessories in HomeKit to control on / off, play / pause, select source, or volume increase / decrease, depending on supported_features of entity. Requires iOS 12.2/macOS 10.14.4 or later.”

Doesn’t this sound exactly like what a harmony does? I believe so.

Thanks!

The only way to bridge any media player to Alexa is to use NabuCasa or HAASKA. Emulated hue does not support media players.

HAASKA - You have to build your own commands from the ground up. This whole process can be very time consuming.

NabuCasa (Paid monthly service) - Super easy to set up, but costs money. Money goes to developing home assistant though, so this is a good thing.

There are other ways that require you to get inventive with the limitations of emulated hue. Like making a template light that acts as volume slider for your media player.

This is why I pretty much said

Because he’s using harmony and you don’t need to go through HA for that. Would be way easier to go around HA.

I know this is a little old, but…

I followed the universal media player link above and it has a harmony example setup which i followed and now in Hass, I have a nice setup for the harmony. I have two issues which I cannot get past:

  1. Even thoughI have conifguration for the volume level, it is not showing up in Hass. On my Denon, I can see the volume level just fine. Mute and mute indicator works just fine.
  2. Still this setup does not show up correctly in Homekit. I can only control power, and it shows 11 accessories (for the harmony activities) that I cannot do anything to and they all show as on.

Does anyone have this working as well it works through homebridge? (not throwing shade cuz I love Hass and left homebridge for it, but…)

here is my config:

media_player:
  - platform: universal
    name: Family Room TV
    attributes:
      state: remote.harmony_hub
      source_list: remote.harmony_hub|activity_list
      source: remote.harmony_hub|current_activity
      is_volume_muted: media_player.denon_avr_s920w|is_volume_muted
      volume_level: media_player.denon_avr_s920w|volume_level
    commands:
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub
      turn_off:
        service: remote.turn_off
        target:
          entity_id: remote.harmony_hub
      volume_up:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: Denon AV Receiver
          command: VolumeUp
      volume_down:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: Denon AV Receiver
          command: VolumeDown
      volume_mute:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: Denon AV Receiver
          command: Mute
      select_source:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub
        data:
          activity: "{{ source }}"
    device_class: tv

Here is the homekit config, and I do not see anything about play/stop/volume in HomeKit either.

# Used for exposing media players.
  - name: "HASS Bridge TVs"
    port: 56335
    mode: accessory
    filter:
      # include_domains:
      #   - media_player
      include_entities:
        - media_player.family_room_tv
    entity_config:
      media_player.living_room:
        feature_list:
          - feature: on_off
          - feature: play_pause
          - feature: play_stop
          - feature: toggle_mute

Here is how it looks in HomeKit:

ok, figured out the first issue. I needed to add a volume_set to the media player like so:

      volume_set:
        service: media_player.volume_set
        target:
          entity_id: media_player.denon_avr_s920w
        data:
          volume_level: "{{ volume_level }}"

For anyone else that stumbles here later…seems like a few reboots fixed my issue. I now have the harmony showing up as I expected it in Homekit. Hooray to HA.

1 Like

@korey_sed It’s been a while since you posted your config. Has it been working well for you? I am going to try to use yours as a template for myself, as I would like to finally pull the plug on my Homebridge installation. Question - You have volume_up, volume_down, and volume_mute in your first iteration of your media_player config. But then you follow up later with a separate volume_set that you are adding to your media_player config. Did you keep the volume_up/down/mute after this edit, or did volume_set replace them? Would you mind sharing your full final config? Thanks so much!

So I am going through a reset and right now and for some reason HA is not discovering my Denon receiver again, but…

yes, I kept the volume up/down. The full config is below.

Note that the volume does not get exposed to HomeKit or I have not figured that part out yet. but if you do things this way, at least you will be able to control the volume from HA. Also, notice that the config is a mixture of knowing the current status through a different integration than harmony.

 - platform: universal
    name: Family Room TV
    attributes:
      state: remote.harmony_hub
      source_list: remote.harmony_hub|activity_list
      source: remote.harmony_hub|current_activity
      is_volume_muted: media_player.denon_avr_s920w|is_volume_muted
      volume_level: media_player.denon_avr_s920w|volume_level
    commands:
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub
      turn_off:
        service: remote.turn_off
        target:
          entity_id: remote.harmony_hub
      volume_up:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: "Denon AV Receiver"
          command: VolumeUp
      volume_down:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: "Denon AV Receiver"
          command: VolumeDown
      volume_mute:
        service: remote.send_command
        target:
          entity_id: remote.harmony_hub
        data:
          device: "Denon AV Receiver"
          command: Mute
      volume_set:
        service: media_player.volume_set
        target:
          entity_id: media_player.denon_avr_s920w
        data:
          volume_level: "{{ volume_level }}"
      select_source:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub
        data:
          activity: "{{ source }}"
    device_class: tv
2 Likes

Welp, I appreciate your help very much. But unfortunately, this isn’t working for me. I first took the simplest approach and added my harmony remote remote.family_room_harmony_hub to my HomeKit configuration. It came through to the Home app with all the activities listed, and I could successfully select activities. It also showed in the Remote widget. But that’s where the fun stopped. None of the buttons in the Remote widget worked.

So I then tried your config and pushed the new media_player.family_room_tv into HomeKit. It works perfectly in HA. But in HomeKit it is exactly the same as the original remote.family_room_harmony_hub. Bleh.

I’m not quite clear. What were you expecting in HomeKit? All I can do in HomeKit is also just to start an activity. Or turn off.

Sorry if I didn’t make that clear. I am referring to two different things - The Home app (HomeKit) and the Remote widget. The Home app works correctly with both configurations. Meaning, I can start an activity and turn the TV on/off using remote.family_room_harmony_hub or media_player.family_room_tv. The issue I am having is with the Remote widget. With both configurations, the TV shows up but none of the buttons work -

Thanks. I did not even know about that :(. learnt something new today.
will let you know if I figure anything out with it.

1 Like