-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Minor extension to generic ip discovery #3943
Conversation
@Skinah FYI |
03ef355
to
2c0b1bc
Compare
...scovery.addon.ip/src/main/java/org/openhab/core/config/discovery/addon/ip/IpAddonFinder.java
Outdated
Show resolved
Hide resolved
Thank you for the changes. |
@holgerfriedrich the ZWay binding is probably a candidate to be suggested via your IP addon finder. => WDYT? |
bcf3a4c
to
0034e54
Compare
Sorry, @andrewfg, I got you wrong in my first reply. Let's discuss this #3936. I will copy your comment to the other issue. |
@mherwege I think this PR is ready for review. It contains extensions needed for govee and ipcamera bindings. @stefan-hoehn just confirmed it working for govee and approved my PR openhab/openhab-addons#16109. |
Just for the avoidance of doubt:
|
adb6678
to
1ec1821
Compare
@mherwege Could you please take a look at this? |
4079156
to
1df3889
Compare
@openhab/core-maintainers could you pls have a look? Auto-detect for 2 add-ons is depending on additional functions introduced in this PR:
Thanks a lot! |
In principle, this LGTM. But I am wondering if we should not introduce use of #3981 at the same time. As we add requests being sent out to all interfaces, we should probably restrict the interfaces before getting too much into trouble. |
@mherwege thanks for looking into this.
I had implemented a fallback to the main interface in case too many interfaces were found, but removed it for now to keep the PR cleaner. What we will need to think about - but for me it is not yet scope of this PR - is either shortening the timeouts or doing requests more or less in parallel. Otherwise we will not finish the scan before the wizard suggests plugins during when OH is installed. |
Agree to keep it out of here, but that’s where it should probably be in sync with the work on #3981, so for a follow-up PR.
Maybe define CompletableFutures with timeout for each request and start them in parallel. Agree we will need more throughput on this. We can delay initial configuration in the UI a bit, showing a preparing screen, within reason. |
I would suggest to use CompletableFuture as @mherwege suggests. Then the scans can all be executed in parallel on separate threads. |
I tend to agree here. It now becomes easy to add discovery info to add-ons. If a number of them are added in the addon repo, suddenly we have code running a sequence of scans potentially each timing out. We should avoid having to come back to this quickly when discovery info gets added to the addon.xml files. |
In particular in OH core, there should be no long running processes on main threads. |
I am thinking that the approach below would perhaps be appropriate.. |
I think there even is a bigger theme for OH and networking to look at. I created an issue for it, but have had little response so far: #4047 |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/oh-4-1-1-startup-takes-more-than-an-hour/153310/33 |
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.
@holgerfriedrich apropos threading .. to be a bit more helpful I would suggest refactoring your code lines 265..395 into a separate method, and at line #264 call that method via something like List<Future> myFutures .. add(scheduler.submit(() -> thatMethod()))
.
And on shutdown you should also do myFutures.forEach(f -> cancel())
;
...scovery.addon.ip/src/main/java/org/openhab/core/config/discovery/addon/ip/IpAddonFinder.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
1df3889
to
573ce30
Compare
I agree that better handling of multiple addresses and interfaces is desired for IP discovery. Which solution to implement is not yet clear, maybe there will be a result out of #4047. Parallelization is required as well when more add-ons start using this. Thanks, @mherwege and @andrewfg for pointing at I still think that both is out of scope of this PR and tracked #3936. The PR adds new config options and has already been validated with the corresponding add-on. |
@holgerfriedrich HERE is some code to do the scans asynchronously (not tested). |
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.
Thanks for the extension!
@holgerfriedrich shall I convert my code to a new PR? |
Thanks, @andrewfg. I have created #4094 based on your example above. Hope you are fine with that. |
Add new replacement $uuid in request frame.
This is needed for discovery of ipcamera devices.
Add new parameter listenPort (required for govee).
Add new parameter requestPlain as alternative to request (enhance readability of request for text/xml/json based req., govee and ipcamera)
Improve resource handling:
restrict to 5 addresses(moved to next PR)respect system.config.network.useOnlyOneAddress setting(moved to next PR)Refs: #3936