Home Assistant and Harmony Hub Scripts

Last Updated or created 2024-02-29

I’ve got a Logitech Harmony Hub to IR control devices.

When adding this to your home assistant, you initially only get the Activities.

But I want to add single button presses.
I was going to re-visit my IR remote project.
(The IR blaster and the IR wemos, see previous posts)

Thanks to Duncan I had a second look at this solution

Check the files using the file editor.
Search for /homeassistant/harmony_xxxxxxxx.conf

It will show the Hub devices and their capabilities.

Short example below

{
    "Activities": {
        "-1": "PowerOff",
        "42652474": "Watch TV",
        "43054933": "Squeeze",
        "43054959": "Watch Netflix",
        "43072690": "Switch",
        "43073688": "Spotify",
        "43557114": "Kodi",
        "49494467": "Tv on",
        "52476284": "Boxon",
        "52476285": "Boxoff"
    },
    "Devices": {
        "Google Chromecast": {
            "commands": [],
            "id": "67134460"
        },
        "LG TV": {
            "commands": [
                "PowerOff",
                "PowerOn",
                "PowerToggle",
                ".",
                "-",
                "0",
 -----------8<----------------------------- SNIP SNAP
               "SportsMode"
            ],
            "id": "67134658"
        },
        "Onkyo AV Receiver": {
            "commands": [
                "PowerOff",
                "PowerOn",
 -----------8<----------------------------- SNIP SNAP
                "VolumeLevelUp5Step"
            ],
            "id": "67134459"
        },
        "arcadyan DVR": {
            "commands": [
                "PowerToggle",
 -----------8<----------------------------- SNIP SNAP
                "TV"
            ],
            "id": "67134775"
        }
    }
}

Lets create a Script for this

See the IDs above to refer to commands below.

alias: Netflix
sequence:
  - service: remote.send_command
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 1.2
      command: PowerOn
      device: "67134658"
  - service: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: InputStb/Dvr
      device: "67134459"
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
  - service: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: Netflix
      device: "67134658"
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
mode: single

Add these scripts to buttons

type: entities
entities:
  - script.allmediaoff
  - script.netflix
  - script.tvon

Leave a Reply

Your email address will not be published. Required fields are marked *