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
}
}