Logitech Harmony API

Previous discussion here.

3 Likes

I’d love to have the ability to do more than just call an activity, like sending individual commands (Play, pause, etc) through the hub!

I have a Harmony hub and can definitely help with testing.

Does the pyharmony still work? I might take a crack at this.

Edit: Yes, looks like my weekend just disappeared…

2 Likes

I have multiple hubs at home i’d love to help testing this.

I would like to be able to respond to events from the hub, like play is pressed, pause is pressed etc. This would allow to define triggers in HA based on these events. Like turn off lights when play is pressed.

I too am available for testing. Would love to see this!

Any update on this? Just checking!

I am also available for testing. Any movement on this feature request? I have 0.0 technical ability to add to developing this component but am willing to help anyway I can in a non-technical capacity. This is a much needed component and is really amazing to me that hasn’t been integrated yet given Harmony remotes’ popularity.

I’ve written .NET libraries for interacting with Harmony, but I don’t know Python. If anyone wants to tackle this, you could probably have a beta together in a weekend (that’s about how long it took me to do a working C# implementation).

If a Python dev wants to partner up, I can provide some insight around some of it, I just have no idea how you do something similar to what I did with stream reading on the python side.

  1. Open a raw Tcp socket to the Harmony.
  2. Get a handle to the Tcp stream and start parsing responses.
  3. Send opening stream preamble.
  4. Send login / pass to logitech to get a token.
  5. Authenticate to the Harmony hub using that token (now you can send commands instead of just read only).
  6. Run some background thread that sends a heartbeat request every 30 seconds to keep the stream alive.

Note that the Harmony seems to only advertise changes of the Current Activity, I haven’t been able to get it to send notifications of button pushes. The only real “state” it maintains is the Current Activity, and it exposes a few calls that will return configuration (which includes all of the available devices and commands, which you can read from and then send back).

I have no insight into how HASS does its stuff here, and this is just how I did it. I’ve seen other implementations do the whole thing in one big event loop too, though I didn’t really like that approach. Unfortunately, I’m unlikely to do anything with HASS until this has been added, as I’d be breaking a good chunk of my existing system just to try it out.

3 Likes

I’ve just read over the previous discussion and briefly reviewed the numerous pyharmony forks.

pyharmony seems to be in a bit of disarray. It has some excellent docs on the protocol, but other languages have used that to implement fuller clients. The original pyharmony was updated just over 3 years ago, and never was configured with setuptools so never made it to pypi. A bunch of forks did add setuptools, but never did publish. They seemed to add it independently too.

Here’s the forks that seem the most active in the past few months:

I’ve also reviewed how https://github.com/maddox/harmony-api is implemented. It’s using two libraries under the hood: harmonyhubjs-discover for finding the hub on the network, and harmonyhubjs-client for interacting with it. pyharmony fills second role, so either we’d need a python way to discover it, or require a hard-coded IP address, which usually also implies doing network setup to give a static IP.

A totally different approach might be to implement a component that is designed to work with harmony-api. It could depend on mqtt, and discover devices on it, and create mqtt switches to represent it. It might also be possible to do a media_player implementation using mqtt, with the goal of being harmony-api compatibility.

3 Likes

Right now, that’s how I have implemented the Harmony-API; with mqtt switches. I appreciate the efforts you have put into your research; obviously you value this integration as much as I do.

1 Like

@rpitera, do you think you could share your MQTT bridge?

I’m not bridging; I use CloudMQTT direct. My setup is based on @danichispa’s post here

I just wanted to post an update to this. @iandday has been working on this and has a pretty solid solution but I know he could use some help finalizing a few things. I’ve been helping with testing but he could use help with writing the coverage test file if anyone could be of assistance.

The post is here:

You’d probably do better posting this request in the developer section and reaching out on gitter. I’ve been following his progress and would help if I could but I lack the same experience he needs.

@iandday’s pull request was merged in time for 0.34 (might be 0.35). Closing this topic as Home Assistant now has Harmony support.

1 Like