Testers Needed - Harmony Hub Support Implemented in Python

@iandday - so far (after minor install issues) this component is really cool, some notes from my use / experience:

  • ISSUE: After rebooting my Pi3 which runs HASS, I need to remove the harmony_conf_XXX.txt file and restart HASS (all other types of HASS restart do not require this step, only full power cycle of the Pi)

  • POSSIBLE ISSUE: I find that the frontend can sometimes take a long time to reflect reality (up to a couple of minutes) - this is both for “switches” (input_boolean) and the sensor itself - the most noticeable occurrence is when using my Amazon Echo to turn on an activity, Alexa responds with “OK” then a varying period of time before the activity actually starts

Despite the “possible issue” listed above, I love being able to get Alexa to turn on / off my stereo! Great work!
Let me know if any additional details would be helpful…

Remember that in order to do this, you’re going through two clouds and three APIs to make it happen. That introduces a a bit of lag time.

Thanks for the feedback. Does HASS fail to start after a reboot if the conf file is not removed?

Is there any way you can sanitize some logs for me that include a few actions involving the harmony remote? I’d like to see how much the times are varying between activating the “switch” and the remote’s current_activity being updated.

In the meantime I need to read up on Async operations, I rebased my fork to bring it current and am not having some strange errors when I have more than one hub specified in my config files

Does HASS fail to start after a reboot if the conf file is not removed?

Correct, HASS simply hangs and never becomes “truly active”. I can’t browse to it, or interact with it, despite the process remaining active. I kill the process, delete the file and “hey presto”, HASS starts, a new config file is generated.

Is there any way you can sanitize some logs for me that include a few actions involving the harmony remote?

I will look through some logs and give you as much as I can - was thinking of recording a video or something too - will see what I have time for!

Thanks for getting back to me.

@Iandday Do you have an example of a working action using the send command service? I can’t get my hub to respond to the request, and home assistant isn’t logging any errors.

Here’s the action I’m attempting to trigger:

    action:
      service: remote.turn_on
      entity_id: remote.living_room
      data: {"device": "35163109", "command": "Pause"}

and here’s the section of my harmony_conf.txt for the device I"m trying to control:

 35163109 - Direct TV DVR
    PowerOff
    PowerOn
    NumberEnter
    Hyphen
    Number0
    Number1
    Number2
    Number3
    Number4
    Number5
    Number6
    Number7
    Number8
    Number9
    PrevChannel
    ChannelDown
    ChannelUp
    DirectionDown
    DirectionLeft
    DirectionRight
    DirectionUp
    Select
    Stop
    Play
    Rewind
    Pause
    FastForward
    Record
    SkipBackward
    SkipForward
    Menu
    Back
    List
    Green
    Red
    Blue
    Yellow
    Guide
    Info
    Exit
    RedCircle

I dont have any examples that include sending a specific command, only starting an activity. In your example it looks like you specified the start_activity service instead of the send_command service. That might be what’s causing your issue

bedroom_tv_on:      
  alias: "Fox HD"
  sequence:
    - service: remote.turn_on
      data:
        entity_id: remote.bedroom
        activity: 15601182
    - service: shell_command.bedroom_kodi_start

Thank you for catching that. I’ll re-test when I get home.

I just installed this myself and was able to get it working quickly.

I too am experiencing a lot of latency between commands. As someone else pointed out, that might be because it’s going through a bunch of stuff. On that note, is there any hope of communicating with the Harmony Hub locally? I am not sure which route of communication that harmony-api uses (Node.js), but it is lightning fast and doesn’t miss a beat.

Aside from that, my thoughts/ideas would be:

  • Slugify the name when creating the harmony_conf.txt file
  • Switch to using the extension .conf to conform with other components
  • Allow devices to be called by name, instead of just by ID
  • Somehow add activities and devices to the attributes of the remote

If I think of any more, I’ll be more than happy to share.

Thanks again for all of your hard work in bringing this to light. This is something that has been missing from Home Assistant for far too long!

I think I can rework the underlying module to query the config once at boot instead of each time a command is called, that should slow it down.

Pyharmony does communicate with the hub locally, it only has to reach out to Harmony’s servers to swap the credentials for an auth code, all the rest is done with the XMPP server in the hub.

I initially thought about activities and devices being added as attributes but thought that would make the state screen pretty polluted. The externally generated file would still be needed to reference the available commands per device.

I’ll post an update if I can get the speed increased

1 Like

For reference, I don’t seem to have an issue with the config file existing at Pi startup anymore (updated to latest).

Still not had a chance to capture the delays - what are the most useful logs / items for you to see?

Also, for anyone else in this post, this is my config:

# Harmony (iandday test components) - needs manually added files in "/usr/local/lib/python3.4/dist-packages/homeassistant/remote"
remote:
 - platform: harmony
   name: bedroom_harmony
   username: !secret harmony_user
   password: !secret harmony_password
   host: !secret bedroom_harmony_ip
   port: 5222

# Current Harmony Status - needs "remote" components
sensor beroom_harmony:
 - platform: template
   sensors:
      bedroom_harmony:
         value_template: '{{ states.remote.bedroom_harmony.attributes.current_activity }}'
         friendly_name: 'Current Activity'

# Harmony activity "switch" for frontend
input_boolean:
   bedroom_harmony_sonos:
      name: Sonos Activity
      initial: off

# Automation for Bedroom Harmony "switches"
automation bedroom_harmony:
# Uses bedroom_harmony_sonos "switch" to turn on the Sonos activity
 - alias: "Listen to Sonos - On"
   hide_entity: True
   trigger:
      platform: state
      entity_id: input_boolean.bedroom_harmony_sonos
      state: 'on'
   action:
      service: remote.turn_on
      data: 
         entity_id: remote.bedroom_harmony
         activity: Listen to Sonos

# Uses bedroom_harmony_sonos "switch" to turn off the Sonos activity, includes condition to ensure it is turned on first
 - alias: "Listen to Sonos - Off"
   hide_entity: True
   trigger:
      platform: state
      entity_id: input_boolean.bedroom_harmony_sonos
      state: 'off'
   condition:
      condition: template
      value_template: '{{ states.remote.bedroom_harmony.attributes.current_activity == "Listen to Sonos"}}'
   action:
      service: remote.turn_on
      data: 
         entity_id: remote.bedroom_harmony
         activity: PowerOff

# Uses current harmony status to inform the correct position of the bedroom_harmony_sonos "switch"
 - alias: "Listen to Sonos - started from harmony hub"
   hide_entity: True
   trigger:
      platform: state
      entity_id: remote.bedroom_harmony
   condition:
      condition: template
      value_template: '{{ states.remote.bedroom_harmony.attributes.current_activity == "Listen to Sonos"}}'
   action:
      service: input_boolean.turn_on
      entity_id: input_boolean.bedroom_harmony_sonos

# Uses current harmony status to inform the correct position of the bedroom_harmony_sonos "switch"
 - alias: "Listen to Sonos - stopped from harmony hub"
   hide_entity: True
   trigger:
      platform: state
      entity_id: remote.bedroom_harmony
   condition:
      condition: template
      value_template: '{{ states.remote.bedroom_harmony.attributes.current_activity != "Listen to Sonos"}}'
   action:
      service: input_boolean.turn_off
      entity_id: input_boolean.bedroom_harmony_sonos

Okay so I got this running via Docker on my Synology NAS. Here’s what I did

  1. Copied the GitHub folder from the branch into my config/custom_components directory
  2. As others have mentioned this doesn’t work, so I opened a bash connection into my docker container by running docker exec -it home-assistant /bin/bash
  3. I then copied the remote component into Home Assistant cp -r /config/custom_components/remote /usr/src/app/homeassistant/components
  4. Setup my configuration.yaml using the code below
remote:
  - platform: harmony
    name: Living Room
    username: 
    password: 
    host: 192.168.1.5
    port: 5222
    activity: WatchPlex

Presto! It worked.

Now onto my issues. Straight away, I had problems with my remote. I tried to turn on an activity on my remote, but the touch screen would not respond to anything. I could switch between devices and activities fine, but as soon as I tried to press an activity like “Watch TV”, nothing would happen on the remote. Then all of a sudden, a message came up saying “cannot communicate with Hub, try moving closer”. I’ve never seen that before.

Eventually, I tried another activity and it started. The TV turned on and it was loud! So I tried to press the mute button. Nothing. Tried to turn the volume down, nothing. Interestingly I could change the channel though.

I went back to my PC and shut down Home Assistant docker stop home-assistant and once stopped, I could control the volume on my TV again (Sonos Playbar using HTTP control from Harmony Hub).

After confirming my remote was working again, I restarted Home Assistant docker start home-assistant and once booted, my remote immediately became unresponsive. It took about 2 minutes for my remote to change a TV channel, and I once again can’t control the volume on my Sonos Playbar. I’ve also been unable to use the remote service to change the activity.

I’ve updated pyharmony to a new version as well as the remote code. Prior versions were logging into Logitech’s servers at each request to swap credentials for a token which is needed to authenticate to the local hub. This version logs into the servers at boot and reuses the token, the token appears to be fairly static, mine has stayed the same over the past three days. The reaction times have improved on my setup, hopefully everyone else is the same.

I’ve changed the generated file by sluggifying the remote’s name and changing the extension to ‘conf’.

@philhawthorne
It sounds like your hub was getting hit to hard with requests. Can you delete the remote directory in custom_components directory and replace the remote directory in your HASS installation directory? Hopefully the new method will not interfere with your remote.

Will do

Just to confirm, all I need to do is the following?

  1. Grab the latest code from your fork on GitHub and replace it into the components directory
  2. Restart HASS, which will update the dependencies? Or do I need to run another pip install command to update that?

Okay looks like things are more stable now

  1. Downloaded a new copy of your GitHub component
  2. Copied this into my docker, and removed the custom_component directory
  3. Updated pyharmony by running pip install --upgrade pyharmony in the container

There’s about a 20-30 second delay before the status updates, which is okay. I’ll keep this enabled and report anything that comes up.

THANK YOU

Hi,

I’m very excited to see that a Harmony Hub plugin is being developed for Home Assistant. Thank you!

However, I’ve just installed it using pip inside the virtual environment and I’m not sure what I’m doing wrong but I get the following result when I check the config:

(homeassistant_venv) homeassistant@homepi:~/.homeassistant $ hass --script check_config                  Testing configuration at /home/homeassistant/.homeassistant
16-10-31 19:09:40 ERROR (Thread-1) [homeassistant.loader] Unable to find component harmony
Failed config
  General Errors:
    - Component not found: harmony

Successful config (partial)

If I run it directly from where it was installed it seems to work, but if I call it as shown some posts above it fails.

(homeassistant_venv) homeassistant@homepi:~/.homeassistant $ /srv/homeassistant/homeassistant_venv/bin/harmony
usage: harmony [-h] --email EMAIL --password PASSWORD --harmony_ip HARMONY_IP
               --harmony_port HARMONY_PORT
               [--loglevel {WARNING,DEBUG,INFO,ERROR,CRITICAL}]
               {show_config,show_current_activity,start_activity,power_off,sync,send_command}
               ...
harmony: error: the following arguments are required: --email, --password, --harmony_ip, --harmony_port
(homeassistant_venv) homeassistant@homepi:~/.homeassistant $ python3 pyharmony
python3: can't open file 'pyharmony': [Errno 2] No such file or directory

What have I done wrong? Any tips greatly appreciated.

Thanks in advance.

Regards,
Michal

Hey Michal

Can you post your configuration.yaml entry (be sure to take our your username and password)

It’s the definition of basic:

harmony:
  - name: Family Room
    username: [email protected]
    password: !password
    ip: HarmonyHub
    port: 5222

HarmonyHub resolves to the correct ip so that shouldn’t be an issue.

You need to use the remote platform, like below:

That’s great to hear!

The scan interval is set to 30 seconds, so you might have been right on the edge of the scan interval. I tried to manually update the status in the turn_on activity but it doesnt seem to have any effect. If you’re feeling saucy you can try to lower the value on line 29 of init.py and see if it interferes with the remote, I’d love to hear the results.