Harmony Hub rules and Activity IDs

Hi everyone,

I’m very new to this whole thing but I am very eager to learn and have been enjoying spending the last couple of weeks learning how OpenHab 2 can make me even smarter, or lazier for some, than I already am.

I am running OH2 on the current LTS of Ubuntu (16.04). Within OH2 (2.1.0) I have the network binding, WoL binding, harmonyhub binding and Exec binding installed.

I have been successful in being able to write a couple of rules that wake different PC’s up that I have on my home network.

Problem: I am trying to add a rule to one of my harmony activities that will trigger a WoL. I have a home theatre setup with a PC/projector/tuner. Within Harmony, I have an activity called “Theatre” that will turn on the projector and the tuner to the correct settings. I have not been able to figure out a rule to trigger a WoL for the PC.

Here is what I have so far and to be honest, after browsing a number of threads, I seem more lost than when I started.

.items
String harmony_hub “activity [%s]” {harmonyhub=“harmonyhub:hub:HarmonyHub:currentActivity”}

.rules
rule “Home Theatre"
when
Item harmony_hub received command Theatre
then
wol=”<broadcastIP>#<MAC>"
end

I’m not very knowledgeable on how to get logs out of things, but from looking at the logs when I invoke a change through PaperUI this is what I get:

20:30:06.809 [INFO ] [marthome.event.ItemStateChangedEvent] - harmonyhub_hub_HarmonyHub_currentActivity changed from PowerOff to Theatre
20:30:06.809 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘harmonyhub_hub_HarmonyHub_currentActivity’ received command Theatre

It seems that when I had ‘simple mode’ enabled that an item was automatically created called “harmonyhub_hub_HarmonyHub_currentActivity.” When I change the rule and test it with that item, this is the error I get:

20:46:15.843 [INFO ] [marthome.event.ItemStateChangedEvent] - harmonyhub_hub_HarmonyHub_currentActivity changed from PowerOff to Theatre
20:46:15.844 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘harmonyhub_hub_HarmonyHub_currentActivity’ received command Theatre
20:46:15.854 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘Home Theatre’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: default.rules#|::0.2.0.2.0.0::0::/1)

So two things I guess, how do I fix this item since I don’t have it in my .item file and it is just within the PaperUI database, and how can I get wol working for this activity?

Any help on how to log or move forward with this is greatly appreciated!

Thanks!!

for the WOL stuff: you have to create an item for this. What you are trying to do right now is assign a value to “wol”, and that cannot work.
So either you create a item for this, how you are going to do this is described here and then you call it from the rule like this:

wolItem.sendCommand(ON)

Or, if you don’t want to create an item for this, you could invoke the exec binding directly from the rule. AFAIK, there is no option to call the wol binding without an item. You could do it like this:

executeCommandLine("/usr/bin/wakeonlan -i IP-Address-here MAC-Address-Here")

Regarding the .items file, I think your only option is to delete it within the PaperUI and then create the .items file (not sure though)

Nicholas,

You gave me just enough information to make it work. Well, the rule works anyway, the .items parts is still a bit wonky and I will work on that later.

I already had a WoL item setup for the media centre itself, so in essence all I had to do was call it up within the rule.

.rules
rule “Home Theatre"
when
Item harmonyhub_hub_HarmonyHub_currentActivity received command Theatre
then
home_theatre.sendCommand(ON)
end

Thank you for the quick replies! Appreciate the help.

1 Like