digitaldan / harmony-client

Logitech Harmony WebSocket Client
Eclipse Public License 2.0
4 stars 0 forks source link

[harmonyhub] NumberFormatException when selecting a hue scene #12

Closed hcgpraesi closed 7 months ago

hcgpraesi commented 9 months ago

A possible cause for this error was identified in this issue: https://github.com/openhab/openhab-addons/issues/6732

Details are here: https://github.com/openhab/openhab-addons/issues/6732#issuecomment-1917447729

Below you can find my setup to reproduce th error.

BR Reinhard


I use a Harmony Hub to control my TV, AV receiver and TV box. This works well since many years. I use the Harmony Elite to start and stop several AV scenarios (TV, Chromecast, etc.).

I also have a hue bridge and my complete home is equipped with hue lamps. I have paired my Harmony Hub with the hue bridge and have synced lamps and scenes to the Harmony Hub.

And of course I have integrated the hub and the bridge into my OpenHAB 4 environment. I run OpenHAB on an Raspberry Pi in the actual stable version.

On my Harmony Elite there are 4 buttons on the bottom of the remote control, which you can use to control some home automation devices. I have configured each of the four buttons to trigger a specific hue scene defined in the bridge. A long press turns the scene off. This is the standard functionality, if you select a scene for the button.

When I press one of these buttons the scene is triggerd by the Harmony Hub on the hue bridge as intended. But the Harmony Hub goes offline with the following error message seen in error log.

'harmonyhub:hub:LivingRoom' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Could not connect: java.lang.NumberFormatException: For input string: "hueScene-ifn0JQ6XtpD9s9r"

After 30 seconds the heartbeat restores the connection again.

I am pretty sure, that this error occured already quite long (the original post is from 2020). As the heartbeat of the Harmony binding repairs the connection, you normally don't see the error. Also the hue scenes are triggered correctly.

I detected the error message after the last update of OH4. At that time I tested all functions and checked in the log, if everything is working as expected. And so I found this error.

I tried already a re-installation of the Harmony binding, I re-paired the Hue bridge, I synced my scens and lamps. The problem didn't go away.

I use openHAB 4.1.1 Release Build.

On the Hue bridge version 2 I use the actual software release,

On the Harmony Hub I also use the latest release 4.15.330


jlaur commented 8 months ago

Just to have the information directly in this issue:

I was able to obtain a bit more details by:

log:set trace com.digitaldan.harmony.HarmonyClient

Logged:

2024-01-30 17:34:00.537 [TRACE] [com.digitaldan.harmony.HarmonyClient] - onWebSocketText {"type":"harmony.engine?startActivityFinished","data":{"activityId":"hueScene-Bc5WzFrmJ1Br2iT0","errorCode":"200","errorString":"OK"}}
2024-01-30 17:34:00.540 [DEBUG] [com.digitaldan.harmony.HarmonyClient] - onWebSocketError
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "hueScene-Bc5WzFrmJ1Br2iT0"
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:251) ~[?:?]
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:241) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433) ~[?:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1227) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1329) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1300) ~[?:?]
    at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179) ~[?:?]
    at com.digitaldan.harmony.messages.MessageDeserializer.deserialize(MessageDeserializer.java:47) ~[?:?]
    at com.digitaldan.harmony.messages.MessageDeserializer.deserialize(MessageDeserializer.java:17) ~[?:?]
    at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1227) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1137) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:1047) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:982) ~[?:?]
    at com.digitaldan.harmony.HarmonyClient$MyWebSocketListener.onWebSocketText(HarmonyClient.java:518) ~[?:?]
    at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextMessage(JettyListenerEventDriver.java:296) ~[bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69) ~[bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:67) ~[bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextFrame(JettyListenerEventDriver.java:235) ~[bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:152) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:326) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:202) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:225) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.Parser.parseSingleFrame(Parser.java:259) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:459) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:440) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [bundleFile:9.4.52.v20230823]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [bundleFile:9.4.52.v20230823]
    at java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: java.lang.NumberFormatException: For input string: "hueScene-Bc5WzFrmJ1Br2iT0"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) ~[?:?]
    at java.lang.Integer.parseInt(Integer.java:668) ~[?:?]
    at java.lang.Integer.parseInt(Integer.java:786) ~[?:?]
    at com.google.gson.JsonPrimitive.getAsInt(JsonPrimitive.java:219) ~[?:?]
    at com.google.gson.internal.bind.JsonTreeReader.nextInt(JsonTreeReader.java:250) ~[?:?]
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:249) ~[?:?]
    ... 41 more
2024-01-30 17:34:00.575 [DEBUG] [com.digitaldan.harmony.HarmonyClient] - notifyClose java.lang.NumberFormatException: For input string: "hueScene-Bc5WzFrmJ1Br2iT0" {}
2024-01-30 17:34:00.579 [DEBUG] [b.internal.handler.HarmonyHubHandler] - Updating listeners with status OFFLINE
2024-01-30 17:34:00.581 [DEBUG] [com.digitaldan.harmony.HarmonyClient] - onWebSocketClose 1006 java.lang.NumberFormatException: For input string: "hueScene-Bc5WzFrmJ1Br2iT0"
2024-01-30 17:34:00.583 [DEBUG] [com.digitaldan.harmony.HarmonyClient] - notifyClose java.lang.NumberFormatException: For input string: "hueScene-Bc5WzFrmJ1Br2iT0" {}

So activityId can be something like "hueScene-Bc5WzFrmJ1Br2iT0", but is expected to be Integer here:

https://github.com/digitaldan/harmony-client/blob/3688498071cc711f80c8c5d51c2654065f0947e9/src/main/java/com/digitaldan/harmony/messages/ActivityFinishedMessage.java#L20

jlaur commented 7 months ago

@digitaldan - gentle ping. Most likely you didn't have time to look into this yet, but just in case you forgot. 😉

digitaldan commented 7 months ago

Thank @jlaur this is fixed, and i have a PR up at https://github.com/openhab/openhab-addons/pull/16646