Testers Needed - Harmony Hub Support Implemented in Python

@iandday did the config files show anything obvious? Would really like to get this working.

If I get time tomorrow I will backup my settings and start with a fresh config, see if that changes anything.

Cheers

Gareth

@iandday I’m having the same issue as @gazzer82 after updating from 1.0.7 to 1.0.9. It just hangs on Loading Harmony component.

Nov 09 04:33:34 raspberrypi hass[10074]: 16-11-09 04:33:34 INFO (Thread-4) [homeassistant.components.remote.harmony] Loading Harmony component: Living Room

I’ve been restarting HA hundreds of times today trying to get some components to install and tweaking the configuration (oh how I wish it just auto reloaded the config file and just acted on changes to the config!)…

What I found was that about 80% of the time the Harmony remote component fails to start, but sometimes it starts just fine. Not sure if it’s to do with logging into the Logitech cloud or what.

I think the password being passed to the MyHarmony servers is being mangled somehow?

I just tried to log in (for the first time) with the Windows app and it has told me after the very first attempt to log in that “Your account has been locked due to multiple login attempts with incorrect password. Please try again after 30 minutes.”

Either that or it treats frequent logins in the same manner as failed logins.

apologies for the delayed reply, work got away from me this week. I’m going to try to increase the debug level of output in pyharmony. I’m running the current version in both my prod and dev VMs without any issues. Hopefully the debugging output will help us track it down!

No apologies needed. Great work and I’m sure it will become rock solid as more and more people put it through its paces :slight_smile:

I can say however that in my experience it’s connected properly maybe 5% of the time. I suspect Logitech is to blame. Every time it fails I try to connect using the Windows app… And even if I had not tried to start HA more than once in a 24 hour period I STILL get the locked account message.

I have NO idea why they think there are multiple login attempts with the incorrect password even when I am not trying to log in at all. Total mystery to me…

As @mihalski says, no need for apologies at all, very much appreciate your hard work so far!

I tried this today with a completely clear config other than the Sonos Component and I had the same issues.

I also did a complete update of my raspbian install today to check I didn’t have an out of date component that was causing issues, same result.

Just in case there is come correlation, I am using raspbian (Jessie) lite on a pi3, network connection is hard wired and there is no crazy networking going on. I installed home assistant using the all in one installed.

Sonos wise, I have the following.

TV system compromised of a play sub, play bar and two play ones.

Bedroom play 3.

Kitchen play 5.

I am using wifi to connect so no play bridge.

What’s everyone else’s setup?

Cheers

Gareth

I don’t think the devices play a factor in the login failing.

I am however very interested in whether you use the Sonos Home Assistant Component? As I posted in another thread, I cannot get it to install as it goes into a crazy loop failing to install modules it depends on…

Ha sorry brain fail moment, ignore the Sonos bit. Confusing threads. Though the rest of it stands true.

For the Sonos loop issue, see here for the reason - https://github.com/home-assistant/home-assistant/issues/4327

I’m really curious about the account lockouts, the code will only attempt to login when the remote component is initialized. The new debug logging will log your credentials in plain text

I did realize a fault in my turn_on service logic that was preventing it from functioning correctly due to the default activity variable being optional. That should be fixed now.

I received some random xmpp errors that weren’t consistent when I had both my hubs listed in the configuration file. I cant figure out what was causing it. On a whim i removed my installation of pyharmony using pip and let HASS download and install version 1.09 at startup

I’ve added a bunch of debugging lines to the harmony platform code in hass, right now pyharmony remains untouched. Hopefully this helps get to the bottom of the issues.

My dev fork has the most recent updates.

below is a sample of the output with two configured hubs

16-11-10 18:46:33 INFO (Thread-3) [homeassistant.components.remote.harmony] Loading Harmony platform: Family Room
16-11-10 18:46:33 INFO (Thread-4) [homeassistant.components.remote.harmony] Loading Harmony platform: Bedroom
16-11-10 18:46:33 DEBUG (Thread-3) [homeassistant.components.remote.harmony] calling pyharmony.ha_get_token with username: [email protected] and password: PASSWORD
16-11-10 18:46:33 DEBUG (Thread-4) [homeassistant.components.remote.harmony] calling pyharmony.ha_get_token with username: [email protected] and password: PASSWORD
16-11-10 18:46:33 DEBUG (Thread-3) [homeassistant.components.remote.harmony] received token: TOKEN
16-11-10 18:46:33 DEBUG (Thread-3) [homeassistant.components.remote.harmony] HarmonyRemote device init started for: Family Room
16-11-10 18:46:33 DEBUG (Thread-3) [homeassistant.components.remote.harmony] retrieving configuration from hub using token: TOKEN
16-11-10 18:46:33 DEBUG (Thread-4) [homeassistant.components.remote.harmony] received token: TOKEN
16-11-10 18:46:33 DEBUG (Thread-4) [homeassistant.components.remote.harmony] HarmonyRemote device init started for: Bedroom
16-11-10 18:46:33 DEBUG (Thread-4) [homeassistant.components.remote.harmony] retrieving configuration from hub using token: TOKEN
16-11-10 18:46:34 DEBUG (Thread-3) [homeassistant.components.remote.harmony] writing hub configuration to file: /home/localadmin/.homeassistant/harmony_family_room.conf
16-11-10 18:46:34 DEBUG (Thread-4) [homeassistant.components.remote.harmony] writing hub configuration to file: /home/localadmin/.homeassistant/harmony_bedroom.conf
16-11-10 18:47:00 DEBUG (Thread-1) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:47:00 DEBUG (Thread-2) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:47:01 DEBUG (Thread-1) [homeassistant.components.remote.harmony] current activity reported as: PowerOff
16-11-10 18:47:01 DEBUG (Thread-2) [homeassistant.components.remote.harmony] current activity reported as: PowerOff
16-11-10 18:47:30 DEBUG (Thread-3) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:47:30 DEBUG (Thread-4) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:47:31 DEBUG (Thread-4) [homeassistant.components.remote.harmony] current activity reported as: PowerOff
16-11-10 18:47:31 DEBUG (Thread-3) [homeassistant.components.remote.harmony] current activity reported as: PowerOff
16-11-10 18:48:00 DEBUG (Thread-1) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:48:00 DEBUG (Thread-2) [homeassistant.components.remote.harmony] polling hub at for current activity
16-11-10 18:48:01 DEBUG (Thread-2) [homeassistant.components.remote.harmony] current activity reported as: PowerOff
16-11-10 18:48:01 DEBUG (Thread-1) [homeassistant.components.remote.harmony] current activity reported as: PowerOff

Ok, so i’ve removed pyharmony, pulled your latest dev code and enabled debug logging for the remote module, there is more information but nothing definiative and it still seems to hang and never fully load with the remote component loaded:

16-11-11 07:50:50 homeassistant.util.package: Attempting install of pyharmony>=1.0.9
16-11-11 07:51:42 homeassistant.components.remote.harmony: Loading Harmony platform: Lounge
16-11-11 07:51:42 homeassistant.components.remote.harmony: calling pyharmony.ha_get_token with username: email and password: password
16-11-11 07:51:43 homeassistant.components.remote.harmony: received token: token
16-11-11 07:51:43 homeassistant.components.remote.harmony: HarmonyRemote device init started for: Lounge
16-11-11 07:51:43 homeassistant.components.remote.harmony: retrieving configuration from hub using token: token
16-11-11 07:51:49 hbmqtt.broker: Listener 'default': 2 connections acquired

It seems that the next step in your log is it writing the configuration file, which i never get to. Could this be a permissions issue/issue creating that file?

Cheers

Gareth

Actually looking at the code, it doesn’t look like it gets as far as trying to write the file otherwise i would have another line logged with the path, so it’s failing whilst trying to fetch the config:

self._config = pyharmony.ha_get_config(self.token, host, port)

And i think i’ve worked out what’s going on, my token contains a / and i don’t see the token string being URL encoded anywhere in the component or in pyharmony.

I’ve sent you a pull request on githhub with a fix, i can confirm that encoding the token has fixed the issues on my end.

I guess it might also be worth adding some kind of timeout to the request to the hub, but not sure if it’s best for that to be in the component or pyharmony?

Cheers

Gareth

Just got this installed. I’m getting this error in my logs:

16-11-11 09:33:53 homeassistant.bootstrap: Error during setup of component remote
Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py”, line 149, in _async_setup_component
None, component.setup, hass, config)
AttributeError: ‘module’ object has no attribute ‘setup’

I tried removing the manually installed pyharmony and got this:

(homeassistant_venv) homeassistant@homepi:~ $ hass --script check_config
INFO:homeassistant.util.package:Attempting install of colorlog>2.1,<3
Testing configuration at /home/homeassistant/.homeassistant
16-11-11 23:43:10 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 85, in <module>
    import pyharmony
ImportError: No module named 'pyharmony'
16-11-11 23:43:10 ERROR (MainThread) [homeassistant.loader] Unable to find component remote.harmony
16-11-11 23:43:10 ERROR (MainThread) [homeassistant.bootstrap] Unable to find platform remote.harmony
Failed config
  General Errors:
    - Platform not found: remote.harmony

Successful config (partial)

I also upgraded to 0.32.3 so maybe that’s a problem?

Still having trouble with Sonos, but I pasted that in the Github forum… It also didn’t fix the other half od my problem… ie the Plex problem:

16-11-11 23:46:25 INFO (MainThread) [homeassistant.loader] Loaded media_player.plex from homeassistant.components.media_player.plex
16-11-11 23:46:25 INFO (Thread-3) [homeassistant.util.package] Attempting install of plexapi==2.0.2
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 323, in run
    os.path.join(options.target_dir, item)
  File "/usr/lib/python3.4/shutil.py", line 520, in move
    raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/home/homeassistant/.homeassistant/deps/requests-2.11.1.dist-info/requests-2.11.1.dist-info' already exists

Storing debug log for failure in /home/homeassistant/.pip/pip.log
16-11-11 23:46:35 ERROR (Thread-3) [homeassistant.bootstrap] Not initializing media_player.plex because could not install dependency plexapi==2.0.2
16-11-11 23:46:35 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=create, domain=persistent_notification, service_data=notification_id=invalid_config, message=The following components and platforms could not be set up:
* media_player.plex

Don’t suppose you use Plex and know of anywhere else that issue was raised? :stuck_out_tongue:

I would guess it’s related to this line

shutil.Error: Destination path '/home/homeassistant/.homeassistant/deps/requests-2.11.1.dist-info/requests-2.11.1.dist-info' already exists

Seems to not be able to write to that folder, are your permissions correct?

I noticed last night when I let home assistant install it’s own dependencies, both pyharmony and pyharmony1.0.9 were listed in my deps folder. To roll back to an older working version of harmony.py, I had to remove the pyharmony1.0.9 folder, even though 1.0.7 was correctly installed.

I’ve just tried updating to the latest version of the remote folder (SVN reports version 7334), and using PyHarmony 1.0.9. I’m getting a little further now.

HASS loads the component properly and gets a token but it hangs on:
Nov 11 19:53:20 btpiserver hass[9656]: DEBUG:homeassistant.components.remote.harmony:retrieving configuration from hub using token: XXXX

@gazzer82 Great catch on the URL encoding, I guess I was lucky enough to not have any special characters in my hub’s tokens.

@BTallack I merged @gazzer82’s PR, it sounds like that should fix your issue. Can you sync the changes and try again?

@iandday That did the trick! I’ll get it set up with some switches and some automation today and report back my findings. Excellent work! I’m excited to test it out.