Starting Harmony activity from a rule

I added my hub through PaperUI. I added the following items:

 String HarmonyCurrentActivity "Current Activity [%s]" {channel="harmonyhub:hub:FamilyRoomHub:currentActivity"}
 String HarmonyStartingActivity "Starting Activity [%s]" {channel="harmonyhub:hub:FamilyRoomHub:activityStarting"}
 String HarmonyActivityStarted "Activity Started [%s]" {channel="harmonyhub:hub:FamilyRoomHub:activityStarted"}

and I now see HarmonyCurrentActivity log entries when I start and stop activities with my remote control. Strangely I don’t see the activityStarting or activityStarted events, but they aren’t that important to me.

But what I want to do now is start and stop activities with rules. How do I do that?

 rule "Armed away. Turn the TV off"
 when
   Item ArmUpState received update "Armed with Exit Timer working"
 then
   // turn the "watch tv" activity off
 end

@SkipMorrow

rule "Armed away. Turn the TV off"
when
  Item ArmUpState received update "Armed with Exit Timer working"
then
  HarmonyCurrentActivity.sendCommand("PowerOff")
end
2 Likes

Send a command to the current activity:

HarmonyCurrentActivity.sendCommand("Activity Name")

The state is whatever you’ve named the activity in the Harmony app (e.g. “Apple TV”). If you want to turn off the system, use “PowerOff”.

This was something I hadn’t even considered when I got into openHAB, but it’s now one of my favourite things about it. Whenever openHAB sees that my Chromecast is not idle, it automatically turns on the “Chromecast” Harmony Hub activities. When the Chromecast goes back to idle (meaning I’ve stopped streaming content), the Harmony Hub turns off after five minutes.

1 Like