OH2: buttonPress for a device not working on Harmony Hub

Hello again,
I successfully integrated my Harmony Hub into openhab and I am even able to switch the actions.
Since the thing discovery also detected the single devices, I was eager to implement some features by using the buttonPress cha.nnel.

Items:

String HarmonyHubWZ             "Aktuelle Aktion [%s]"           { channel="harmonyhub:hub:Wohnzimmer:currentActivity" }
Number HarmonyHubWZBose         "Bose"                           { channel="harmonyhub:device:Wohnzimmer:14363514:buttonPress" }

Sitemap:

Switch item=HarmonyHubWZ mappings=[PowerOff="Aus","Fernsehen"="SAT/TV","Apple TV"="Apple TV","PLEX"="Plex","DVD"="DVD", "RADIO"="Radio","Licht ein/aus"="Licht"]
Switch item=HarmonyHubWZBose mappings=["Volume Up"="Volume Up","Volume Down"="Volume Down"]

The first switch works flawlessly, the second one not at all.
All I get is the following logfile:

23:03:23.778 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'HarmonyHubWZBose' received command Volume Up
23:03:23.792 [TRACE] [monyhub.handler.HarmonyDeviceHandler] - Command Volume Up  for harmonyhub:device:Wohnzimmer:14363514:buttonPress
23:03:23.795 [DEBUG] [monyhub.handler.HarmonyDeviceHandler] - Pressing button Volume Up on 0
23:03:23.798 [INFO ] [marthome.event.ItemStateChangedEvent] - HarmonyHubWZBose changed from UNDEF to Volume Up
23:03:24.381 [INFO ] [marthome.event.ItemStateChangedEvent] - HarmonyHubWZBose changed from Volume Up to UNDEF

No error, everything seems fine. Can anyone figure out what’s wrong here?
Thanks!

P.S.: I’m using the latest nightly build of OH2

Update: Seems like the button names of the device are not correct (e.g. “Volume up”).
When I use “Mute”, the device goes silent.

The question is: How can I know the names of the buttons per device?
In OH1 there was some information at the startup to be found in the logfile.
But where do I find this in OH2? Inside the admin-panels I did not see anything (unless I’m blind)

Thanks,
Boby

From the Harmony Hub Binding Wiki Page:

Shell

The harmony-java-client project on GitHub provides a simple shell for querying a Harmony Hub, and can be used to retrieve the full configuration of the hub to determine ids of available activities and devices as well as device commands (buttons).

1 Like

@rlkoshak, thank you. I’ve seen this before, but I stopped as I saw I had to install approx 150MB of Java development libraries to compile the binaries.
I am afraid, my openhab-Installation goes corrupt by installing these libraries. Is there really no interference on the same machine?

Thank you,
Boby

Hi @Boby

Looking at the Switch mapping for the second item, your switch is configured with strings, but your item is a Number type, you could try changing it to a string?

1 Like

@t65shd, thank you - that happened because I tried everything to get it working. I’ve corrected it now.
@Kai, @rlkoshak: I solved my problem by using an old openhab1 image starting in debug mode. Because in this mode, the Harmony hub binding prints out all actions, devices and available keys. For the Bose device it was “VolumeUp” and “VolumeDown”:

      "name" : "Volume",
      "function" : [ {
        "name" : "Mute",
        "label" : "Mute",
        "action" : "{\"command\":\"Mute\",\"type\":\"IRCommand\",\"deviceId\":\"14363514\"}"
      }, {
        "name" : "VolumeDown",
        "label" : "Volume Down",
        "action" : "{\"command\":\"VolumeDown\",\"type\":\"IRCommand\",\"deviceId\":\"14363514\"}"
      }, {
        "name" : "VolumeUp",
        "label" : "Volume Up",
        "action" : "{\"command\":\"VolumeUp\",\"type\":\"IRCommand\",\"deviceId\":\"14363514\"}"
      } ]

Don’t know it there’s a “debugging mode” in OH2, but it would be great to have the same option for looking up these informations easily without having to install a ~ 150MB develoment environment.

Thanks to all for your contribution!

I posted an OH 2 Logging tutorial here:

If you still have questions about putting OH 2 into debug, or certain bindings into debug ask on that thread and I’ll clarify as much as I am able.

1 Like
Possible values for the “buttonPress” channel can be determined via the REST API for channel-types, http://YourServer:8080/rest/channel-types. Search the JSON for “harmonyhub:device”.

Click on “channel-types” and next blue GET button, and in “Response Body” you will see all channels like this:

[
  {
    "parameters": [],
    "parameterGroups": [],
    "description": "Send a button press to device Motorola Beeline",
    "label": "Send Button Press",
    "itemType": "String",
    "kind": "STATE",
    "stateDescription": {
      "readOnly": false,
      "options": [
        {
          "value": "PowerToggle",
          "label": "Power Toggle"
        },
        {
          "value": "Number0",
          "label": "0"
        },
        {
          "value": "Number1",
          "label": "1"
        },
        {
          "value": "Number2",
          "label": "2"
        },
        {
          "value": "Number3",
          "label": "3"
        },
        {
          "value": "Number4",
          "label": "4"
...

No need to debug.

2 Likes

edit: restart of openhab solved it… :slight_smile:

I’m also struggling with this. I found out what the json values are

eg

“description”:“Send a button press to device Onkyo AV test”,
“label”:“Send Button Press”,
“itemType”:“String”,
“kind”:“STATE”,
“stateDescription”:{
“readOnly”:false,
“options”:[
{
“value”:“PowerOff”,
“label”:“Power Off”
},
{
“value”:“PowerOn”,
“label”:“Power On”
},
{
“value”:“PowerToggle”,
“label”:“Power Toggle”
},
{
“value”:“Keuken”,
“label”:“Keuken”
},

But when I add this in my sitemap

Switch item=OnkyoAVTest_SendButtonPress mappings=[“Keuken”=“Keuken”,“PowerToggle”=“Power Toggle”]

I receive following error

2017-08-11 21:26:43.432 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while calling handler: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@64838d rejected from java.util.concurrent.ScheduledThreadPoolExecutor@88878c[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
java.util.concurrent.ExecutionException: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@64838d rejected from java.util.concurrent.ScheduledThreadPoolExecutor@88878c[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:374)[106:org.eclipse.smarthome.core.thing:0.9.0.b5]
at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:47)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)[99:org.eclipse.smarthome.core:0.9.0.b5]
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)[99:org.eclipse.smarthome.core:0.9.0.b5]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@64838d rejected from java.util.concurrent.ScheduledThreadPoolExecutor@88878c[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)[:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326)[:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533)[:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:622)[:1.8.0_121]
at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:668)[:1.8.0_121]
at org.openhab.binding.harmonyhub.handler.HarmonyHubHandler.pressButton(HarmonyHubHandler.java:334)[184:org.openhab.binding.harmonyhub:2.1.0]
at org.openhab.binding.harmonyhub.handler.HarmonyDeviceHandler.handleCommand(HarmonyDeviceHandler.java:97)[184:org.openhab.binding.harmonyhub:2.1.0]
at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:377)[106:org.eclipse.smarthome.core.thing:0.9.0.b5]
at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)[106:org.eclipse.smarthome.core.thing:0.9.0.b5]
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)[99:org.eclipse.smarthome.core:0.9.0.b5]
… 12 more
==> /var/log/openhab2/events.log <==
2017-08-11 21:26:43.446 [ItemCommandEvent ] - Item ‘OnkyoAVTest_SendButtonPress’ received command PowerToggle

May be you should use String instead of Switch item?