-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[boschshc] Add bridge and device discovery #14197
[boschshc] Add bridge and device discovery #14197
Conversation
914b314
to
e30b864
Compare
Hello @david-pace, can you already take a look at the code and how I now write the test? |
I'll look at it as soon as I find some time, probably at the weekend. |
...rc/main/java/org/openhab/binding/boschshc/internal/discovery/BridgeDiscoveryParticipant.java
Outdated
Show resolved
Hide resolved
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
new AbstractMap.SimpleEntry<>("BBL", BoschSHCBindingConstants.THING_TYPE_SHUTTER_CONTROL.getId()), // Rollladenschalter | ||
new AbstractMap.SimpleEntry<>("TWINGUARD", BoschSHCBindingConstants.THING_TYPE_TWINGUARD.getId()), // Twinguard | ||
new AbstractMap.SimpleEntry<>("PSM", BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH.getId()), // Steckdosen Zwischenstecker | ||
new AbstractMap.SimpleEntry<>("PLUG_COMPACT", BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH.getId()) // Steckdosen Zwischenstecker kompakt |
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.
we now have a dedicated thing type for the plugs (not in-wall switch)
...src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java
Outdated
Show resolved
Hide resolved
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
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.
added some comments about things I saw at first glance
Thanks a lot. I will improve your findings together with the updated list/map of devices. |
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Show resolved
Hide resolved
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Show resolved
Hide resolved
...src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java
Show resolved
Hide resolved
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.
I found a typo in the key for the 360 camera and I also have some general questions about the keys.
Fixed the typo, improved the tests code and tried to clarify the questions. Soon I will squash and cleanup the commits and provide a bundle Jar for testing with last stable version 3.4.2 |
4cca586
to
5d181ec
Compare
Test failing, because of updated code. Branch will be rebased and fixed soon. |
5d181ec
to
ea1fdb2
Compare
...schshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandler.java
Show resolved
Hide resolved
...schshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandler.java
Show resolved
Hide resolved
...schshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandler.java
Outdated
Show resolved
Hide resolved
...schshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandler.java
Outdated
Show resolved
Hide resolved
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.
See comments, plus some checkstyle warnings have been introduced that should be fixed if possible. See file target/code-analysis/report.html
. On the main
branch I currently see 3 warnings related to catching NullPointerExceptions, on your branch I see 19 additional minor things that could be mitigated easily (like unnecessary empty lines etc.)
ea1fdb2
to
9354467
Compare
All comments should be improved, please check how I handled the InterruptException.
I did my best to get rid of all findings |
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.
...rc/main/java/org/openhab/binding/boschshc/internal/discovery/BridgeDiscoveryParticipant.java
Outdated
Show resolved
Hide resolved
9354467
to
dedff34
Compare
Thanks for your testfeedback
It took some time to find a solution for nice names, but now this enhancement is part of this PR. |
// convert "IntrusionDetectionSystem" into "Intrusion Detection System" | ||
String[] allParts = StringUtils.splitByCharacterTypeCamelCase(niceName); | ||
String[] parts = Arrays.stream(allParts).filter(p -> !p.trim().isEmpty()).collect(Collectors.toList()) | ||
.toArray(new String[0]); |
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.
Array conversion is not needed. You could use String.join()
providing a list of strings. But there is an even better way: use Collectors.joining(" ")
instead of Collectors.toList()
and you're done directly 👍
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.
Awesome, this looks great! Thanks for improving the labels, I see that this was not trivial ;) I tested again with the actual hardware and it looks good 👍
I just have a minor suggestion which could save one line of code, but this is optional. Good work 😎
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! In addition to the review of @david-pace (👍) only a single comment from my side.
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
dedff34
to
f0c003e
Compare
f0c003e
to
da883d9
Compare
Out of topic, but @jlaur, do you know how I can provide a nice binding icon for boschshc? I wasn't able to find a documentation or used the wrong words. |
Yes, see here: https://www.openhab.org/docs/developer/bindings/#add-your-binding-s-logo-to-the-openhab-website |
2023-03-20 20:30:48.026 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'boschshc:security-camera-eyes:yourBrideName:hdm_Cameras_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' to inbox. | ||
2023-03-20 20:30:48.026 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'boschshc:smoke-detector:yourBrideName:hdm_HomeMaticIP_XXXXXXXXXXXXXXXXXXXXXXXX' to inbox. | ||
2023-03-20 20:30:48.027 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'boschshc:twinguard:yourBrideName:hdm_ZigBee_XXXXXXXXXXXXXXXX' to inbox. | ||
2023-03-20 20:30:48.028 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'boschshc:smart-bulb:yourBrideName:hdm_PhilipsHueBridge_HueLight_XXXXXXXXXXXXXXXX-XX_XXXXXXXXXXXX' to inbox. |
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.
yourBrideName intended? 👰
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.
Arg - last minute changes 🤦♂️
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.
Out of topic, but @jlaur, do you know how I can provide a nice binding icon for boschshc? I wasn't able to find a documentation or used the wrong words.
Yes, see here: https://www.openhab.org/docs/developer/bindings/#add-your-binding-s-logo-to-the-openhab-website
Thanks a lot for the link to this obvious location.
I wasn't able to get information when I searched for hints the last time, but its already some months ago - hopefully this answer was added just recently 🤔
Bridge discovery is implemented via mDNS, local IP addresses are checked. If a GET returns the public SHC information, then this shcIpAddress is reported as a discovered bridge. Devices are always discovered after successful pairing, but a manual scan is also possible. Added unit tests for Bridge and Device Discovery. Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
Three AvoidCatchingNPE findings are pending in the class BoschHttpClient. Could be false positive, because NullPointer exceptions appear during tests run. Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
da883d9
to
1205492
Compare
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.
Last minute finding, sorry.
...shc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
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
* openhab#14195 Bridge and Device Discovery Bridge discovery is implemented via mDNS, local IP addresses are checked. If a GET returns the public SHC information, then this shcIpAddress is reported as a discovered bridge. Devices are always discovered after successful pairing, but a manual scan is also possible. Added unit tests for Bridge and Device Discovery. Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
#14195 [boschshc] Bridge discovery is implemented via mDNS, local IP addresses are checked. If a GET returns the public SHC information,
then this shcIpAddress is reported as a discovered bridge.
Devices are always discovered after successful pairing, but a manual scan is also possible.