[Release] Logitech Harmony Hub Driver v0.1.20230311

@ogiewon and I used this a while back but it would progressively affect our Harmony Hub's performance until I needed to reboot it (within a week). I'm surprised this hasn't affected your hub. I wonder what's different about your implementation.

1 Like

I changed the state update times in app.js (line 22 I think?) from 5 seconds to 10 seconds. Since I did that, all three of my hubs have been fine.

It could also be something that was in one of the older firmwares as well. On the past few versions, I've not had any slow downs at all using the harmony-api scripts.

2 Likes

I may have to give this a shot again. I was also planning to test out the node red (contrib-harmony) at some point. Have you played with that node yet?

1 Like

@corerootedxb - As @stephack mentioned, we used the 'harmony-api' nodejs server for quite a while in the early days of Hubitat, but it caused issues with the Harmony Hubs. I even created a Hubitat HTTP Switch Driver specifically to turn on/off Harmony Activities. One issue using it is that it is one-way communications between Harmony Hub and Hubitat, IIRC. If a remote control is used to change the Activity, Hubitat will get out of synch.

The webSocket implementation is really pretty amazing. Super fast, reliable, and no man-in-the-middle server required.

If volume control is everyone's number one wish, I can take a look at trying to add device support for Harmony device classes that are known to support volume (e.g. Receivers, TV's, etc...) It just has not been a high priority for me personally.

6 Likes

I did and it's actually pretty good! There's even a websocket version of it now.

@ogiewon Yeah, I believe that's all been resolved. However, I'm only doing HTTP POSTs from HE to Harmony for volume using a virtual dimmer (it's messy, imho, but it works). For bi-directional communications, I actually modded your HTTP Momentary Switch driver to call for status after the device command was sent and it worked OK. But, like you, my use case is dead simple for Harmony; Turn on/off activities and occasionally adjust the volume of said activities.

Curious - does anyone know if Volume Control is in any way abstracted away from the specific device controlling volume? It would be nice if logitech exposed a volume control that is tied to the Activity versus a specific home theater component. This would allow for a single, universal volume control which the harmony hub would translate into the correct device specific commands. This would be truly universal and would be much simpler to add and maintain. In fact, the Parent Device could have the volume level commands added directly to it, if this were the case. I just haven't poked around enough yet to know if this is possible.

1 Like

AFAIK, Yes. If the activity has a volume capable device included in it, then there is a top level volume up/down. If you don't specify a volume device in your activity, the hub just ignores the volume commands.

That's exactly how I do it with the API today. I use the URL: http://[server]:8282/[hub]/commands/volume[up|down]. I can dig through the code and see what that translates to on the hub if it'll help.

Not sure it will help, as the harmony-api is not using webSockets, IIRC. But, I definitely appreciate the information and the offer for assistance!

True. BUT... The NodeRed Harmony API does use websockets. :slight_smile: Give me a sec to dig through that code base. I might be able to find something quickly.

1 Like

I found this:

getActivityCommands(activityId) {
        return this.getConfig()
            .then(response => {
                var activity = response.data.activity
                    .filter(act => {
                        return act.id === activityId
                    })
                    .pop();
                return activity.controlGroup
                    .map(group => {
                        return group.function
                    })
                    .reduce((prev, curr) => {
                        return prev.concat(curr)
                    })
                    .map(fn => {
                        return {
                            action: JSON.parse(fn.action),
                            label: fn.label
                        }
                    });
            });
    }

sendCommands(action) {
        var payload = {
            hubId: this._remoteId,
            timeout: 30,
            hbus: {
                cmd: 'vnd.logitech.harmony/vnd.logitech.harmony.engine?holdAction',
                id: 0,
                params: {
                    status: 'pressrelease',
                    timestamp: '0',
                    verb: 'render',
                    action: action
                }
            }
        };

        return this._client.open()
            .then(() => this._client.sendRequest(payload));
    }

So, I'm guessing the fast track would be to send a command of volume-[up|down] to the activity id?

I can PM you the complete file if you want to dig around in it.

Another vote for yes IIRC. I was running something on a node.js server awhile back and set up volume control to use with Google Home, I believe I was doing it through the activity rather than the device.

1 Like

@ogiewon, I installed the Harmony driver, child driver. Everything came up ok. I can turn things on/off from the device page.

I have an app that I wrote to do certain things and one of them is to turn off the TV at bedtime. I previously used that with ST and used mediaController for my input, and acitivityOff() for my command.

It seems that it is different with HE. So I use switch for my input? And then to turn things off do I turn the OFF device on? And if so, do I need to turn that back off to be reset for the next time?

Hope that made sense.

Another vote for yes here.

Correct, you can either turn off the current Activity switch OR you can turn on the Power Off Activity switch. No need to reset anything. Only 1 of the 'Activity Switches', including the 'Power Off switch', will ever be active at any given time. Turning ON any activity will cause all of the others to 'turn off' automatically.

1 Like

I have setup four virtual devices in my ST hub and added them to the companion remote. I can see a string in the logs when the buttons and brightness are pressed. I think the next step is to try and get my hands on your code to setup the Hubitat to respond to the input. May I get a copy of your code and some quick instructions if they are available?

Sent you a PM

Would be an awesome feature. I go to bed before the rest of the family and the TV from time to time is a little loud. Currently I turn it down using the Harmony app from bed, but would love to automate the allowed volume level.

Why not just use the physical Harmony remote control? The issue I have with volume control is that it is only possible to adjust the volume of your TV, Receiver, or whatever device either up or down. There is no way of setting a consistent volume level (e.g. 25%) from a Harmony remote/hub device.

As I look into this, I struggle more and more to see the value. I understand Mute/UnMute, and possibly Play/Pause. But even those are more readily handled, IMHO, by simply using the Logitech physical remote control.

I’ll continue to look at the possibility of adding these features, but since I don’t see the use-case for them personally, it’s not a high priority for me. I’m just trying to be honest and set expectations realistically.

As always, I am open to Pull Requests for this code, plus anything else I have put out there on GitHub. I love when other users contribute and collaborate on software like this.

1 Like

The TV is in the first floor living room. I sleep on the second floor and hear the TV as my headboard is on a shared wall with the livingroom as the livingroom has 18ft high ceilings. The volume is not always a problem when I get in bed, but often as the scenes change in the movie. No worries if this doesn't fit in to your plans or even is possible. Thanks for all your efforts in the community. I can continue with the phone app as it has worked well.

1 Like

I understand now. Thanks for the use-case. For that specific scenario, I just fire up the Denon App on my phone and turn the volume down.

BTW - do you have a surround sound receiver that is being used for volume control in that first floor living room? If so, Hubitat actually has some built-in drivers for some models. This would provide precise volume control of the device via Hubitat.