Troubles setting up Harmony binding with openHAB 2

Hi,

I’m trying to set up my Harmony remote/hub with OH2 and I’m unable… partially.
What I’m doing is:

  1. install Harmony binding
  2. let it discover my hub
  3. then I add the things it sees (two items because I have 2 activities) so that I end with:
  4. in order to try to control it I manually create an item (with the correspondent xxx.items file):
String Harmony_Activity "Current Activity [%s]"  (All) { channel="harmonyhub:hub:HarmonyHub:activity" }
  1. and a sitemap entry as follows:
Switch item=Harmony_Activity label="Harmony" icon="television" mappings=[PowerOff="PowerOff", 33974847="tv", 37795934="macmini"]

It only works the PowerOff button, the other activities are never activated so they are not working…

Any idea?
Am I doing anything wrong?

Thank you!

Hi, the “tv” and “macmini” are devices not activities, activities would might look like “Watch TV”. I realize there’s not a good way to see what those are right now from the paperui, they should be visible from the rest api however at http://you-server:8080/rest/channel-types/harmonyhub%3AcurrentActivity There’s a bug right now that complicates this if you have more then one hub which I’m currently trying to fix (doesn’t sound like thats a issue for you)

Umm, I understand…
So, if it worked for me with OH1 like the following:

items

String	Harmony_Activity	"Harmony [%s]"	<television>	{ harmonyhub="*[currentActivity]" }
String	Harmony_PowerOff	"powerOff"	<video>	{ harmonyhub=">[start:PowerOff]" }
String	Harmony_TV	"Harmony TV"	<video>	{ harmonyhub=">[start:33974847]" }
String	Harmony_macmini	"Harmony Macmini"	<video>	{ harmonyhub=">[start:33996393]" }

sitemap

Switch item=Harmony_Activity label="Harmony" icon="television" mappings=[PowerOff="Off", 18756100="TV", 18770716="macmini"]

How can I do now with OH2 to make it works?
As you say that is complicated because of the bug you are trying to fix, do I need anything else or now it’s impossible to do because of the bug?

Thank you again

Ok I see the issue and the error in the code on my side, I will open up a bug for it and try and get to it soon. In the mean time if you replace the numeric id with the String version (look for the label value in the response from the REST call I posted earlier) it should work for you.

Actually I’m still confused why your Devices (which you send button commands to) have the same ID’s as activities that seem to have worked in the past? From your screenshot above it clearly shows those numbers (33974847) as device id’s an not activities, I would suggest using the activity label instead from now on until I can figure out whats going on.

Dan, related to this topic, do you have any idea why I continuously get the error:

“20:49:43.341 [ERROR] [onyhub.discovery.HarmonyHubDiscovery] - IO error during HarmonyHub discovery: No route to host: Datagram send failed”

This error shows up every ten minutes, usually in sets of 5 or 6.

Using OH2 with harmony binding 2.0.0.b4.

Note that aside from this error, the binding seems to work, e.g., I have assigned an item to the current activity, and am able to switch activities (and receive current activity values), power on/off, etc.

Any insights or thoughts on what I should be looking into would be appreciated.

MBK.

The REST call reads:

{"parameters":[],"parameterGroups":[],"description":"The label/name of the current activity of a Harmony Hub","label":"Current Activity","tags":[],"UID":"harmonyhub:currentActivity"}

From where I only find “Current Activity” as a label…

You are right, it’s kind of weird…
Anyway, continuing my tests, I do have some questions:

  • in OH1 I had to configure my user/password… in OH2 is it not needed any more?
  • your comment about device ID’s same as activities made me think: when installing it I add a Hub which has an ID/label, then I install devices and it finds 2 (I only own one remote… is that a “device”?), which they are correspondent to the 2 activities I have… and they have its own ID/label…

Finally, I tried using labels and it doesn’t work:

Switch item=Harmony_Activity label="Harmony" icon="television" mappings=[PowerOff="Off", "TV LG"="TV LG", "Sony PS3"="Sony PS3"]

It’s annoying because the PowerOff does work but the other no… Could it be something related with the channels created? where they should point from the previous pictures/code I posted? I guess it may be “Harmony_Activity” but I don’t know…

Thank you

Yep, its not needed if you are on the same network as the Hub, this is how the Harmony Mobile app works.

The Harmony binding has two types of 'Things" , Hubs and Devices. The Hub is what you control to change the current activity. An activity on the Harmony side is like a macro, it coordinates its Devices. So if I have a TV and Amp, an activity may be “watch TV” which then knows how to coordinate the TV and Amp together (power on tv, power on amp, turn amp to input 1, etc…). You probably know all this, I’m just restating so we are clear :wink:

Devices are the Things that the Hub controls, in the example above this would be the TV and the AMP. So in the PaperUI if you have added the Hub (either through a item file or using auto discovery), then it will automatically create two more Device Things, TV and AMP. Devices can be sent “buttonPress” commands, this would be like “Play” or “Pause”.

I just pushed some fixes , if you can update to the latest version that might help. Once you do, I would be interested in what your channels look like. if you go to the swagger rest endpoint (http://your-oh2:8080/doc/index.html) and click “channel-types” → “Get Channel-Types” it should give you a nice list of Activities and ButtonPresses.

We try and discovery new Hubs and Devices every 5 (maybe 10?) mins, something is failing during this, if everything else is ok then I think this is probably unnecessary logging , although it could be something else, can you open a github issue please? Thanks.

Thank you very much for the explanation, now everything is more clear and it has sense to me =)

I have tried to update it… let me know if I did correctly:

  1. I went to CloudBees and grabed the most recent 2.0.0 snapshot
  2. In order not to reset all my config I updated just the /runtime/ folder, that’s it, I deleted old one and copied new one
    Is that a correct procedure to update without loosing my configuration?

Then I went to the Rest API and got a list of Activities and ButtonPresses. There I found the labels I was using for my Activities where incorrect so I tried the ones found there and I got it working! I mean, now I can control the active activity with OH2.

Now I tried to map buttons, just a simple one: volume up/down for the TV device… and it didn’t worked. Here I don’t know if it’s related the problem with ID’s or anything else. I created an item:

String Harmony_tv "TV Button Press" (All) { channel="harmonyhub:device:HarmonyHub:33974847:buttonPress" }

And then a sitemap entry to control it:

Switch item=Harmony_Activity label="Volume" mappings=["Volume Up"=" + ","Volume Down"=" - "]

As I said, it is not working but I don’t know if it’s related with the “ID’s bug”…
Do you want me to try anything else?

Thank you very much for your help =)

I was able to solve it: the configuration was right but no the labels Harmony uses to refer to commands. Reading other posts I figured out that the commands do not have spaces so it worked like the following:

Switch item=Harmony_Activity label="Volume" mappings=["VolumeUp"=" + ","VolumeDown"=" - "]

So I think it’s everything working =)
Do you want me to try anything else in case the IDs bug is not solved?

Thank you very much

Great, glad its working!

Yes, this is a bug, I just fixed it now https://github.com/openhab/openhab2-addons/pull/1310

1 Like

so, i also have trouble setting up Harmony with OH2.

I can read the current activity, but i want to call a specific activity in a rule.
In OH1 this was possible with an action, but there are no actions for OH2, right?

Could someone please point me in the right direction on how to activate an activity not using the ui?

Thanks alot.
Mario

ok. I just found it out myself. Just use

current_activity.sendCommand("<nameOfActivity>")
2 Likes

Hello All,

I’m using this along with the Hue Emulation module.

I would like to be able to map a specific activity to a “switch” value so I can trigger it from Google Home via Hue Emulation.

I tried setting up a Switch item with a mapping for “PowerOff” and “Tivo” ,

Switch denTivo "Tivo [MAP(Tivo.map):%s]" <television>  { channel="harmonyhub:hub:HarmonyHub:currentActivity" }

but when I try to use it, I get the message:

[WARN ] [harmonyhub.handler.HarmonyHubHandler] - Command {]: Not a acceptable type (String or Decimal), ignorning

What’s the proper way to do this. I don’t want to have to use IFTTT and go out to the internet for such a simple operation.

Thanks,
Scott

Edit: I was able to get this working using a rule and the sendCommand() method above, but it doesn’t seems like that should be needed.

Hi Scott,

I think you should use a rule for that.
i’ve done it this way with Alexa:

rule "Fire TV schauen"
    when
        Item hh_firetv changed
    then
    	logDebug("Harmony", "Entry - Rule: Fire TV schauen")
        if ( hh_firetv.state == ON ){
            logInfo("Harmony", "FireTV: AN")
            hh_current.sendCommand("FIRE TV")
        } else {
            logInfo("Harmony", "FireTV: AUS")
            hh_current.sendCommand("PowerOff")
        }
        logDebug("Harmony", "Exit  - Rule: Fire TV schauen")
end

hh_firetv it the switch that i can set or get’s set via Alexa to trigger the Harmony-activity.
it’s defined like this:

Switch hh_firetv 	"Fire TV" 	(harmony) 	[ "Switchable" ]

Hello,

thats almost what i am looking for several hours now.

I try to find a command that is compatible with the hue emulation addon.

I tried to use your rule as you seem to want to do the same. But its not working for me. He says that he can not find the method current_activity.
where did you define the hh_current function?

my code:

home.item

Switch Harmony_KodiTV 	"Kodi auf Fernseher" 	(Wohnzimmer) 	[ "Switchable" ]

harmony.rules

rule "Kodi Fernsehen einschalten"
    when
        Item Harmony_KodiTV changed
    then
    	//logDebug("Harmony", "Entry - Rule: Fire TV schauen")
        if ( Harmony_KodiTV.state == ON ){
            //logInfo("Harmony", "FireTV: AN")
            current_activity.sendCommand("KODI auf Fernseher")
        } else {
            //logInfo("Harmony", "FireTV: AUS")
            current_activity.sendCommand("PowerOff")
        }
        //logDebug("Harmony", "Exit  - Rule: Fire TV schauen")
end

This mostly works, but still has some odd interaction between the activity and the switch.

Items:

String harmonyDenActivity				"Den Activity [%s]" <television> { channel="harmonyhub:hub:HarmonyHub:currentActivity" }
Switch denTivo "Tivo" ["Switchable"]

Rules:

rule "doTivoOn"
when   
	Item denTivo changed from OFF to ON
then   
	harmonyDenActivity.sendCommand("Tivo")
end

rule "doTivoOff"
when   
	Item denTivo changed from ON to OFF
then
	harmonyDenActivity.sendCommand("PowerOff")
end

SItemap snippet:

	Frame label="Den Multimedia" {
		Switch item=harmonyDenActivity mappings=[PowerOff="Power Off", Tivo="Tivo", Sky="Sky",PS4="PS4"]
		Switch item=denTivo
	}

I’ve tried several things trying to keep the two items in sync, but none have worked well.
With this, at least “Hey Google, turn on the tivo” works. (It actually turns on the TV, the receiver, sets the receiver input to tivo)