Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Channels not yet linked when initialize() method of handler is called?
Channels not yet linked when initialize() method of handler is called? [message #1736972] Mon, 04 July 2016 18:11 Go to next message
Dominic Lerbs is currently offline Dominic LerbsFriend
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.

Re: Channels not yet linked when initialize() method of handler is called? [message #1736987 is a reply to message #1736972] Mon, 04 July 2016 19:14 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

I think you need to implement the handling of the REFRESH command.
See
issue: https://github.com/eclipse/smarthome/issues/1658
PR: https://github.com/eclipse/smarthome/pull/1677
Re: Channels not yet linked when initialize() method of handler is called? [message #1737112 is a reply to message #1736987] Tue, 05 July 2016 19:45 Go to previous messageGo to next message
Dominic Lerbs is currently offline Dominic LerbsFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks, looks promising. I'll try to implement it this way.
Re: Channels not yet linked when initialize() method of handler is called? [message #1737113 is a reply to message #1737112] Tue, 05 July 2016 20:05 Go to previous message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

What you need to do (in your binding) is to implement the handling of RefreshType.REFRESH in the handleCommand method (update the status of the channel).

Only if you overwrite the method channelLinked in your thing handler you need to add the same call to your method.
Previous Topic:Non existing item for dynamic channel
Next Topic:Setup ESH development environment failed
Goto Forum:
  


Current Time: Thu Apr 25 12:48:57 GMT 2024

Powered by FUDForum. Page generated in 0.03271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top