Harmony Hub + Openhab2

Using Openhab2, can someone give me a sample rule of how to use openhab2 with the harmony hub?

From what I’ve read in OH2, I do not need to set anything manually? Is that correct? No config file or items/things?
I just let it discover it in Paper UI and added it as a thing.

I have just one channel. So what would a rule look like to call this hub to say activate an “activity” i have programmed into the hub?

You have to manually code your activities in Items or use them in Rules. This will help you understand how to find your activities available through the REST API and set them up - https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.harmonyhub

Thanks. I saw that already. There are no “Rule” examples.
Theres a sitemap example, but I want to make a switch and when i trigger that switch, somehow call the activity that is in the harmony.

What would something like that look like?
rule "Harmony Bedroom Netflix"
when
Item BRHarmony_Nexflix received command
then

Some how call this { channel=“harmonyhub:hub:Bedroom:HarmonyHub:buttonPress” } with a saved activity “BedroomTVNetflix” <----this is the part i need help with…the actual rule and how to trigger it

end

Here’s how I did mine. I created an item linked to the activity channel:

AV_GF_Harmony_Activity

Then in the rule you would just send the activity to the Item:

AV_GF_Harmony_Activity.sendCommand("PowerOff")

So for yours you need to find the right activity to for your NetFlix and send it in your rule to your item.

I hope that makes it a little clearer

Edit:

So in your case for your rule you would then use an if/else check so that if your switch was turned on you’d send the NetFlix command and if off you’d send the “PowerOff” command.

You had me until the If/Else
I get the item part now and how to send it an activity.

So here’s what i have in the app.

There is an activity called BR Roku Netflix.
It will 1)Turn on TV 2)Set the HDMI switch to 2 and 3)Turn on Netflix on the Roku
Using Harmony you turn it on, it does that, you hit OFF it run the “end sequence” screenshot 2
Does doing “PowerOff” essentially run the “End Sequence”

I guess my point is this:
If i create an item: BRHarmonyActivity
To run that saved activity i would do:

If switch=on then(pseudocode here :slight_smile: )
BRHarmonyActivity.sendCommand(“BR Roku Netflix”)

else
BRHarmonyActivity.sendCommand(“Poweroff”)

The confusion is around Poweroff. How does it know what “end sequence to run” based on that command. Is it based on what is currently ON I suppose?

Thanks

The PowerOff activity is the same as hitting the off button on the remote, which I assume executes the End Sequence. So your rule would be:

rule "Harmony Bedroom Netflix"
when
    Item BRHarmony_Netflix received command
then
   if (BRHarmony_Netflix.state == ON) {
      BRHarmonyActivity.sendCommand("BR Roku Netflix")
   } else {
      BRHarmonyActivity.sendCommand("PowerOff")
  }
end

You can also use a number item and load it with all your options and then use the Switch / Case method if you want to get fancy.

SiteMap:
Selection item=BRHarmony_Actions label="Actions" icon="switch" mappings=[1="--", 2="Power Off", 3="FirstAction", 4="SecondAction"]

rule"Harmony Bedroom"
when
	Item BRHarmony_Actions received command
then
	switch BRHarmony_Actions.state {
		case 2 : BRHarmonyActivity.sendCommand("PowerOff")
		case 3 : BRHarmonyActivity.sendCommand("FirstAction")
		case 4 : BRHarmonyActivity.sendCommand("SecondAction")
	} 
	BRHarmony_Actions.postUpdate(1)
end

Thanks.

So here’s the million dollar question…keeping the switch in sync with the remote/app.

Dilema:
Turn on with Openhab-sets switch to on which fires rule.

Turn off on the harmony remote…openhab switch is still ON

Openhab/Harmony App/Remote are out of sync.

Perhaps something like this:

rule “Harmony Activity Changed"
when
Item BedroomHarmonyActivity changed
then
sendMail(”******@gmail.com", “Harmony:Activity Changed”, "Harmony:Activity Changed: " + BedroomHarmonyActivity.state)

If (BedroomHarmonyActivity.state = “PowerOff” {
postUpdate(BRHarmony_Kodi,OFF)
}

end

That’s one of the reasons I take mine back to a null value in my multi-select approach. What you defined above should work (you have typos in your sample and I’d suggest using the new item.postUpdate() command structure). Though you’d probably want to make your if statement

If(BedroomHarmonyActivity.state != "BR Roku Netflix") {

I have a Fire TV connected to Harmony. I created an item that uses the Fire TV Thing discovered through Harmony. For the dropdown item, I can control all keys except “Select”. Select key does nothing. maybe the text sent should be different? If I use the same “Select” from the TV dropdown then the TV sends the “Select” key thru HDMI and it works.