Logitech Harmony devs...have any of you seen this?

As part of a discussion that we were having in my migration thread, I did a little bit of digging to try and find out how the Harmony phone app communicates with the Harmony hub, since the phone app updates immediately with activity changes, even when making changes with the remote. I found github users jterrace and swissmanu. These two have a lot of information about and development around controlling Harmony hubs. Two parts caught my eye...

First, there's some explanation here about authentication and how to get both a user authentication token and a session token:

Second, there's an explanation here about the Harmony State Digest, which is used to update clients when an activity is started or stopped by the hub:

I was wondering if any of you who had worked on Harmony integrations with Hubitat had seen or tried to use any of this. Seems like the two big hurdles right now are user authentication (currently needing to reuse tokens from ST) and the lack of instant updates from the hub when using the remote to start and stop activities. Could the information above be used to solve either or both of these problems?

I'm far from a competent js developer, figured I'd post these in case they could be useful to any of you who have worked on this before.

Someone needs to test the token url, without being able to fetch an auth token, this code is going no where.

I tried briefly, no luck. Not sure if I'm doing it right. I get a response with a null GetUserAuthTokenResult

Yup, that's what the other codebase returned from a different url.

Something just came to mind. The Harmony app doesn't ask for user name and password until you try to either connect via cloud or log in to edit a device or activity. Since ST was cloud based they would need to go through the authentication process. With HE being all local, I wonder if authentication is actually unnecessary?

Exactly... If you have run the 'harmony-api' NodeJS server, I am pretty sure it never ask you for your Harmony credentials. Everything is done via a direct LAN connection. Therefore, I am not sure that any authentication is even necessary.

I ran a test last night where I installed the Harmony App on my wife's phone, but did NOT sign into Harmony with any credentials. The Harmony App on her phone found my two active Harmony Hubs, was able to sync up all of the activities, was able to control activities, and also was able to receive instant updates when activities were changed via the physical Harmony Remote. What I didn't try was turning off my cable modem during this test. That is the ultimate test.

1 Like

I just reset my Harmony app to factory and downloaded a capture program to my phone. Got a capture of the interaction between the Harmony app and one of my hubs when I connected to it the first time. I'm not sure what exactly to do with the information. There's some data that looks like it's encoded, but some was readable. Is this something that looks like it could be useful? Here's some snippets.

Authentication is definitely not necessary to send commands to the hub, I have a separate js app on my Pi running to send individual button presses commands to my hubs. Never entered credentials for that one either.

So there are a couple ways to control the hub without credentials. The question now is can we listen for state digest notifications from the hub without authentication, which would allow for instant activity updates, just like the Harmony app gets. My gut says yes, since the Harmony app can do it. It's just a question of how.

Well just to take this one step further....can we listen for updates without creds locally through HE verses having another device in the mix.

That would be the ultimate goal, but I believe we would need TCP/UDP connectivity, versus simple http-type calls.

2 Likes

Hi everyone. What you are doing is beyond me but I'm interested. Not sure if this helps or not - I'm currently using the harmony tasker plugin on a separate android device. I don't use harmony activities - just use the hub as a blaster. It works for me as I dont need any feedback as to what activity/device is on.

A switch in HE sends a http command to tasker which receives it and sends the button I want pushed to the harmony hub through the harmony tasker plugin.

I wasnt sure if the tasker plugin could be used as an example on how to get access. I cant imagine it has official api access. It does ask for a username and password and local hub ip. It then connects and downloads all the device commands available. You can then use those in tasker. I am nearly positive (at least once connected) it is all over my local lan.

Not sure if helpful, but thought I'd throw that out there!

1 Like

Does the Tasker plugin have anything that shows you which activity is running, or is it just a method to send commands to the hub?

I'd have to play with it when I am home- I dont have any activities on my harmony so I'd have to create a couple and test.

The google play app store says it has an action for getting the current activity. That likely means if you set up an event in tasker (such as every 30 seconds) it can pull the info from the hub (the action). My guess, and just a guess at this point, is that the activity change isnt pushed from the hub to tasker (otherwise he would have called it an event in the description, not an action).

What I said previously was accurate. If you know tasker - there is no "event" or "state" for the harmony plugin. So you can't react to changes from the hub - it isn't getting real time updates to react to. However, there is an action for the plugin that states "get current activity" that returns the result in a variable to be further used within tasker. So you would have to set it to get the current activity on some event such as on a timer, if some other variable changed, or on a manual command.

I didn't actually test it because I wasn't sure if it was worth playing with my system settings - I don't use harmony activities. I have all my "activities" within rule machine and use the streaming device's original remote with CEC to control receiver volume. But if it helps develop a HE harmony app so I can take tasker out of the loop I'm happy to test whatever is needed.

There's already a couple of node.js solutions out there for button presses, and a workaround for activity control. Having to reuse tokens from the ST integration is not ideal though. The missing piece right now is immediate updates to activities. If this protocol ends up working out, it would solve both of those problems.

I know a lot of people are looking for the immediate updates. Unfortunately, I'm stuck in the camp just waiting for a direct connection for button presses without having to keep another device running in order to translate between the HE and the Harmony. Hopefully someday!

1 Like

Using harmonyhubjs-client from the links above, I was able to start a node app this evening and have it just sit and listen, then log to console when it received a State Digest from the hub. I used no credentials and no authentication, only entered the IP address of the hub in the node app. Not sure if there was some sort of guest authentication that happened behind the scenes, but if there was, it did not require any input from me as the user. I think there's going to be something here we can use, just need to turn it into a fully formed idea.

This screenshot shows what happened when I first pressed the off button from my phone app (activity is listed but status is 0/off), then when the activity finished turning off (no activity listed, status 0)

Just tested again using the physical remote and received state digest immediately when activity was started, and again when activity finished turning on.

Then again received a state digest when I first pressed the off button, and another one when turning off was completed.

With the GH integration released this morning, these immediate Harmony updates are now all that stand between me and shutting down my ST hub :sunglasses:

1 Like

You’re definitely getting close! Keep up the good work.

1 Like

It would help a lot if I knew much of anything about javascript. The only work I've done in this area before is hacking up other people's code. Writing my own is proving to be problematic, I don't even understand basic function syntax. Ugh.