|
|
Re: Thing Status Listeners [message #1719486 is a reply to message #1719295] |
Fri, 08 January 2016 10:41 |
|
I don't know our implementation, but why do you rate it "very clumsy"?
Each thing is propagating status changes on the event bus on the topic "smarthome/things/{thingUID}/statuschanged". You can just subscribe to this event.
Within the framework you could use the ThingHandlerCallback#statusUpdated method to be informed about any status update.
|
|
|
|
|
Re: Thing Status Listeners [message #1719675 is a reply to message #1719546] |
Mon, 11 January 2016 10:47 |
|
Please have a look into the documentation about events: https://www.eclipse.org/smarthome/documentation/concepts/events.html. Here the status events are mentioned as well and the difference between status and statusChanged events. You do NOT need to listen to OSGi events using declarative services!
If you want to get hold of the thing handler of your bridge, you might want to implement a method like get in the Hue-Binding: HueLightHandler#getHueBridgeHandler. But you cannot access the bridge handler's ThingHandlerCallback so this won't help you for getting information of status changes of the bridge.
|
|
|
|
|
|
|
Re: Thing Status Listeners [message #1719798 is a reply to message #1719738] |
Tue, 12 January 2016 07:27 |
|
Dan Cunningham wrote on Mon, 11 January 2016 19:06
At the bottom of that page its states
Each event subscriber must be registered via OSGi Declarative Services (DS) under the org.eclipse.smarthome.event.EventSubscriber interface.
Is this not the case then, or am I confusing something?
Dan, you are completely right and I was wrong.
But I agree with Kai that as long as you are inside the binding you should not rely on events but use the binding API. However, AFAIK there is no easy way to get informed about status updates from your bridge, although you are able to get hold of your bridge handler easily as I explained earlier.
|
|
|
Re: Thing Status Listeners [message #1719803 is a reply to message #1719798] |
Tue, 12 January 2016 08:13 |
|
The framework ensures, that in case the Bridge goes OFFLINE, the children are going OFFLINE as well, with status detail "Bridge offline". If the Bridge is going online again, the children remain OFFLINE, but the status detail "Bridge offline" is removed. The framework cannot distinguish between children being OFFLINE, because of the bridge was OFFLINE or children being OFFLINE for somer other reason. Therefore you must handle the ONLINE case yourself as for instance the Hue binding does. The BaseThingHandler provides a method bridgeHandlerInitialized that you can override (the above mentioned PR moves this method into the ThingHandler interface) to handle your children accordingly in case the bridge goes ONLINE.
|
|
|
|
|
|
|
Re: Thing Status Listeners [message #1720197 is a reply to message #1720124] |
Fri, 15 January 2016 07:55 |
|
Stefan Bussweiler wrote on Thu, 14 January 2016 16:03
With other words: ThingHandler.bridgeHandlerInitialized() will be called if the status of the Bridge has been set to ONLINE resp. OFFLINE.
I don't think, it is called on each status change from ONLINE to OFFLINE. At least I did not see this in the code.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04995 seconds