Harmony hub in a rule

I have the following rule:
rule "radio on"
when
Item Radio changed from OFF to ON
then
sendCommand(philips_power, ON)
sendCommand(philips, PLAY)
sendCommand(stereo, ON)

end

It’s works.
I want to add an action by sending a command to my harmony hub. I made an activity in the app namend “Radio”

What do i add to send the command.

i’m totally lost

harmonyhub:hub:HarmonyHub2:activityStarting Radio    ?

define an item in the harmony hub thing (current activity) and sendCommand „radio“ to it.

btw. well explained here

Hi,

I do it like this:

rule "Alexa verbinden"

when

    Item harmonyhub_hub_Wohnzimmer received update

 

then

    logInfo("Info", "Alexa verbinden rule Start")

    if ((harmonyhub_hub_Wohnzimmer_currentActivity.state == "Radio") || (harmonyhub_hub_Wohnzimmer_currentActivity.state == "Aussenboxen Radio")){

        EG_wz_fs_stereoanlage.postUpdate(ON)

        EG_wz_fs_stereoanlage.sendCommand(ON)

    }

    else{

        if (EG_wz_fs_stereoanlage.state == ON){

             EG_wz_fs_stereoanlage.postUpdate(OFF)

             EG_wz_fs_stereoanlage.sendCommand(OFF)

             EG_wz_alexa_radio.sendCommand(OFF)

        }

    }

    logInfo("Info", "Alexa verbinden rule Stop")

end

I have no items for the actions Radio and Aussenboxen Radio defined.

How is the activity called in your harmony app ?

Radio & Außenboxen Radio

but you are not using the harmony channel(s).
with the harmony channels you dont need any rules. this can be done simply with a sitemap definition.

1 Like

please explain

check the example sitemap in the documentation.

I’m still confused to do this, Can you show me your thing file.

And the devices in your harmony app + the activities ?

thanks in advance

Peter,

maybe you are wrong way?
I don’t work with any items, therefore I don’t have any thing files. I just request the state of the currentActivity at the Harmony hub. Based on the state, I created a rule.

I have defined different activities at the Harmony Hub i.e. Radio.
If I call Radio from the Harmony Remote, the Harmony Hub starts my Receiver (it is that old, it does not have a LAN connection to integrated it into openhab directly) and switch it to Tuner. In addition, openhab switch a plug on which enables a bluetooth device for further operations.

I hope you get it clear.

Oke, @dascrip you do smething totaaly different i think. But thanks for the contribution.

@HaKuNa, this is what i have done:

Things file:

Bridge harmonyhub:hub:HarmonyHub2 [ host="192.168.11.54"]

    devide PhilipsAV [ name="Philips AV-ontvanger"]
    device PhilipsTD [ name="Philips Tapedeck"]
    device samsungTV [ name="Samsung Tv"]
}

The device names are the same as in the harmony app (android)

I have made 1 activity in the harmony app called “radio”, it changes the input from cd to aux

then i made an items file:

String Harmonyhub2Activity "Current Activity [%s]" (gMain) { channel="harmonyhub:hub:HarmonyHub2:activityStarted" }

and a rule:

rule "Starting Radio"
when
    Item harmony changed from OFF to ON
then
    sendCommand(Harmonyhub2Activity, Radio)
end

when pressing the switch to change (fake) switch harmony from off to on the log says:

Rule 'Starting Radio': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null

Where do i go wrong ?

Give a try with

Harmonyhub2Activity.sendCommand('Radio')

Herewith another example, how I use Alexa (in your case a switch, etc.) to switch on the stereo:

rule "Alexa schaltet Stereoanlage ein"

when 

        Item EG_wz_alexa_radio changed to ON or

        Item Echo_Living_Room_Player changed to PLAY

then

        logInfo("Info", "Alexa schaltet Stereoanlage ein rule Start")

        harmonyhub_hub_Wohnzimmer.sendCommand('Radio')

        logInfo("Info", "Alexa schaltet Stereoanlage ein rule Stop")

end

The rule calls the activity ‘Radio’ at my Harmony Hub.
I hope this helps

Oke, that does not do anything. By the way this is what exactly what i try to do. To get Alexa put on the radio.

So the 'first" rule is. When i say Alexa Radio on:

rule "radio on"
when
    Item Radio changed from OFF to ON 
then
 sendCommand(philips_power, ON)
 sendCommand(philips, PLAY) 
 sendCommand(stereo, ON)
end

It send a command to a tradfri plug to put power an the reciever (stereo ON, it send 2 commands to a squeezeplayer PLAY and ON.
The problem i tried to solve, the reciever is standard on cd and not on AUX. The Harmony so send a command to change the input.
So i made an activity called radio that changes the input.

When i press it on the android app, it does that (duh) ans i see in the openhab2 event log:

2020-10-05 14:51:14.124 [vent.ChannelTriggeredEvent] - harmonyhub:hub:HarmonyHub2:activityStarted triggered Radio
2020-10-05 14:51:14.140 [vent.ItemStateChangedEvent] - harmonyhub_hub_HarmonyHub2_currentActivity changed from PowerOff to Radio

So i can make (like you did) another rule, like this:

rule "Alexa schaltet Stereoanlage ein"

when 

             Item philips changed to PLAY

then

        logInfo("Info", "Alexa schaltet Stereoanlage ein rule Start")

        Harmonyhub2.sendCommand('Radio')

        logInfo("Info", "Alexa schaltet Stereoanlage ein rule Stop")

end

I will give this a try

Does not seem to work either.

Why is this so difficult to solve?.

When starting the activity on my phone it says in my event log:

2020-10-06 08:28:49.471 [vent.ChannelTriggeredEvent] - harmonyhub:hub:HarmonyHub2:activityStarted triggered Radio
2020-10-06 08:28:49.492 [vent.ItemStateChangedEvent] - harmonyhub_hub_HarmonyHub2_currentActivity changed from PowerOff to Radio

So what is the rule for starting the same activity ?

Pleeaaassseee help

Sorry, then I couldn’t help you here.

What I could tell, I haven’t create things file manually. I used paperUI to add the hub - maybe here is the difference.

Does not make a difference,

When i do it through paper UI i get the same issue, i just need to know what the ‘command’ is to send to the hub from openhab rule

you need an item „current activity“ in harmony thing.
then in the rule just use:

itemname.sendCommand(“Radio”)

OR:
you post your thing config and your items regarding harmony stuff.
otherwise it will be hard to help you here.
again, the docs should help. check the examples (thing, items, sitemap).
and is your harmony thing online in paperUI ?