Can Harmony Remote control any of your openHAB devices?

How?
I have only read tutorials about controlling Harmony Hub with openHAB but not the contrary: controlling openHAB with your Harmony Remote?
For instance: can I press a button of my Harmony Remote and control a Zwave light I already have listed inside openHAB?
Is that possible? how?

Thank you

Here is how I would do it.

Buy a USB IR receiver and plug it into your OH computer.

Install and configure LIRC to respond to whatever your remote is sending and send commands to openHAB via either the REST API or sending MQTT messages.

NOTE: Almost nothing above actually touches openHAB directly. This is all something you have to get set up outside of openHAB.

https://marklodato.github.io/2013/10/24/how-to-use-lirc.html

Thanks rikoshak,

I see your solution is very smart but it’s kind of a workaround… I mean, I guess Harmony Hub cannot send button commands to openHAB and make it react as you want, doesn’t it?

Your solution could work if you have the Harmony Remote on the same room as the IR receiver and even the OH computer…

Thanks!

The API exposed by the Harmony Hub is relatively limited, but it does allow for reading the current activity as well as setting the activity and sending device commands.

It appears the Harmony Hub API does not support that.

Umm, thank you.
I see the “problem” is the limited API… finally I should take a workaround similar to yours :wink:

Thanks again

Here is how i use it to control my openHAB bits. I have an IR receiver plugged into my Mac Mini (OH is running on a Pi in a different room). I then register a dummy TV device (note that i don’t have the actual device) with Harmony (pick one with lots of buttons, the Panasonic TC-P65VT30 is a good candidate)

Then using Flirc (the ir receiver) on the Mac I tell it that I am going to record a IR signal and these are the keys I want you to press when you receive that signal

Make them super obscure then you press the button on the remote you want to associate with those keys.

Then, I use Keyboard Maestro (though any custom keyboard shortcut trigger thing will work like BetterTouchTool, Script Events, even the built in Mac system prefs) to do something when those keys are pressed.

(I don’t know if you have a Mac, if not I am sure there are equivalent applications for whatever platform you need)

Keyboard Maestro lets me do anything, I can fire a shell script to send a http request to openHAB, open an Application, send shortcuts specifically to an application.

Once the buttons are in the Harmony Hub I can use openHAB to simulate presses.

E.g I have a “good night” sequence in openHAB that i trigger with HomeKit, it starts to dim the lights downstairs, lights the bedroom and landing, checks to see if the harmony states that an activity is running (and which one) then powers it all off.

I also use the Harmony to control individually the volume levels of Squeezelite and Kodi. Turn on the fan via a remote power switch from the remote.

So whilst the API is a little lacking, you can easily hook several things together.

Yes it might sound like a lot of faffing, and it is, but it works and is very flexible.

I hope my ramblings help somehow :slight_smile:

2 Likes

Hi Sam,

I really like your solution as I have a macmini next to the TV working as a media center. I guess I can add FLIRC to that computer and listen to my Harmony Remote buttons presses as it’s always near the TV.
Could you be more precise about how openHAB can get that commands from Keyboard Maestro?

Thanks!

Sure, happy to share.

Flirc

In Flirc I click the keys I want to associate with the IR signal I am about to send

I select the Panasonic TC-P65VT30 “device” which I have already added to my Harmony (I also renamed it Flirc), I press the “vera link” button (though it could be any button).

Flirc flashes to say it has added it.

Keyboard Maestro

In Keyboard Maestro icreate a new macro and say I want it to be triggered by a “hot key”.

Click the mouse inside the “this hot key” box and then Keyboard Maestro is waiting for you to press the keyboard combination you want it to be triggered on. Using the Harmony remote press the button you just set in Flirc (vera link).

If the Flirc side of things is working, this should fill in the hot keys correctly.

Then in the “execute the following actions” part of the macro I add a new action and select “Execute Shell Script”

#!/bin/bash
curl --header "Content-Type: text/plain" --request POST --data "ON" http://192.168.1.222:8080/rest/items/Harmony_TV_to_Projector

OpenHAB

.items

You don’t need the hub configured, the item we sent the ON request to is a dummy item and is not linked to any binding.

String Harmony_Press_Projector_Off	"Projector Off"   (gAll)   { harmonyhub=">[press:34897415:Projector off]", autoupdate="false"}
String Harmony_Press_Projector_On	"Projector On"    (gAll)   { harmonyhub=">[press:34897415:Projector on]", autoupdate="false"}
String Harmony_Press_SamsungTV_Off	"Samsung Off"     (gAll)   { harmonyhub=">[press:SamsungTV:PowerOff]", autoupdate="false"}
String Harmony_Press_SamsungTV_On	"Samsung On"      (gAll)   { harmonyhub=">[press:SamsungTV:PowerOn]", autoupdate="false"}

Switch Harmony_TV_to_Projector  	"TV to Projector" (gAll)  
Switch Harmony_Projector_to_TV  	"Projector to TV" (gAll)   

.rules


rule "Switch the TV to Projector"
when
    Item Harmony_TV_to_Projector received command ON
then
    sendCommand(Harmony_Press_Projector_On, ON)
    Thread::sleep(1000)
    sendCommand(Harmony_Press_SamsungTV_Off, ON)
    Thread::sleep(1000)
    postUpdate(Harmony_TV_to_Projector, OFF)
end

So you can see in this case I am using OpenHAB to run a little sequence, the MacMini, PS3 and Freesat box have HDMI out into switch box, then the HDMI from the switch is split into two so the same signal is going to the tv and the projector at the same time.

This allows me to switch the display from TV to Projector without changing activity.

To do the same on the Harmony is very tedious, you can read how I did on the Logitech forum

Once you have the “when” bit triggered, you can do whatever you fancy using anything that OpenHAB can control.

Good luck.

Not sure which remote you have, does it have a touch screen?

###Just for kicks here is my rule that does something based on the Harmony Activity

String Harmony_Current_Activity  	"Activity"     (gAll, gRestoreStartup) { harmonyhub="*[currentActivity]" }
rule "Turn off Cinema Mode when powering off Harmony"
when
    Item Harmony_Current_Activity changed
then
    var String HarmonyState = Harmony_Current_Activity.state.toString()
    if (HarmonyState == "PowerOff" &&  Cinema_Mode.state==ON){
            sendCommand(Cinema_Mode, OFF)
    }
end

2 Likes

Thank you very much!!
I finally got it working, it’s a really great way of controlling openHAB and I have learned some new tricks, thanks!

Anyway, I used a simpler way to control simple switches, I just used:

#!/bin/bash 
curl --header "Content-Type: text/plain" http://localhost:8080/CMD?ventilador=TOGGLE

Is it correct or it might turn into problems using it as a “toggle”?

Finally, a Harmony remote related question: I have the new Harmony Companion:

which has some specific buttons for lights, dimmers and outlets but they are disabled if you don’t add a “home automation device”… but I don’t have any that Harmony understands… So, do you know a way to “enable” these buttons so that I can bind them to the “system” you have shared with me?

Thanks!

Cool, glad it worked out.

Toggles are tricky, I started using them at the start but there will be times when a command to openhab gets held up somewhere and you fire off another thinking it hasn’t worked. The Harmony Touch remote is nice as you have buttons to spare with the screen.

Note that ir signals are blasted out repeatedly and in quick succession. You can use a pause action in Keyboard Maestro if it is a bit trigger happy.

There is a great… well I say great, and it is great but it’s not without its quirks, bit of software on the Mac called Remote Buddy. You can use that to build custom menus and control software on the Mac.

I use remote budy for controling OH with my Harmony hub. The magic thing si it configure your remote as an ps3 remote on Harmony so it’s in bluetooth and toi CAN control it from almost any room or your house

Of course I know Remote Buddy, I own it since almost 7 years ago and I’m very happy with it. Since then I run Kodi (formerly XBMC) with my Macmini and used RB with the Apple Remote without any other input device, I mean, I have setup RB in a way that let me use the full computer (mouse, keyboard, etc) just with this remote.

Now I have added the Harmony Hub and I only have this remote to control the TV, Macmini and Music stereo… that’s why I would like it to control my “home automation devices” too, hehehe.

@Dominic_Bonneau, I already have the remote as an PS3 remote but I can’t use the “home automation buttons” with this “activity” so that’s why I would like to enable them somehow (here is the thread) where @sam is also helping me out.

Thank you both

Using the same method as the Flirc you can also create your own behaviours and actions, then setup custom menus in Remote Buddy. Because there will never be too many ways to turn lights on and off :slight_smile:

It’s exacly what I did !

great minds and all that :slight_smile:

Hi,
Must the String in the First line in the Rule too?
Is my First Time with OH.

My Rule is looking so:

String Harmony_Current_Activity “Activity” (gAll, gRestoreStartup) { harmonyhub="*[currentActivity]" }

rule “Gute_Nacht_TV_AUS”

when
Item Harmony_Current_Activity changed
then
var String HarmonyState = Harmony_Current_Activity.state.toString()
if (HarmonyState == “Amazon” && nacht.state==ON)
{
sendCommand(homematic_HM_LC_Sw1_FM_8677c139_MEQ0361878_1_STATE, ON)
}

end

Is it possible to Check the Rule in the Internet? Thanks

This is an Item definition and needs to be in a .items file in the items folder.

Hi,
Thanks die the quick Answer. But wy do don’t take the item the Harmony Binding? And can i Check the ruels somewhere in the Internet, like a Compiler?
Is the Rest from the Rule than ok? I am testing the rule dir a few days.
Thanks for help

Lars

I don’t understand the question. The way OH works is you have a Binding that knows how to talk to a device or technology, in this case Harmony.

You must create Items to represent these devices inside of OH. Items are defined in .items files in the items folder of your configurations folder.

Rules run when certain events occur, in this case when the Harmony_Current_Activity changes its state. Rules are defined in .rules files in the rules folder of your configurations folder.

No. The best you can do is to use Designer which will syntax check the rules as you type. But for logic errors the only way to check them is to run them and use logging statements to discover and solve the problem.

I assume you are asking whether you can make an HTTP REST call from a rule. Yes with the one limitation that currently the HTTP actions do not currently support making HTTP calls with a body.

Please see :

Hi,
Thanks gor all. I will Look tommorrow.

Herr is My Script without a extra Item

rule “Gute_Nacht_TV_AUS”

when
Item harmonyhub_hub_Wohnzimmer_currentActivity changed
then
var String HarmonyState = harmonyhub_hub_Wohnzimmer_currentActivity.state.toString()
if (HarmonyState == “Fernseher” && nacht.state==ON)
{
sendCommand(homematic_HM_LC_Sw1_FM_8677c139_MEQ0361878_1_STATE, ON)
}

end

Thanks gor help!!