Harmony-api on Windows Docker?

Has anyone here ever been able to get the Harmony-api working on Windows Docker, and if so, how did you do it?

I've had it running successfully on my Pi for years-and-years and ported my integrations from SmartThings into Hubitat with no issues, but I'm trying to simplify my life and number of always-on devices. And yes, I already have the Harmony Hub Driver up and running perfectly, but I need some very specific device controls.

I spoke with the creator of the above project the other day (he's one of the founders of Channels DVR) and he basically told me he had no idea, either, and that he's abandoned the project in favor of Home Assistant's approach for Harmony integration. I let him know that I was sticking with Hubitat :smile:

Details on what I tried so far...

When I use this command with the port defined, I can get the webpage to appear, but can never get it to discover the Harmony Hub:

docker run -d --restart unless-stopped --name="harmony-api" -v C:\docker_volumes\harmonyapi\config:/app/config -p 8282:8282 jonmaddox/harmony-api

When I use this one with --net=host, I never get the front-end webpage at all, and it does not seem to go past discovery in the logs anyway:

docker run -d --restart unless-stopped --name="harmony-api" -v C:\docker_volumes\harmonyapi\config:/app/config --net=host jonmaddox/harmony-api

This is what I have in my config.json:

{
  "enableHTTPserver": true,
  "topic_namespace": "harmony-api",
  "hub_ip": "10.255.1.143"
}

I've also tried manually running on the command line, running a bunch of versions that forked off the original project, and replicating what some people did in an old KuKuHarmony thread, but all were to no avail. I even looked at Home Assistant's Harmony code, but haven't been able to think of a way to port it over to Hubitat. I did stand up a Home Assistant session and was able to get the Harmony integration to work, but individual device control was rather opaque, not as straightforward as the Harmony-api, and certainly was more resource intensive. Definitely not worth it just for this one thing.

I cannot assist with the HarmonyAPI questions, sorry. However…

You can issue device specific commands from my Harmony Hub integration for Hubitat. If you know the command, you can simply pass in the device ID and command to the parent’s device command feature.

4 Likes

Thanks (and also special thanks for your work on the Harmony integration; it installed smoothly without any issues and works perfectly), I think I see the setting field you are talking about:

image

However, if I am understanding this, I can put one combo here, plus a bunch of other television/audio ones. Unfortunately, I have many virtual devices that do a lot of different functions on various IR devices, not necessarily all TV-focused. Sadly, unless I'm missing something, this is not going to work for me. I really need granular device level control, which I do get from Harmony-api and HTTP buttons.

Give me an example of a detailed device control action that you’d like to implement, please.

The way in which this is typically used would be from within Rule Machine as a custom action. You could string together a sequence of commands as multiple actions in a RM rule. Each “deviceCommand()” takes two parameters, the device ID and the command you’d like to issue. Thus you could really build whatever sequence of commands you’d like.

4 Likes

All right, this took me a hot minute to fully comprehend and parse through hundreds of posts to get to the full solution, so I wanted to capture what I did to get this to successfully work.


(1) Create a new Device, select Virtual, and select the Type as Virtual Switch.

(2) Click Save Device to make new options appear in Preferences.

(3) Make sure Enable debug logging is set to on (should be by default). If this is a function that turns on and off (i.e., an air conditioner), do not change anything else. If this is a function that only turns "on" (i.e., changing the input of a television), then change Enable auto off to something like 2 seconds. This will make it so you can always "turn on" the function.

image

(4) If you have made this change, click Save Preferences. You can also test to make sure it is working by clicking the On button and making sure the Current States of the "switch" turns back to "off".

image

(5) Go to Apps, select Rule Machine, and Create a New Rule. Give the Rule a name. I like 'WHAT - DEVICE- ACTION':

image

(6) Click on Select Trigger Events.

image

(7) Under Select capability for new Trigger Event select Switch.

image

(8) Select the new Virtual Switch that was created above.

image

(9) Click Update and a new option called Switch turns will appear. The default option will be "On", so you should leave it as-is for now.

image

(10) Click Done with this Trigger Event and then Done with Trigger Events so upon returning to the main screen you should have something like this:

image

(11) Click on Select Actions to Run...

image

(12) Click to Create New Action.

(13) Under the Select Action Type to add dropdown, select Set Variable, Mode or File, Run Custom Action.

(14) A new dropdown for Select Which Action will appear. Select Run Custom Action.

(15) A new dropdown for Select capability of action device will appear. Here, you can either select Actuator, Button, Presence, Switch, or anything else that the Harmony Hub will appear under. I just went with Actuator because it was alphabetically first.

image

(16) Click on the newly appeared Select *** to act on, scroll down, and select Harmony Hub.

image

(17) Click Update and the Select custom command dropdown will appear. Select deviceCommand.

image

(18) A new dropdown for parameter type will appear. Select string.

image

(19) The first parameter is for the Harmony Device function you want to run. An easy way to get this value is to to open the MyHarmony desktop or mobile app, edit the Device, and click on Add or Fix a Command.

image

(20) This will give a list of Commands. Note the one you want exactly as it is written.

image

(21) Enter that Command into the string value field that appeared before.

image

(22) Click Add another parameter and this time select number.

image

(23) The number is the Device ID. You can easily get this from the State Variables in the Harmony Hub parent device. Enter this number into the field that appeared.

image

(24) You should now have Parameters that look like this:

image

(25) Click Done with Action. You should have an action that looks like this:

(26) Click Done with Actions. You should now have Trigger Events and Actions that look like this:

image

(27) Under the Logging dropdown, select everything.

image

(28) Click Install Rule and then Done. The Rule is now complete. Return to the Device and test that it does the action as expected. The Virtual Switch can also be picked up by voice assistants, so you can say, "Voice Assistant, turn on Example Virtual Device" in order to perform the action.

(29) The good news is that now that you have one of these, the rest can be more easily created with cloning. For instance, if there should be an "Off" selection, you can reopen the Rule and click the Show app details and settings button.

image

(30) Select Export/Import/Clone, then Clone [Rule Name], and then Clone .... This will give you a screen where you can rename the Rule to what you want it do or change out the virtual switch that is being used.

(31) After it is created, you can then go into that Rule and just edit the fields that are needed to be modified. Notably this is the Hubitat device, the Harmony Hub Device ID, and the Harmony Hub Command.

(32) That's it!


So thanks, @ogiewon, I can now retire my old Harmony Hub API. I did try a few different approaches like writing my own custom switch to skip the Rule Machine part, but at the end of the day you have already done enough of the hard work that this methodology works perfectly well. I was also able to just to take my existing custom http switches and convert them to this method, so my switchover was relatively painless.

1 Like

Glad to hear you were able to get everything working as desired. And, thank you for the great write up!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.