Troubles setting up Harmony binding with openHAB 2

Hey guys, i also got it working now, so i want to share with you. my intention was to use it with alexa, therefore i need to setup some rules and i dont need the sitemap entries for my purposes.

I can now say “Alexa, start SKY TV” and it turns everything on as defined with my harmony hub. I need to change the state of everything else to OFF then, because i may want to say “start kodi” but if kodi was started before, it will not start again, because it is already in the state of started.
if there is a better solution for that, then i am grateful for any ideas how to optimize the construct :wink:
to switch everything off i made an extra rule called “alle Media Geräte aus” which is alway on if a acitvity was started. so i am able to say “alex, switch all devices off”.

the last small problem is, that if i am now saying “alexa, turn on sky tv” alexa asks me which device (because i have “sky tv” and “sky beamer” and i need to repeat what i was saying. very annoying. siri dont ask me that, she simply does her job :wink:

items:

//Harmony
String Harmony_Activity "Current Activity [%s]"  (Wohnzimmer) { channel="harmonyhub:hub:HarmonyHub:currentActivity" }
Switch Harmony_skytv 	"Sky Fernseher" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_skybeamer 	"Sky Beamer" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_koditv 	"Kodi Fernseher" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_kodibeamer 	"Kodi Beamer" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_alles 	"alle Media Geräte" 	(Wohnzimmer) 	[ "Switchable" ]

rules

rule "Sky TV schauen"
    when
        Item Harmony_skytv changed to ON
    then
            Harmony_Activity.sendCommand("24360745")
            postUpdate(Harmony_koditv, OFF)
            postUpdate(Harmony_skybeamer, OFF)
            postUpdate(Harmony_kodibeamer, OFF)
            postUpdate(Harmony_alles, ON)
end

rule "Sky Beamer schauen"
    when
        Item Harmony_skybeamer changed to ON
    then

            Harmony_Activity.sendCommand("24360747")
            postUpdate(Harmony_koditv, OFF)
            postUpdate(Harmony_kodibeamer, OFF)
            postUpdate(Harmony_skytv, OFF)
            postUpdate(Harmony_alles, ON)
end

rule "Kodi TV schauen"
    when
        Item Harmony_koditv changed to ON
    then

            Harmony_Activity.sendCommand("24361209")
            postUpdate(Harmony_skybeamer, OFF)
            postUpdate(Harmony_kodibeamer, OFF)
            postUpdate(Harmony_skytv, OFF)
            postUpdate(Harmony_alles, ON)

end

rule "Kodi Beamer schauen"
    when
        Item Harmony_kodibeamer changed to ON
    then

            Harmony_Activity.sendCommand("24360748")
            postUpdate(Harmony_koditv, OFF)
            postUpdate(Harmony_skybeamer, OFF)
            postUpdate(Harmony_skytv, OFF)
            postUpdate(Harmony_alles, ON)

end

rule "Alle Media Geräte aus"  //Switch everything off and update the activities
    when
        Item Harmony_alles changed from ON to OFF
    then

            Harmony_Activity.sendCommand("PowerOff")
 			postUpdate(Harmony_koditv, OFF)
            postUpdate(Harmony_skybeamer, OFF)
            postUpdate(Harmony_kodibeamer, OFF)
            postUpdate(Harmony_skytv, OFF)
            postUpdate(Harmony_alles, ON)

end
3 Likes

how can i understand this whole rules…

Can you there directly control an activity on the harmony hub? I think i do not really understand how to control the whole harmony activities via OpenHab 2 :frowning:

The Number in the rule is the thing number of the device?

And are the “Name items” the same name like the activities in the hub?

You don’t need rules, you may use them to extend functionality.
Direct control:

http://docs.openhab.org/addons/bindings/harmonyhub/readme.html

Hi guys sorry to bardge on an old thread, its just i’ve read through google etc to no avail… any ways I too have installed the logitech hub, I added thing as above etc… I can only seem to control devices through paper ui and not classic ui… my hub shows online, I can see activity state on classic ui which refreshes when I use the harmony remote… I tried using habpanel button format with the openhab command value to the item but it doesnt work any helps appreciated

Hi,
I’ve got it working with activity names. All good. Now I’d like to change it to activity IDs in order to accommodate for changing activity names over time. My dumb question would be on how to get those IDs identified? I can’t see them neither in OpenHAB nor in the Logitech Harmony Control app for iOS.

Cheers.

Rainer

Go to PaperUI → Configuration → Things and select one of your devices, you should see the id at the end of the definition:

Thanks sihui.

What you mentioned are the device IDs being available as part of the device definition. That’s fine.

What I’m looking for are the activity IDs for something like “Watch TV” configured on the Harmony Hub via the Harmony Control app. In earlier posts there are code examples like:

String Harmony_Activity "Current Activity [%s]"  (Wohnzimmer) { channel="harmonyhub:hub:HarmonyHub:currentActivity" }
...
Harmony_Activity.sendCommand("24361209")

My understand is that you can choose either the activity name (Watch TV) or the ID (24361209). Where can I find the ID related to the activity?

Rainer

At the end of the docs:

Possible values for the “buttonPress” channel can be determined via the REST API for channel-types, http://YourServer:8080/rest/channel-types. Search the JSON for “harmonyhub:device”.

Here is my setup. I’ve found this works very well with the Harmony and HomeKit. Hopefully this helps someone who is trying to integrate OpenHab, Harmony, and even HomeKit.

Explanation for making sense of names going forward. Harmony activity “Watch Movies” used to be name “Apple TV” I expose this to HomeKit with the name “Movie Station” because Siri didn’t want to respond to “Turn on Apple TV”. There may be references to Delonghi. This is a portable air conditioner that I have learned specific commands into a new Harmony device. This allows me to trigger quick settings from Harmony, and now OpenHab and HomeKit.

The activity “Retro Gaming” while switch the Harmony to the correct activity, turns on a WeMo switch that I have plugged into my Raspberry Pi running RetroPie.

items:

String TheVerseRemoteActivity "Current Activity [%s]" (gLiving) { channel="harmonyhub:hub:TheVerseRemote:activity" }
Switch TheVerseRemote_Apple TV "Movie Station" (gVerseRemoteActivity) [ "Switchable" ]
Switch TheVerseRemote_RetroPie "Retro Gaming" (gVerseRemoteActivity) [ "Switchable" ]
Switch TheVerseRemote_WiiU "Wii U" (gVerseRemoteActivity) [ "Switchable" ]
Switch TheVerseRemote_Xbox360 "Xbox 360" (gVerseRemoteActivity) [ "Switchable" ]
Switch TheVerseRemote_Other "Other HDMI" (gVerseRemoteActivity) [ "Switchable" ]

things:

Bridge harmonyhub:hub:TheVerseRemote [ name="The Verse Remote",host="10.0.42.252" ] {
        device Delonghi [ id=47218609 ]
}

rules:

rule "Starting Values"
        when
                System started
        then
                if ( TheVerseRemote_AppleTV.state == NULL ) { postUpdate(TheVerseRemote_AppleTV,OFF) }
                if ( TheVerseRemote_RetroPie.state == NULL ) { postUpdate(TheVerseRemote_RetroPie,OFF) }
                if ( TheVerseRemote_WiiU.state == NULL ) { postUpdate(TheVerseRemote_WiiU,OFF) }
                if ( TheVerseRemote_Xbox360.state == NULL ) { postUpdate(TheVerseRemote_Xbox360,OFF) }
                if ( TheVerseRemote_Other.state == NULL ) { postUpdate(TheVerseRemote_Other,OFF) }
                if ( LivingRoomAC_KickOn.state == NULL ) { postUpdate(LivingRoomAC_KickOn,OFF) }
                if ( LivingRoomAC_KickOff.state == NULL ) { postUpdate(LivingRoomAC_KickOff,OFF) }
                if ( LivingRoomAC_Status.state == NULL ) { postUpdate(LivingRoomAC_Status,OFF) }
end

rule "Catch PowerOff"
        when
                Item HarmonyHubTheVerseRemote_CurrentActivity changed
        then
                switch (HarmonyHubTheVerseRemote_CurrentActivity.state) {
                        case "PowerOff" : {
                                postUpdate(TheVerseRemote_AppleTV,OFF)
                                postUpdate(TheVerseRemote_RetroPie,OFF)
                                postUpdate(TheVerseRemote_WiiU,OFF)
                                postUpdate(TheVerseRemote_Xbox360,OFF)
                                postUpdate(TheVerseRemote_Other,OFF)
                        }
                        case "Watch Movies" : {
                                postUpdate(TheVerseRemote_AppleTV,ON)
                                postUpdate(TheVerseRemote_RetroPie,OFF)
                                postUpdate(TheVerseRemote_WiiU,OFF)
                                postUpdate(TheVerseRemote_Xbox360,OFF)
                                postUpdate(TheVerseRemote_Other,OFF)
                        }
                        case "Retro Gaming" : {
                                postUpdate(TheVerseRemote_AppleTV,OFF)
                                postUpdate(TheVerseRemote_RetroPie,ON)
                                postUpdate(TheVerseRemote_WiiU,OFF)
                                postUpdate(TheVerseRemote_Xbox360,OFF)
                                postUpdate(TheVerseRemote_Other,OFF)
                        }
                        case "Wii U" : {
                                postUpdate(TheVerseRemote_AppleTV,OFF)
                                postUpdate(TheVerseRemote_RetroPie,OFF)
                                postUpdate(TheVerseRemote_WiiU,ON)
                                postUpdate(TheVerseRemote_Xbox360,OFF)
                                postUpdate(TheVerseRemote_Other,OFF)
                        }
                        case "Play Xbox 360" : {
                                postUpdate(TheVerseRemote_AppleTV,OFF)
                                postUpdate(TheVerseRemote_RetroPie,OFF)
                                postUpdate(TheVerseRemote_WiiU,OFF)
                                postUpdate(TheVerseRemote_Xbox360,ON)
                                postUpdate(TheVerseRemote_Other,OFF)
                        }
                        case "Other" : {
                                postUpdate(TheVerseRemote_AppleTV,OFF)
                                postUpdate(TheVerseRemote_RetroPie,OFF)
                                postUpdate(TheVerseRemote_WiiU,OFF)
                                postUpdate(TheVerseRemote_Xbox360,OFF)
                                postUpdate(TheVerseRemote_Other,ON)
                        }
                }
end

rule "Apple TV Start"
        when
                Item TheVerseRemote_AppleTV changed from OFF to ON
        then
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Watch Movies")
                {
                        HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("Watch Movies")
                }
                postUpdate(TheVerseRemote_RetroPie,OFF)
                postUpdate(TheVerseRemote_WiiU,OFF)
                postUpdate(TheVerseRemote_Xbox360,OFF)
                postUpdate(TheVerseRemote_Other,OFF)

end

rule "RetroPie Start"
        when
                Item TheVerseRemote_RetroPie changed from OFF to ON
        then
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Retro Gaming")
                {
                        HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("Retro Gaming")
                        RetroPieSwitch.sendCommand("ON")
                }
                postUpdate(TheVerseRemote_AppleTV,OFF)
                postUpdate(TheVerseRemote_WiiU,OFF)
                postUpdate(TheVerseRemote_Xbox360,OFF)
                postUpdate(TheVerseRemote_Other,OFF)
end

rule "Wii U Start"
        when
                Item TheVerseRemote_WiiU changed from OFF to ON
        then
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Wii U")
                {
                        HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("Wii U")
                }
                postUpdate(TheVerseRemote_AppleTV,OFF)
                postUpdate(TheVerseRemote_RetroPie,OFF)
                postUpdate(TheVerseRemote_Xbox360,OFF)
                postUpdate(TheVerseRemote_Other,OFF)
end

rule "Xbox 360 Start"
        when
                Item TheVerseRemote_Xbox360 changed from OFF to ON
        then
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Play Xbox 360")
                {
                        HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("Play Xbox 360")
                }
                postUpdate(TheVerseRemote_AppleTV,OFF)
                postUpdate(TheVerseRemote_RetroPie,OFF)
                postUpdate(TheVerseRemote_WiiU,OFF)
                postUpdate(TheVerseRemote_Other,OFF)
end

rule "Other HDMI Start"
        when
                Item TheVerseRemote_Other changed from OFF to ON
        then
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Other")
                {
                        HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("Other")
                }
                postUpdate(TheVerseRemote_AppleTV,OFF)
                postUpdate(TheVerseRemote_RetroPie,OFF)
                postUpdate(TheVerseRemote_WiiU,OFF)
                postUpdate(TheVerseRemote_Xbox360,OFF)
end

rule "When all devices are off"
        when
                Item TheVerseRemote_AppleTV changed from ON to OFF or
                Item TheVerseRemote_RetroPie changed from ON to OFF or
                Item TheVerseRemote_WiiU changed from ON to OFF or
                Item TheVerseRemote_Xbox360 changed from ON to OFF or
                Item TheVerseRemote_Other changed from ON to OFF
        then
                Thread::sleep(250)
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "Retro Gaming" && RetroPieSwitch.state == ON)
                {
                        RetroPieSwitch.sendCommand(OFF)
                }
                if (HarmonyHubTheVerseRemote_CurrentActivity.state != "PowerOff")
                {
                        if (HarmonyHubTheVerseRemote_CurrentActivity.state == "Watch Movies" && TheVerseRemote_AppleTV.state == OFF) {
                                HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("PowerOff")
                        }
                        if (HarmonyHubTheVerseRemote_CurrentActivity.state == "Retro Gaming" && TheVerseRemote_RetroPie.state == OFF) {
                                HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("PowerOff")
                        }
                        if (HarmonyHubTheVerseRemote_CurrentActivity.state == "Wii U" && TheVerseRemote_WiiU.state == OFF) {
                                HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("PowerOff")
                        }
                        if (HarmonyHubTheVerseRemote_CurrentActivity.state == "Play Xbox 360" && TheVerseRemote_Xbox360.state == OFF) {
                                HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("PowerOff")
                        }
                        if (HarmonyHubTheVerseRemote_CurrentActivity.state == "Other" && TheVerseRemote_Other.state == OFF) {
                                HarmonyHubTheVerseRemote_CurrentActivity.sendCommand("PowerOff")
                        }
                }
end

This set of rules keeps HomeKit up to date with current Harmony Activity. OpenHab, Harmony and HomeKit now agree which activities are On and which are Off.

sitemap (for those who care):

sitemap HomeMap label="The Verse Devices"
{
        Frame label="WeMo" {
                Switch item=RetroPieSwitch
        }
        Frame label="The Verse Remote" {
                Selection item=HarmonyHubTheVerseRemote_CurrentActivity mappings=[PowerOff="PowerOff","Watch Movies"="Watch Movies","Retro Gaming"="Retro Gaming","Wii U"="Wii U","Play Xbox 360"="Xbox 360",Other="Other"]
                Switch item=TheVerseRemote_AppleTV
                Switch item=TheVerseRemote_RetroPie
                Switch item=TheVerseRemote_WiiU
                Switch item=TheVerseRemote_Xbox360
                Switch item=TheVerseRemote_Other
        }
}
4 Likes

I’m just setting up my new Harmony Hub, and so far so good (i am used to OH2 having used it and OH1 for several years).

In the manual pages, there are example rule like:

rule "Starting TV"
when
    Channel "harmonyhub:hub:GreatRoom:activityStarting" triggered Watch_TV
then
    logInfo("Harmony", "TV is starting...")
end

rule "TV started"
when
    Channel "harmonyhub:hub:GreatRoom:activityStarted" triggered Watch_TV
then
    logInfo("Harmony", "TV is started")
end

I’ve not seen this sort of Channels … triggered syntax before in rules, and it also doesn’t work (using my own “Thing” not the example of course).

The Only Channel I have is:

harmonyhub:hub:HarmonyHub:currentActivity

Can someone explain this (it looks self explanatory, but as I say it doesn’t work).
Looks quite useful.

BTW I’m using the latest released (stable) version 2.2

Thanks,

The trigger channels that the documentation mentions are part of the 2.2.0-SNAPSHOT builds (see also issue #1390. So they will not work in 2.1.0. Another binding that has these trigger channels is the Astro binding.

Ah ha!

I see, so only the latest SNAPSHOT builds have this functionality. I will download and try it out immediately!

Would probably be useful if the documentation mentioned this, but we can figure it out I guess.

Thanks for the quick reply.

It does :rofl:, just switch the article version:

1

OK, on the latest harmonyhub SNAPSHOT, and all is working.

Thanks.

Same here :grinning:

I also have problems getting the harmony binding working:

I added the hub to the things file. Then I got the IDs of the items from autodiscover (this seems to work)

Things:

Bridge harmonyhub:hub:wohnzimmer [ host="192.168.X.X" ] {
    device HisenseTV "Hisense TV" [ id=46326561]
    device Playstation3 "Playstation 3" [ id=46326627]    
    device FireTV "Amazon Fire TV" [ id=46307375]
    device AltecSpeaker "Altex Lansing Lautsprecher" [ id=46326894]
}

Items:

String HarmonyHisenseTV (gMain) { channel="harmonyhub:device:wohnzimmer:46326561:buttonPress" }

Sitemap:
Switch item=HarmonyHisenseTV mappings=[PowerToggle="PowerToggle"]

What’s wrong here?

thx
best regards,
Dave

still problems? what do you want to achieve?

I just installed OH 2.2 stable (Docker container) with the latest bindings. I have two harmony hubs and tried to use activityStarting and activityStarted in my rules (I used the example from the documentation and only changed the name of the harmony hub). But the rules are not triggered and I don’t see anything in the logs.

In PaperUI all three channels are shown. Any idea why activityStarting and activityStarted are not triggered?

Best regards,
Björn

I can’t offer you a fix for your problem but I can let you know you are not alone. I have the same problem and have been unable to figure out why.

There seems to be a very small subset of users who are experiencing this issue.

@bjsjr thanks for the information. I worked around the problem. So my rules are working, again.