Testers Needed - Harmony Hub Support Implemented in Python

Just sync’d the latest changes and allowed hass to install 1.0.9 and everything is working beautifully.

Thank you again @iandday!

Here’s what I’ve put together so far.

I’ve created an Input_Select with an item for each activity. I then created scripts to start each activity.

From there I created two sets of automations. One that selects the correct input on the selector when an activity is selected from the Harmony Remote. The other set watches for state changes on the input selector and launches the correct script when an activity is selected.

I’d be happy to post my code if anyone is interested.

3 Likes

Just updated pyharmony to version 1.0.10 to add some exception handling if timeouts occur when communicating with the hub.

I’ll still cant submit a pull request to HASS until i can get this damn coverage test to pass for /components/remote/init.py

@gazzer82, @BTallack, @Bahnburner: any experience with writing coverage test files??

Unfortunately, no.

For my (with the latest component/remote from the harmony branch) it fails to install pyharmony.

(homeassistant_venv) homeassistant@homepi:~ $ hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
16-11-12 17:20:24 ERROR (MainThread) [homeassistant.loader] Error loading homeassistant.components.remote.harmony. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/loader.py", line 139, in get_component
    module = importlib.import_module(path)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/remote/harmony.py", line 17, in <module>
    import pyharmony
ImportError: No module named 'pyharmony'

I previously had it installed manually but removed it after reading that HA should be able to do it itself once the component is loaded.

I install pyharmony manually and this is what I get in the logs:

16-11-12 17:29:04 INFO (MainThread) [homeassistant.loader] Loaded remote.harmony from homeassistant.components.remote.harmony
16-11-12 17:29:04 INFO (Thread-3) [homeassistant.components.remote.harmony] Loading Harmony component: Family Room
16-11-12 17:29:05 CRITICAL (Thread-3) [pyharmony.auth] Received response code 400 from Logitech.
16-11-12 17:29:05 CRITICAL (Thread-3) [pyharmony.auth] Data:
{"ErrorCode":1,"Id":"24b069b7-bee0-4fa9-b0cc-b2991edad1f2","Message":"Authentication failure BadCredentials  : Unable to authenticate user's mail with the corresponding password via LIP:: [email protected]","Source":"GetUserAuthToken"}

Logitech login failed for remote: Family Room

Your configuration seems really cool, mind sharing the code?

Hi All. Noob alert!

I’m running the All-in-one HASS, and haven’t yet got this to work.

i followed these instructions, thanks datamonkey

go to virtual environment

sudo su -s /bin/bash hass
source /srv/hass/hass_venv/bin/activate

download pyharmony

cd /tmp
wget https://github.com/iandday/pyharmony/tarball/1.0.7

install

pip install 1.0.7

but like iceball, i get this error:

Collecting 1.0.7
Could not find a version that satisfies the requirement 1.0.7 (from versions: )
No matching distribution found for 1.0.7

i thought i was being clever, so substituted 1.07 for 1.09 on the wget and the pip install, but it just does the same thing for 1.09

can anyone shed any light?

You don’t actually need to manually install pyharmony anymore. Hass will automatically install the current version (v1.0.10) on boot. So long as you add the remote component and update your configuration.yaml, you should be all set.

@mefistofelis I’ve created a new thread so as not to hijack this one with my full code:

@danpow That same thread also goes over how I installed it for me. It will be a bit different for you since you’re using a virtual environment but I bet you can make it work.

2 Likes

Like I mentioned earlier… I DO need to install pyharmony manually as Hass will NOT do it automatically… This could be the case for other users also.

@iandday seems like a sensible move.

No I’m afraid my skills lie in JavaScript, Go and Swift. That said I do have experience of unit testing on all those platforms so I’ll do some research and see if I can pitch in.

Been meaning to learn python properly for a while anyways!

Maybe PM me with the specific issue with coverage you’re having?

Cheers

Gareth

I completely wiped my setup yesterday and Hass was able to install 1.0.9 without any action in my part beyond adding the remote folder to components and updating my yaml. This was done on an RPi3 with an AIO installed build.

1 Like

@iandday looks like it’s still creating the .conf file on every startup rather than just the first launch. I assume this is unintended behaviour? I know you built it so that a manual sync can be triggered later. This does add a fair bit off time to load time in HASS.

DEBUG:homeassistant.components.remote.harmony:writing hub configuration to file: /home/pi/.homeassistant/harmony_living_room_tv.conf

That was the intended behavior, to overwrite the conf file at each boot to catch any changes made to the hub’s configuration by other applications. Now that you bring it up it’s much more likely that HASS will be rebooting that the hub’s configuration will change. I’ll change it to write the conf file only if it’s not present and to overwrite it when the sync service is called

1 Like

Sounds great. Let me know when you’ve committed the changes and I’ll test it out.

give it a shot, I’ll be interested to see the increase in startup times you see while on a rpi, I have hass on esxi so the time difference was negligible.

Easily 30-40 seconds quicker now. From cold service start it takes about thirty seconds to launch Home Assistant now. It took well over a minute before having to write the conf file.

Edit: I’m deleting the conf file now and I’ll time it with and without file creation.

Launch time including creating the conf file: 1:27
Launch time without creating the conf file: 0:27

This is the amount of time from when I launched the service until the web interface could be loaded.

This is on a Raspberry Pi 3 running Raspbian Jessie Lite

wow that’s quite an improvement!

2 Likes

Thanks @iandday got this working really well using @BTallack guide as well but just have an issue with one activity. My TV is hooked up to a home cinema receiver and if I switch from any activity to the satellite box, it all works correctly switching inputs as it should but I have no sound.I can see the amp volume going up and down when I control volume so I’m fairly certain it’s a HDMI handshake issue. I could be way off here but I have a feeling the commands are being sent too quickly in the activity sequence. When I change activities with the physical remote, it takes a bit longer than using your code. Could this be the case or does your code only trigger the hub to start an activity as it would if I selected it using the remote?