So I’ve been using OpenHAB for some time now, and finally got around to learning about rules and scripts. I’ve successfully implemented quite a few rules for various items in my home, and so far so good, until now. I’ve finally wrote a rule to turn off items when I leave the house, or when I come back home, and most of my rule works like a charm, except when it comes to firing harmonyStartActivity. Here’s the relevant details: OpenHAB 1.8.3
Items:
String Harmony_Activity "Activity [%s]" (Living_Room_TV) { harmonyhub="*[LR:currentActivity]" }
String HarmonyHubOff "Power OFf" (Living_Room_TV) { harmonyhub=">[start:PowerOFF]" }
Sitemap: The sitemap is using a selection with mappings, and it works flawlessly.
Selection item=Harmony_Activity label="Activity" icon="television" mappings=[PowerOff=Off, "Watch TV"="Watch TV", "Watch Apple TV"="Watch Apple TV", "Play PS4"="Play PS4", "Play Retro"="Play Retro", "Listen to Music"="Listen to Music"]
Rule:
rule "Mode Away"
when
Item Occupied changed to OFF
then
if (Daytime.state != ON) { //its night//
logInfo("Mode", "Night away mode initiated")
if (Harmony_Activity != "Off") { //Check living room tv//
logInfo("Mode", "Away: Turning off tv")
harmonyStartActivity(LR,"PowerOff")
}
if (Away_Mode != ON) { //Check for away mode//
logInfo("Mode", "Away: mode activated")
sendCommand(Away_Mode, ON)
}
}
else if (Daytime.state == ON) { //its daytime//
logInfo("Mode", "Day away mode initiated")
}
// more if statements //
end
Everything before and after the harmonyStartActivity line fire like a champ. But every time I see “Away: Turning off tv” in the logs, it errors out and doesn’t turn off the tv.
What I’ve tried:
harmonyStartActivity(LR,“PowerOff”)
harmonyStartActivity(“LR”,“PowerOff”)
harmonyStartActivity(“LR,PowerOff”)
harmonyStartActivity(LR,PowerOff)
harmonyStartActivity(“PowerOff”) //pulled from wiki//
harmonyStartActivity(PowerOff)
harmonyStartActivity(“Power Off”)
harmonyStartActivity(“Off”)
harmonyStartActivity(Off)
harmonyStartActivity(start,“PowerOff”)
Log: With all of the above I get various error messages, I can supply them if need be.
but the log for harmonyStartActivity(PowerOff), from the wiki looks like this (and doesn’t turn off the tv):
2016-06-18 09:52:36.548 [INFO ] [org.openhab.model.script.Mode ] - Away: Turning off tv
2016-06-18 09:52:36.768 [WARN ] [c.a.internal.AutoUpdateBinding] - InstantiationException on
What am I missing here? I’ve been pulling out what hair I have left trying to figure this out…
Any help is greatly appreciated! I’ve spent hours trying to get this rule just right, and it’s so close!
//edit: I’ve updated the above to include the missing }'s & updated formatting