Harmony integration

Something tells me the security mindedness came as a result of this...even though it was for different hardware.

1 Like

So looking at this further I don't think it will be easy to integrate directly.

The hub ID can be found with a simple httpPost call. That was easy. However the communication is all done through websockets which hubitat doesn't support.

I could create a node server and handle the communication that way. But too much work for something that may or may not be around long.

So just going to keep an eye on it for now and see if anything more comes up.

1 Like

There is an alternate websocket port still available - used by the Logitech apps. Home Assistant have already updated their Harmony plugin to support this in 0.84.4

Of course Logitech might close that too in an update.

As per the message above ....

Didn't the other local API that they just closed down require a separate webserver as well?

I did that...it's SUPER easy. Someone has already done all the heavy lifting too.

Works with all the Hubduino drivers. (Hubduino = ST_Anything)

1 Like

Thanks for sharing this @Ryan780...when I get some extra time on my hands, I'll probably give it a shot.

As another option there is also the project below. I haven't read through Ryan's link in detail so I can't say what's different about the 2 projects (the fact that his uses ST_Anything definitely peaks my interest). One great aspect is that the mdhiggins project can control Roku devices through the LAN as well.

I started building this into an app so I could easily build macros (works great) but found it difficult and time consuming to make user friendly. As a result it's been on the back burner for a few months now. I may have to tackle it again now that I know support for Lan control of Harmony with HE is now all but dead in the water.

1 Like

HomeAssistant has updated to the websockets solution, with the following statements:

"We will be releasing a hot fix today to migrate our integration to another local API that is being used by their iOS app. Expect it to suffer the same faith at a future point."

"Home Assistant 0.84.4 has been released with a fix. The Logitech Harmony integration works again (for now?). We switched to their local websocket API."

So...websockets works, but it sounds like HA is not confident that it won't be closed at some point as well. Bummer. What is Logitech doing? They are not accepting any more "official" integrations, and they are closing down local APIs....are they trying to get out of the home automation market? I don't get it.

FWIW, the author of KuKuHarmony says here he is going to try to adapt to the websockets API:

They are taking the same route as other vendors like Lutron where they are only doing cloud to cloud integrations and only working with "The Big Names". It will be interesting to see where this ends though....

Looks like the one you posted accepts HTTP calls, which could work. I will say the the Hubduino IR integrates pretty seamlessly with no other software or rules needed. Even maintains device state "on/off" as long as you don't use another remote to turn it on or off. I also have it set up to use two different IR bulbs for the one in my bedroom, one for the TV and one for the stereo. And if you're familiar with Hubduino it is extremely easy. The writeup on the ST forum is excellent. The software the guy posted for grabbing the IR codes from your remote actually worked better than the one on the adafruit website. The adafruit version wouldn't capture for my Onkyo receiver but his did on the first try. So, I would definitely try that part at least no matter which you go with.

I am extremely happy with mine. They have been rock solid. The only hick-ups I've experiences have been user or hub-induced (sending commands too close together because 2 rules fired, that kind of thing)

...and when you're done trying to figure out 'another way' to do IR ... there is always the Global Cache IP2IR devices, Driver and App, all ready to go. :sunglasses:

Hey, Google... turn on Watch TV. Sure, turning on the Watch TV (Stereo, TV and Cable box magically turns on)

Hey, Google... turn on ABC. Sure, turning on the ABC (cable box changes channel to ABC)

Remote controls!? Don't need 'em! :stuck_out_tongue_winking_eye:

Is there an easy way to do macro commands. The main reason I set up the mdhiggins method was because there was no easy way to send a string of commands without changing the current activity.

Eg.
I wanted to swap between my samsung soundbar speakers and my 2 rear M3's (don't ask why...home acoustics is the short answer). To do this with the Harmony remote requires loading a separate "device" menu and a string of about 10 button presses. A real PITA for a simple task. With my NodeMcu, I simply ask alexa to "switch to the back speakers" and voila. All 10 commands execute with proper pauses in between and I don't need to touch my Harmony remote or change the activity.

Do you think this scenario...or a version of it ...is possible with the Hubduino solution...please say yes :pray:

In a specific sequence? I don't know. I've never done that. If you can't post on the ST forum I can post on the thread where it was developed.

I can post on ST... but I'll just stop being lazy and actually read through the link you posted. It would probably be apparent once I understand how that method controls the IR transmissions.

I looked at the code. Its nothing special but because its websockets we can't implement it the same way in hubitat. And the only way to update the device is via polling.

That being said you could still use ifttt to trigger activities. Its not nice.

I was able to put together something. But it does require a node server to be running to handle the websocket stuff and it requires polling to update the hubitat device. Its not pretty, has lots of bugs and will probably break but its all local and runs pretty fast. I'm hoping they will figure a way to avoid polling soon. We will see.

3 Likes

So I have been able to reproduce what the Hass.IO folks have done for using Python, websockets and Harmony. I am able to connect to my device, query the activities. I just now need to figure out how to watch for changes in the activity itself.

1 Like

You have to poll the box.

You can use the following websocket command

ws.send(r'{"hubId":"${hub_id}","timeout":30,"hbus":{"cmd":"vnd.logitech.harmony/vnd.logitech.harmony.engine?getCurrentActivity","id":"0","params":{}}}')

Then parse the response. The current activity is stored in the result.

ws_data = ws.recv()
hub_data = json.loads(ws_data)
print("    Current Activity: " + hub_data['data']['result'])

At this point I don't see a way to have it report automatically.

Also as an activity is starting it will see 3 status messages via the websocket. I think at the start, during and once complete. I don't really think we care about them though.

Isn't this exactly what is needed to do away with polling? From the XMPP solution that is now defunct, State Digests would be sent when an activity was started or stopped. It sent the activity ID along with a status of 0, 1, 2, or 3. Sounds like this could be the same thing?

Still looking into it. I have a couple ideas though.

From my other attempt here

Status Code 0 means hub is off
Status Code 1 means activity is starting
Status Code 2 means activity is started
Status Code 3 means hub is turning off

	harmonyClient.on('stateDigest', function(digest) {
		var statusCode = digest.activityStatus
		var currentlyOn = digest.runningActivityList
		var targetActivity = digest.activityId
		
		switch(String(statusCode)) {
			case '0': //Hub is off
				if(currentlyOn == '' && targetActivity == '-1') {
					console.log('- Hub is off')
				} else {
					console.log('- Activity ' + currentlyOn + ' is off')
					changeSwitch(currentlyOn, 'off')
				}
				break;
			case '1': //Activity is starting
				console.log('')
				console.log('Received state digest (' + new Date() + ')')
				console.log('- Activity is starting...')
				break;
			case '2': //Activity is started
				if(currentlyOn == targetActivity) {
					console.log('- Activity is started')
				} else {
					if(currentlyOn == '') {
						console.log('- Activity ' + targetActivity + ' is on')
						changeSwitch(targetActivity, 'on')
					}
					else {
						console.log('- Activity ' + targetActivity + ' is on')
						console.log('- Activity ' + currentlyOn + ' is off')	
						changeSwitch(targetActivity,'on')
					}
				}
				break;
			case '3': //Hub is turning off
				console.log('')
				console.log('Received state digest (' + new Date() + ')')
				console.log('- Hub is turning off...')
				break;
		}
	})

Download the Hubitat app