Channels not yet linked when initialize() method of handler is called? [message #1736972] |
Mon, 04 July 2016 18:11 |
Dominic Lerbs Messages: 15 Registered: June 2015 |
Junior Member |
|
|
Hi,
I am currently implementing a binding and having the following issue:
When the initialize() Method of my handler is called, I already know the state of my thing, so I try to update the channels accordingly, basically something like this (just an abbreviated so you get the idea):
@Override
public void initialize() {
updateState(MUTE, mute);
updateState(VOLUME, volume);
...
updateStatus(ThingStatus.ONLINE);
}
Now if the thing already existed, eveything works fine. But if the initialize() method is called because I added a new thing (e.g. through PaperUI Inbox), it seems like some of the channels are not yet linked when the initialize() method is called, and therefore the updateState calls have no effect.
In the log, it basically seems to happen in parallel:
2016-07-04 18:38:46.719 [INFO ] [smarthome.event.ItemAddedEvent:43 ] - Item 'allplay_speaker_c28336b4_38a5_4849_8ec7_7cfcc990a705_currentgenre' has been added.
2016-07-04 18:38:46.731 [INFO ] [vent.ItemChannelLinkAddedEvent:43 ] - Link 'allplay_speaker_c28336b4_38a5_4849_8ec7_7cfcc990a705_currentgenre-allplay:speaker:c28336b4-38a5-4849-8ec7-7cfcc990a705:currentgenre' has been added.
2016-07-04 18:38:46.820 [INFO ] [allplay.handler.AllPlayHandler:233 ] - Panasonic ALL8 Volume changed to 18
2016-07-04 18:38:46.821 [INFO ] [ome.event.ThingStatusInfoEvent:43 ] - 'allplay:speaker:c28336b4-38a5-4849-8ec7-7cfcc990a705' updated: ONLINE
2016-07-04 18:38:46.823 [INFO ] [nt.ThingStatusInfoChangedEvent:43 ] - 'allplay:speaker:c28336b4-38a5-4849-8ec7-7cfcc990a705' changed from INITIALIZING to ONLINE
2016-07-04 18:38:46.879 [INFO ] [smarthome.event.ItemAddedEvent:43 ] - Item 'allplay_speaker_c28336b4_38a5_4849_8ec7_7cfcc990a705_volume' has been added.
2016-07-04 18:38:46.884 [INFO ] [vent.ItemChannelLinkAddedEvent:43 ] - Link 'allplay_speaker_c28336b4_38a5_4849_8ec7_7cfcc990a705_volume-allplay:speaker:c28336b4-38a5-4849-8ec7-7cfcc990a705:volume' has been added.
So I was wondering, if I really have no guarantee that all channels have been linked when the initialize() method is called, and if there is some other way I should update the state of the thing?
I saw that some bindings have a timer where they request and update the state every 30 seconds or so, but this is not necessary for the binding I am developing as the binding will be informed in case of changes. So I would only need to get the state once at the beginning and then would listen for changes.
Any hints are appreciated.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03271 seconds