Harmony Hub Device Control

I’m a bit stuck on controlling individual Harmony Hub devices in HA, the HA harmony documentation doesn’t help as I don’t have the knowledge to decipher what to do with that information yet, I’m missing key info which is a lack of knowledge on my part. I can set up actions with the activities etc but I want to use my Aqara cube switch to increase/decrease volume of an amplifier connected to Harmony. I know there is some script to be written and I know where the info is in the config files but I’m at a loss to work out how to create a script/action/service that I can then call in an automation. Can someone point me towards an idiots guide/sticky on how to do this? I’ve searched the forums for about an hour and can’t find anything. :frowning:

In your config file, look for the Harmony config file. That file will list all of your devices and available commands. You’ll need the device ID and the command you want to use.
In automations, you’ll use the Remote: Send Command Service as the action.
Example using my receiver and setting the surround mode:

service: remote.send_command
data:
  device: "65890902"
  command: ModeDirect
target:
  entity_id: remote.harmony_hub

1 Like

That’s great, thanks. I’m filling in the gaps now. I’m certain I can write a service that can be called by the automation but I’m missing where I can get that “Remote: Send Command” element from, is this something I need to create somewhere as I’m not seeing a option in the triggers or actions list. Thanks for the reply.

Right, thanks for the clue @Rich37804, manage to get a couple of tests done after working out how to do it in “Scripts” in Settings->Automations->Scripts. After working out that the device ID was at the end of the command list and not the beginning :anguished: I got it sorted:

image

Thanks for the steer

Can you give a bit more of a hint as to how you formatted your script to be able to be called by a button. When I go to create a new script, at the beginning it wants

alias: New Script
sequence: []

And using Rich’s advice I want to call this button from harmony to turn my amp on. Where do I add it to make the script work so I can call it on a dashboard button?

service: remote.send.command
data:
  device: "71697856"
  command: PowerOn
target:
  entity_id: remote.cinema

I ended up getting it working on a button on a dashboard. Turns out you can select call a service from the UI and it prompts you for the other info. After looking at the code it looks something like this

  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: call-service
      service: remote.send_command
      target:
        entity_id: remote.cinema
      data:
        num_repeats: 1
        delay_secs: 0.4
        hold_secs: 0
        device: '71697856'
        command: PowerOn
    icon: mdi:power-standby
    name: Power On Amp

Sorry, missed the post - it’s not often I’m on. Glad you figured it out.

Hi Guys, I’ve searched quite a bit and not finding how to expose / use Harmony Hub actions as automation triggers?

I need automations to run based on… Pause, Play, Stop. I see the Integration exposes Activity changes but I need to detect the state / remote commands

thx!

Use something like file editor. Search for the harmony directory. It gives you device id numbers and commands. You then work these into your automations. I use a lot of scripts. When making scripts make sure to choose your harmony hub as the entity. And, use perform action send command or list of commands. Check device id, input id number. Input Command, etc…hope this helps. It took me a while too. I have 4 hubs and remotes working now.

Could you post an once of your scripts for people to work off of

… so, it doesn’t look like there’s any way to send commands like the remote does? where you just fire off a volume up or pause or play, and it knows which device based on the activity that’s enabled? You have to send a device id with it, which basically is eliminating one of the Harmony’s most useful features. I want to wire up a button that will tell Harmony to play/pause, not a specific other device.

Can that be done with this integration?

A simple script example of pressing ok on my firestick remote. I used the UI to create this YAML. You just need to know the device id and command which you get from the harmony.conf file. Use file editor to view harmony.conf file. I hope this helps.

sequence:
  - action: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      device: "69742254"
      command: OK
    target:
      entity_id: remote.living_room
alias: Press OK
description: ""

sure, but that ignores the purpose of the Harmony. To properly implement a play/pause button if i have to give a device id, i’d have to check the Harmony’s activity state, then send the appropriate command to whichever device is playing. Harmony already knows how to do that, it’s just … not exposed? or not available? i’m not sure which. It’s not useful to have an integration that specifically invalidates one of the main use cases of Harmony – that it already knows what devices are being used to play and to control volume and that they can be different on each activity.

edit: yeah i just dug around for a little bit. it looks like it’s just flat out missing that functionality. other things like harmony-api can do that, send commands to the current activity, so your volume up/down and play/pause always go to the right device.

I’ve been using this script to use ‘buttons’ that will send the required command to the required device.

If the command is the same on each device (e.g OK), you can just use command: OK instead of the if/else.

There is one for each button, just copy and change as required.

media_ok:
  alias: Media OK
  sequence:
    - data:
        entity_id: remote.living_room
      data_template:
        device: >
          {% if is_state_attr('remote.living_room', 'current_activity', 'Watch TV') %}
            Ziggo DVR
          {% elif is_state_attr('remote.living_room', 'current_activity', 'Watch Chromecast') %}
            Google Media Player
          {% elif is_state_attr('remote.living_room', 'current_activity', 'Smart TV') %}
            Living Room TV
          {% else %}
            Windows Computer
          {% endif %}
        command: >
          {% if is_state_attr('remote.living_room', 'current_activity', 'Watch TV') %}
            Select
          {% elif is_state_attr('remote.living_room', 'current_activity', 'Watch Chromecast') %}
            Select
          {% elif is_state_attr('remote.living_room', 'current_activity', 'Smart TV') %}
            OK
          {% else %}
            OK
          {% endif %}
      service: remote.send_command

Thanks for that, that looks like a sort of easy path to it.
If/When I find a little time with nothing else going on, I’ll compare the harmony-api library which actually has the capability to do all of that, versus the partially implemented python library that this integration uses. It might be simple to add it to the python library