openhab-addons: [hue] Exception due to empty response from API (sensors)

Hallo,

To day I updated my OpenHab 3.3 to OpenHab 3.4 and promptly the hue-bridge fails. I have tried with all combinations of Port (80/443) and Protocol (HTTP/HTTPS), but still always the same result.

In the “events.log” I see the following:

023-01-14 12:03:49.543 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from UNINITIALIZED (DISABLED) to INITIALIZING
2023-01-14 12:03:49.550 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from INITIALIZING to UNKNOWN
2023-01-14 12:03:49.554 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2023-01-14 12:03:49.556 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2023-01-14 12:03:49.560 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2023-01-14 12:03:49.561 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:49.567 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:49.569 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:52.571 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from UNKNOWN to ONLINE
2023-01-14 12:03:52.573 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:52.575 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:52.576 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:54.130 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from ONLINE to OFFLINE: Hue Bridge connection lost.
2023-01-14 12:03:54.131 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:54.132 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:54.133 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:54.566 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from OFFLINE: Hue Bridge connection lost. to ONLINE
2023-01-14 12:03:54.568 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:54.569 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:54.570 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:54.637 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from ONLINE to OFFLINE: Hue Bridge connection lost.
2023-01-14 12:03:54.638 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:54.638 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:54.639 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:58.193 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from OFFLINE: Hue Bridge connection lost. to ONLINE
2023-01-14 12:03:58.194 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:58.195 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:58.196 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2023-01-14 12:03:58.698 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:bridge:huebridge' changed from ONLINE to OFFLINE: Hue Bridge connection lost.
2023-01-14 12:03:58.699 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:3' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:58.700 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0010:huebridge:2' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2023-01-14 12:03:58.700 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'hue:0107:huebridge:PresenceSensor' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

And in openhab.log the following repeats over and over again:

2023-01-14 12:03:58.696 [WARN ] [ue.internal.handler.HueBridgeHandler] - An unexpected error occurred: null
java.lang.NullPointerException: null
        at org.openhab.binding.hue.internal.connection.HueBridge.getSensors(HueBridge.java:280) ~[bundleFile:?]
        at org.openhab.binding.hue.internal.handler.HueBridgeHandler$1.doConnectedRun(HueBridgeHandler.java:199) ~[bundleFile:?]
        at org.openhab.binding.hue.internal.handler.HueBridgeHandler$PollingRunnable.run(HueBridgeHandler.java:136) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]

Expected Behavior

hue-bridge starts as “usual” 😃

Your Environment

  • Version used: openHAB 3.4.1, hue-binding 3.4.1
  • Operating System and version: OpenHab: Fedora Linux 35 (Server Edition) deconz: Raspbian GNU/Linux 10 (buster), deconz version 2.19.03 / 9/19/2022

Any suggestions?

Dan

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Do you have any ETA for 3.4.2 (and 4.0)?

No. But 3.4.1 was released 26 days ago, so it is probable that 3.4.2 will be released relatively soon. Official release of OH 4.0 is certainly not for tomorrow. But I assume a first milestone could arrive in the coming weeks.

Come back to @dan-m-joha 's problem:

2023-01-29 21:23:14.809 [TRACE] [ng.hue.internal.connection.HueBridge] - Hue request: GET - URL = 'http://192.168.xx.yy:80/api/xxxxxxxxxx/sensors'
2023-01-29 21:23:14.814 [TRACE] [ng.hue.internal.connection.HueBridge] - Hue response: status = 200, content = ''
2023-01-29 21:23:14.815 [WARN ] [ue.internal.handler.HueBridgeHandler] - An unexpected error occurred: null
java.lang.NullPointerException: null
        at org.openhab.binding.hue.internal.connection.HueBridge.getSensors(HueBridge.java:280) ~[bundleFile:?]

@jlaur: the request returns status 200 but an empty content ! In that case, sensorMap is then null. We should handle that case. The fix will be easy.

Edit: and we should check if we do not have the same potential error for lights. Edit2: or change safeFromJson to handle an empty json and throw an exception ? Edit3: safeFromJson could create the object and return it (when the json is empty).