-
-
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] Initial contribution - Bindings for Bosch Smart Home devices #8629
Conversation
Travis tests were successfulHey @coeing, |
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 wasn't able to review the entire thing, but I found a few issues to get you started.
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/BoschSHCHandlerFactory.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Show resolved
Hide resolved
...oschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java
Outdated
Show resolved
Hide resolved
...chshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/JsonRpcRequest.java
Outdated
Show resolved
Hide resolved
Thanks @cpmeister for your review! I will try to fix the issues you found this week :) |
a251db1
to
83a86f5
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.
Second review pass
...ng.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/BoschSHCHandler.java
Outdated
Show resolved
Hide resolved
...chshc/src/main/java/org/openhab/binding/boschshc/internal/devices/BoschSHCConfiguration.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...oschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java
Outdated
Show resolved
Hide resolved
...oschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java
Outdated
Show resolved
Hide resolved
....boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/dto/Device.java
Outdated
Show resolved
Hide resolved
...ava/org/openhab/binding/boschshc/internal/devices/inwallswitch/BoschInWallSwitchHandler.java
Outdated
Show resolved
Hide resolved
...ava/org/openhab/binding/boschshc/internal/devices/inwallswitch/BoschInWallSwitchHandler.java
Outdated
Show resolved
Hide resolved
...java/org/openhab/binding/boschshc/internal/devices/shuttercontrol/ShutterControlHandler.java
Outdated
Show resolved
Hide resolved
...ng.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/BoschSHCHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPolling.java
Outdated
Show resolved
Hide resolved
...main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.boschshc/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.boschshc/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
...boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPolling.java
Outdated
Show resolved
Hide resolved
updateState(CHANNEL_TEMPERATURE, new DecimalType(state.temperature)); | ||
updateState(CHANNEL_TEMPERATURE_RATING, new StringType(state.temperatureRating)); | ||
updateState(CHANNEL_HUMIDITY, new DecimalType(state.humidity)); | ||
updateState(CHANNEL_HUMIDITY_RATING, new StringType(state.humidityRating)); | ||
updateState(CHANNEL_PURITY, new DecimalType(state.purity)); |
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.
Temperature, humidity, and purity should be QuantityType instead of DecimalType.
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.
Changed it :) Hope the QuantityType<Dimensionless>
is okay for humidity and purity as the channels are of type Number:Dimensionless?
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.
@cpmeister Are the current types okay?
Oh, also your build is failing. |
242909b
to
01a607a
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.
This is pretty good code, you made a really good job!
I receive compiler errors. E.g.
BoschSHCBridgeHandler.java:[355,19] Null type mismatch (type annotations): required 'T extends org.openhab.binding.boschshc.internal.services.dto.@NonNull BoschSHCServiceState' but this expression has type '@Nullable T extends org.openhab.binding.boschshc.internal.services.dto.@NonNull BoschSHCServiceState'
...oschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java
Outdated
Show resolved
Hide resolved
...boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPolling.java
Outdated
Show resolved
Hide resolved
...main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.boschshc/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
bundles/org.openhab.binding.boschshc/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
...oschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.boschshc/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/BoschSHCHandlerFactory.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.
I think these are the last changes I'll request, other than these it looks good to me.
...ava/org/openhab/binding/boschshc/internal/devices/inwallswitch/BoschInWallSwitchHandler.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSHCBridgeHandler.java
Outdated
Show resolved
Hide resolved
|
Found this issue while you wrote your comment :) Changed it in my last commit. |
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.
Almost done from me I think.
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java
Outdated
Show resolved
Hide resolved
...main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java
Outdated
Show resolved
Hide resolved
...hshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClient.java
Outdated
Show resolved
Hide resolved
...boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPolling.java
Outdated
Show resolved
Hide resolved
...boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPolling.java
Outdated
Show resolved
Hide resolved
1b7cc8e
to
0664874
Compare
added back the removed @nullable annotation in sendRequest() replaced deprecated SslContextFactory constructor call Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
<dependencies> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcpkix-jdk15on</artifactId> | ||
<version>1.54</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcprov-jdk15on</artifactId> | ||
<version>1.54</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> |
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.
Is there a documentation which information of the dependencies should go into the NOTICE file?
Not that I'm aware of, but you can look at other bindings as an example.
There is no documentation on format of additional licenses in NOTICE. It's something like this:
One other thing. It looks like the library |
@GerdZanker Could you try this out? Would be nice to have no additional dependency for our binding :) I am currently working on the Long Polling cancelation after 24 hours (stefan-kaestle#62) |
Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
…g.openhab.core.io.jetty.certificate to later reduce download size Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
I'm on the way. The NOTICE is updated and I downgraded the Bouncy Castle version to 1.52 and certificate can still be created. |
The version number 1.52 now matches to the version used in
Can you @Hilbrand support us, because I'm not a maven expert and know how to solve this? It would be great if you can suggest necessary pom.xml changes to fix this, because I have now idea what the problem is. |
GSON will not return null if there is no "result" field, but will just set the "result" member to null. Signed-off-by: Christian Oeing <christian.oeing@slashgames.org>
…method name Signed-off-by: Christian Oeing <christian.oeing@slashgames.org>
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.boschshc/${project.version}</bundle> |
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.
After switch the dependencies to provided
you would then need to update your feature.xml
to let the osgi system know where it can find those dependencies. This should solve the error your are seeing in the build.
<feature>openhab-runtime-base</feature> | |
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.boschshc/${project.version}</bundle> | |
<feature>openhab-runtime-base</feature> | |
<bundle dependency="true">mvn:org.bouncycastle/bcpkix-jdk15on/1.52</bundle> | |
<bundle dependency="true">mvn:org.bouncycastle/bcprov-jdk15on/1.52</bundle> | |
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.boschshc/${project.version}</bundle> |
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 a lot @cpmeister! Your suggestion solves the error on my machine.
This means that the maven pom.xml
contains the "compile time" dependencies and the feature.xml
defines the runtime OSGi environment.
I will tests the new binding jar - now only 88Kb big - and commit the changes afterwards.
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.
88kb?! 🎆
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.
Oh no 😧. During runtime I get now problems: Not all used class from org.bouncycastle.*
are contained in org.openhab.io.jetty.certificate
and this binding code uses of cause missing classes.
I will evaluate the following option:
a) rewrite the binding certificate code to only use available classes
b) use the maven-shade-plugin as in the org.openhab.io.jetty.certificate
bundle pom.xml
to reduce the jar size
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.
From what I can tell, org.openhab.io.jetty.certificate
doesn't export any of the org.bouncycastle.*
classes that it has shaded internally. This means that you can't rely on org.openhab.io.jetty.certificate
as a dependency to get those classes from.
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.
Are you having any trouble getting the binding to install? Or does it install and just throw errors?
The trouble started after a successful compilation and bundle installation. It seems to me that all dependencies inside the OSGi container were resolved, because I was able to start the Bosch SHC Bridge Thing. But during the very first initialization I got exceptions during the keystore and the self signed certificate creation.
I will write unit tests to have a defined environment and reproduce steps for keystore and self signed certificate creation. Then I can evaluate different dependencies and code combinations.
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.
FYI: A first "copy & paste" of the maven-shade-plugin settings from the org.openhab.io.jetty.certificate
pom.xml to this binding pom resulted in the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default) on project org.openhab.binding.boschshc: Error creating shaded jar: Invalid signature file digest for Manifest main attributes -> [Help 1]
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.
Since you are going to shade the bouncycastle libraries into you binding anyway, the easiest way to do that would be to give those dependencies a compile
scope in your pom file. Doing so would automatically get those dependencies shaded into your final binding jar. You also wouldn't need to list the dependencies in your feature.xml file either in that case.
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.
The current PR content has the compile
scope for the bouncycastle dependencies and the shading results in a 3.4MB big jar which is working.
It was requested to reduce the jar size and up to now I found no feasible way, because
a) the org.openhab.io.jetty.certificate
jar doesn't provide necessary classes currently used in the BoschSslUtil
class during runtime
b) I have no working maven pom to shade and reduce the jar size during compile time
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.
When @Hilbrand made his suggestion I don't think he was aware that the org.openhab.io.jetty.certificate
doesn't export the bouncycastle packages. So depending on the core to provide those dependencies isn't an option at the moment. For now I suggest leaving the dependencies embedded for now and once the core exposes the bouncycastle packages we can try to readdress the sizing issue.
Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
The changeable SHC system password for the keystore is replaced by a static string in the code. The keyStore name is now based on SHC ipAddress to support multiple SmartHomeControllers. 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.
The code looks good to me right now. Is there anything else you want to add before this gets merged? I'd suggest leaving new features for later PRs.
Hello @coeing, I know you currently in progress with this issue. I'm done: The JAR size is OK and the initial setup is improved, because an internal password is used for the keystore. |
@cpmeister @GerdZanker I am fine with the current state of the binding. As Gerd mentioned, our binding disconnects after 24 hours (stefan-kaestle#62), but I need some time to investigate the issue as it is not easy to reproduce (having to wait 24 hours each time...). Having some more people test the binding will help with finding the issue. So from my side: Ready to merge! 👍 |
…es (openhab#8629) * Initial code from create_openhab_binding_skeleton.sh Co-authored-by: Stefan Kaestle <stefan@mad-kow.de> Co-authored-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Christian Oeing <christian.oeing@scalamat.de> Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl> Co-authored-by: Fabian Wolter <github@fabian-wolter.de> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
…es (openhab#8629) * Initial code from create_openhab_binding_skeleton.sh Signed-off-by: Stefan Kaestle <stefan@mad-kow.de> Signed-off-by: Christian Oeing <christian.oeing@slashgames.org> Signed-off-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Stefan Kaestle <stefan@mad-kow.de> Co-authored-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Christian Oeing <christian.oeing@scalamat.de> Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl> Co-authored-by: Fabian Wolter <github@fabian-wolter.de> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com> Signed-off-by: John Marshall <john.marshall.au@gmail.com>
…es (openhab#8629) * Initial code from create_openhab_binding_skeleton.sh Signed-off-by: Stefan Kaestle <stefan@mad-kow.de> Signed-off-by: Christian Oeing <christian.oeing@slashgames.org> Signed-off-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Stefan Kaestle <stefan@mad-kow.de> Co-authored-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Christian Oeing <christian.oeing@scalamat.de> Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl> Co-authored-by: Fabian Wolter <github@fabian-wolter.de> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
…es (openhab#8629) * Initial code from create_openhab_binding_skeleton.sh Signed-off-by: Stefan Kaestle <stefan@mad-kow.de> Signed-off-by: Christian Oeing <christian.oeing@slashgames.org> Signed-off-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Stefan Kaestle <stefan@mad-kow.de> Co-authored-by: Gerd Zanker <gerd.zanker@web.de> Co-authored-by: Christian Oeing <christian.oeing@scalamat.de> Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl> Co-authored-by: Fabian Wolter <github@fabian-wolter.de> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
Hi there,
@stefan-kaestle started a fork of your repository in November 2019 to implement the bindings for Bosch Smart Home devices which are pretty popular in Germany. @GerdZanker and I joined earlier this year.
Together we managed to built a good base for a first release, which already has the base structure to setup and communicate with the Bosch Smart Home controller and supports a lot of devices:
Before we continue our development we'd like to do a first public release to gather user feedback and your feedback as openHAB maintainers :)
We already found some fellow openHAB users who tested pre-release versions and apart from some minor issues which we fixed, they were already quite content with the result (and had some ideas for enhancements for the next version of course :) ).
We tried to get some upfront feedback about our code base from one of your maintainers, but got no answer, so we thought we just create a pull request to discuss any further issues here: https://community.openhab.org/t/towards-merging-the-new-bosch-shc-binding/101952
You can find the fork here: https://github.com/stefan-kaestle/openhab2-addons We already tried to sign-off each commit and follow your coding guidelines (https://www.openhab.org/docs/developer/development/guidelines.html), but might have missed some points as it is our first contribution to your project.
We have a thread in the community forum: https://community.openhab.org/t/will-there-be-a-bosch-smart-home-binding
The last pre-release is up-to-date apart from some file moving: https://github.com/stefan-kaestle/openhab2-addons/releases/tag/v1.0-beta.1
Feel free to ask any questions and let us know what work needs to be done before our work can be merged. Thanks for your help and for your great open-source Smart Home platform!
This pull request continues the first merge of our binding from the previous pull request #8371 Due to openHAB 3 we rebased our binding on the new code base.