Philips Hue: Online/offline detection unreliable?

I am using OH2.4.0 on the latest openhabian version.

I have a HabPanel installation that should show me which lights are on/off/offline. To detect if lights are on or off is easy, but to detect if lights are online or offline is slightly more challenging. I do this by having a script for each light. The script looks as follows. It is executed when the Thing of the light changes, Openhab restarts or the Bridge has reconnected after being offline. It then assigns the online/offline value to an empty Item which is then used by HABPanel.

rule “HueOnlineSwitcher_kfr”
Thing “hue:0100:1:kfr” changed or
System started or
Thing “hue:bridge:1” changed to ONLINE
var thingStatusInfo = getThingStatusInfo(“hue:0100:1:kfr”)
postUpdate(hueKuechenfRechts_Online, thingStatusInfo.getStatus().toString())

My problem is that in my installation it works unreliably. I guess in 20% of all cases, the hue binding shows a light as online while it is offline. The JSON output of the bridge shows these lights as offline, so it must be the binding not recognizing whether the light is online or offline.
Any idea what reason this might have? It would also help to know whether you have a similar setup working reliably, so I would know the installation should work for me too.

I am having the problem that my hue bridge thing keeps toggling between online and offline.
(has been happening on OH 2.4 but earlier versions as well).
Querying devices through the bridge would probably also lead to unreliable responses like in your case.
Sorry I don’t have a solution but you might want to ramp up your debug level to see if the same happens on your system so at least you wouldn’t be looking for the cause in the wrong place.

Thank you for your suggestion, @mstormi. However, my problem appears only on lights that I switch off manually (means they become offline and online). Should my problem be related to the connection with the bridge, all lights would have this problem.
However I had the same problem as you some time ago, and at the end it was a network issue (the bridge was connected to a wifi repeater which was instable). You could exclude this reason by using the network binding with this thing:

network:pingdevice:huebridge “Ping: Hue-Bridge” [ hostname=“Philips-hue.local” ]

With this item:

Switch Network_Hue { channel=“network:pingdevice:huebridge:online” }

and an appropriate persistence of Network_Hue you could exclude that it is a network issue between your Openhab server and the Hue bridge.
This same method tells me that the connection to the bridge is relatively stable (drops about once a day).