Testers Needed - Harmony Hub Support Implemented in Python

sounds like it’s hanging trying to establish a connection with the hub. Can you ping the hub from the machine HASS is installed on?

That’s what I currently have, maybe I wasn’t clear. It works fine, but the activity changes are slow to respond to an update if changed outside of Hass (i.e. Via the harmony remote control).

If I use hass, the response is practically instant, so the cause appears to be the update frequency.

The Harmony app on my phone listed IP address 192.168.1.109.

So I tried to ping it, but that IP was dead. Then I found with nmap the IP of my Harmony was 192.168.1.103.
After I changed the IP in the configuration file it worked!

@iandday; thanks for your help. So nothing wrong with the implementation but just a wrong IP address registered…

@iandday First up great work. I’m new to HA and loving it so far.

I have one minor issue with this component and that is the polling.

Do you think you might be able to avoid it by processing the message as is done in the following C# library?

1 Like

It’s been on my list of things to do but it’s going to require a whole rewrite of pyharmony and I’ve got higher priority projects I’m working on now. If you dont want to wait feel free to fork it and I can help wherever possible

Recently I’ve been running into frequent XMPP timeout errors when HASS attempts to initialize the Harmony component. Is anyone else seeing this?

Apr 21 13:45:23 raspberrypi2 hass[19164]: 17-04-21 13:45:23 WARNING (MainThread) [homeassistant.components.remote] Setup of platform harmony is taking over 10 seconds.
Apr 21 13:45:50 raspberrypi2 hass[19164]: 17-04-21 13:45:50 CRITICAL (Thread-4) [pyharmony.client] XMPP timeout, reattempting
Apr 21 13:46:20 raspberrypi2 hass[19164]: 17-04-21 13:46:20 CRITICAL (Thread-4) [pyharmony.client] XMPP timeout, reattempting
Apr 21 13:46:50 raspberrypi2 hass[19164]: 17-04-21 13:46:50 CRITICAL (Thread-4) [pyharmony.client] XMPP timeout, reattempting
Apr 21 13:46:50 raspberrypi2 hass[19164]: 17-04-21 13:46:50 ERROR (MainThread) [homeassistant.components.remote] Error while setting up platform harmony
Apr 21 13:46:50 raspberrypi2 hass[19164]: Traceback (most recent call last):
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 153, in _async_setup_platform
Apr 21 13:46:50 raspberrypi2 hass[19164]: entity_platform.schedule_add_entities, discovery_info
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
Apr 21 13:46:50 raspberrypi2 hass[19164]: yield self  # This tells Task to wait for completion.
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
Apr 21 13:46:50 raspberrypi2 hass[19164]: value = future.result()
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
Apr 21 13:46:50 raspberrypi2 hass[19164]: raise self._exception
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
Apr 21 13:46:50 raspberrypi2 hass[19164]: result = self.fn(*self.args, **self.kwargs)
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/remote/harmony.py", line 67, in setup_platform
Apr 21 13:46:50 raspberrypi2 hass[19164]: config.get(ATTR_ACTIVITY), harmony_conf_file, token)]
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/remote/harmony.py", line 120, in __init__
Apr 21 13:46:50 raspberrypi2 hass[19164]: self._config = pyharmony.ha_get_config(self._token, host, port)
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/pyharmony/__main__.py", line 79, in ha_get_config
Apr 21 13:46:50 raspberrypi2 hass[19164]: config = client.get_config()
Apr 21 13:46:50 raspberrypi2 hass[19164]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/pyharmony/client.py", line 52, in get_config
Apr 21 13:46:50 raspberrypi2 hass[19164]: raise ValueError('XMPP timeout with hub')
Apr 21 13:46:50 raspberrypi2 hass[19164]: ValueError: XMPP timeout with hub
1 Like

It’s been on my list of things to do but it’s going to require a whole rewrite of pyharmony and I’ve got higher priority projects I’m working on now.

Thanks for the response. I’ve worked around my issue by using my Onkyo receiver as the trigger for turning lights on. I had hoped it might be a simple change but if it’s a rewrite I can understand it being a very low priority.

I get the 10 second warning but not the rest here.

I’m getting a new error on boot, so I figured you might want to know about it.

2017-07-04 11:38:55 ERROR (MainThread) [homeassistant.components.remote] Error while setting up platform harmony
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/remote/harmony.py", line 72, in setup_platform
    if host and host[1:] in set([h[1:] for h in DEVICES]):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/remote/harmony.py", line 72, in <listcomp>
    if host and host[1:] in set([h[1:] for h in DEVICES]):
TypeError: 'HarmonyRemote' object is not subscriptable

There’s a fix for this which has been merged and should show in a point release. For the most part, it’s just an error.

In my case, I get the error but both of my Hubs are working fine with HA and vice versa.

Everything is working fine on my end as well, which is what had me curious.

Getting a new error on 51.1 causing device commands to not send, but still allowing activities to be started and ended.

2017-08-14 08:40:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 181, in _step
    result = coro.throw(exc)
  File "/srv/hass/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/lib/python3.6/site-packages/homeassistant/components/remote/__init__.py", line 159, in async_handle_remote_service
    num_repeats=num_repeats, delay_secs=delay_secs)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.6/site-packages/homeassistant/components/remote/harmony.py", line 224, in send_command
    self._token, self.host, self._port, device, command, **kwargs)
TypeError: ha_send_commands() got an unexpected keyword argument 'num_repeats'

EDIT: Disregard. This is fixed in 51.2.

Just saw your old post and @Michel post. I basically just did the same thing connecting my Echo Dot to my SONY receiver, by switching on/off a Bluetooth receiver… I also noticed some delay in HA noticing the change of Harmony activity.

Not a big problem, but curious if any of you found a way of getting HA to notice the change quicker?

@iandday this is kinda embarrassing and I apologize for using this unrelated thread to ask for help…but I can’t figure out how else to ask regarding the pyharmony repo on github since you don’t allow issues to be created. Figured it was worth a shot… I am able to use pyharmony to print the config, sync, and turn activities off from command line, but when I try to start an activity I get harmony: error: unrecognized arguments: 28909465. Am I doing something wrong? Not sure of format to run commands either; is this all supposed to be done through HA?

Thanks.

Hey guys, I’m really new to Hass.io and I need help to send commands through my harmony hub. The hub has been automatically recognized by HA but I can’t seem to send individual commands.

Under services page I tried,
Service: remote.send_command
Entity: remote.harmony_hub
Service Data:
{
“entity_id” : “remote.harmony_hub”,
“command” : “PowerToggle”,
“device” : “4576546”
}

This is to turn on my TV. When I hit “Call Service” though, nothing happens. I’m intending to use this in association with IFTTT as a webhooks service call so I can trigger it through my Google Home.

Any help would be much appreciated. I read the Harmony Hub page but was left confused at the situation. Thanks again.

That seems correct but did you actually use 4576546 for device? You need to read the harmony_xyz.conf file in your config directory to see which devices and commands you have available.

The device name on the harmony_xyz.conf file is stated as, “4576546 - Toshiba XxXXX” should I key in the whole name including the bit after the hyphen?

No, only use the number. It just seemed strange that your device value was the same as the one in the example in the documentation.

@Bahnburner, I’ve tried to follow this thread, but I fail to understand why things appear overly complicated when (if) the objective is just to switch devices on/off through a Harmony HUB. I have the same setup at home, using HA (not Hass.io) and it is simple and straight forward.
Is the complexity described in this thread only due to Hass.io?

A Second question (since you guys seems to know lot), is it at all possible to read out the device status from the Harmony Hub (beyond just current_activity)?

This thread is so out of date it’s not even topical at this point. This is the original implementation prior to it getting built into HA. The complexity in this thread is because it’s how it used to be done.

No. You can manipulate devices through services.