-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix item channel links not properly initialized #1634
Conversation
Code Looks great. Thanks to both of you. To avoid future regressions do you think it is possible to add an integration test - in a simple way - for this feature? |
I haven't added any tests because I first wanted to know from the other @openhab/core-maintainers if we still think this is the way to go (and it was getting late 😉). |
As I said, I like it and I agree on it 😉. |
And I already stated in #1385 (comment) that I like it 😎 . |
There may be issues with this implementation when you link multiple items to one thing channel. If you remove one of the links it will send a "channelUnlinked" event to the handler. Which may use the event to stop a channel update mechanism (polling). I think the handler should only be informed of these changes if:
It looks like this may already have been an issue with the old implementation. Similarly it will call "channelLinked" multiple times when the Another improvement may be to use a scheduler for these events to reduce the impact of thing handlers hijacking threads for long running tasks. It was also used in the old implementation. |
Looking at issue and how it looks a like I believe that we should rather focus on keeping link identifier as part of notification. If we have channel linked which is related to link which have been just created or removed the divider is link and not channel. There might be cases when binding wants to keep distinct subscriptions for each and every link due to let say latency or better concurrency. Letting binding developer decide how to handle above scenario is better than building an extra logic in framework notifier itself. Best, |
28f2e42
to
3a315dd
Compare
I've now added some pretty decent integration test coverage as well. @splatch adding such details would be breaking API changes and I was under the impression the details of links and items were hidden from handlers on purpose. But perhaps the other @openhab/core-maintainers can also comment on that. |
@wborn Given that this is one of less popular framework features coming next major release is great opportunity to introduce breaking change. If a whole intention is to keep handler unaware of items and links then idea of having link notifications in handler was wrong in first place. |
Yes, I fully agree.
Correct. The purpose of these methods was only for the handler to know, whether a certain channel is at all in use as it might otherwise skip expensive internal operations or unnecessary communication. |
After some more thoughts I think it might still be necessary to send "channelLinked" events for already linked channels. That may be the only way for newly linked items to receive the current channel state. |
6d0f49e
to
3c002e3
Compare
Fixes openhab#1596 Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
* Send at most one channelLinked event per linked thing channel when activating ChannelLinkNotifier * Send channelUnlinked event only if all items are unlinked Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
86b8c47
to
add33ad
Compare
The Insteon binding relies on |
With these changes and working channelLink events (openhab/openhab-core#1634) the feed itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
With these changes and working channelLink events (openhab/openhab-core#1634) the feed itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
With these changes and working channelLink events (openhab/openhab-core#1634) the ntp itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, many thanks!
With these changes and working channelLink events (openhab/openhab-core#1634) the feed itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
With these changes and working channelLink events (openhab/openhab-core#1634) the ntp itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
With these changes and working channelLink events (openhab/openhab-core#1634) the feed itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
With these changes and working channelLink events (openhab/openhab-core#1634) the ntp itest works again. Signed-off-by: Wouter Born <github@maindrain.net>
* Fix item channel links not properly initialized * Add ChannelLinkNotifierOSGiTest * Send at most one channelLinked event per linked thing channel when activating ChannelLinkNotifier * Send channelUnlinked event only if all items are unlinked * Use Registry stream instead of getAll Fixes openhab#1596 Signed-off-by: Wouter Born <github@maindrain.net> GitOrigin-RevId: 2dd1a03
I've tested the
ChannelLinkNotifier
by @splatch (#1385 (comment)) and it solves the channel linking issues for me.I made a few small changes:
@NonNullByDefault
@Deactivate
With the channels being properly linked, adding Things via the inbox and adding them to the model works a lot better. :-)
Fixes #1596