Will there be a "Bosch Smart Home" binding?

Sorry I did not see that you are already working on a binding. For the iobroker Adapter I created a library to make the integration easier. I did the same for java.

Sorry if I knew this earlier I could have added you as contributer. Just let me know if it is already too late or if you are still interested. At least the information may help?

3 Likes

@skaestle I’m very interested. Please let me know if you need somebody to test things :wink: I have some inwall-rollershutters installed.

Thank you @skaestle for your shared Bosch SHC code. The hardest part for me was to setup the correct keystore content, but after this your add-on works well and I now make use of my Bosch SmartHomeController.

2 Likes

Oh wow!

Setup of the keystore is very much incomplete in the addon. I wanted to add code that does this automatically from Java, but couldn’t get it to work so far (because of weird packaging issues with mvn)

Could you describe how you set it up? Did you do it from the command line using the keytool?

Cheers,
Stefan

Steps to register a new client and create the JKS keystore to use it in Bosch SHC add-on:

  • Follow the steps in the BoschSmatHome Github repository to “Register a New Client to the Bosch Smart Home Controller”
  • use the Java “keytool” or a UI tool like “KeyStoreExplorer” to create a JKS keystore and import the following three keystore entries. Ensure that your key AND the keystore are both using the same password.
    • your created key and cert from the first step
    • the Smart Home Controller Productive Root CA
    • the Smart Home Controller Issuing CA

The two Smart Home Controller CA certs are provided in the Github repo See Host Verification for more details.

4 Likes

Cool, that’s a really nice explanation of the process, better than the one I was using myself :slight_smile:

In the long run, of course, it would be nice to have the addon to these steps automatically. The issue I had was that one of the Java dependencies needed (bouncycastle) didn’t play well with the Maven setup that OpenHab is using. It’s likely that I might have done something wrong, since I don’t know Maven very well.

I asked a while ago here on the forums, but nobody seemed to be able to help with this.

Perhaps one way forward is to write a small program to generate the key and register it with the SHC to test if that even works before trying to integrate it in OpenHab …

Thanks @GerdZanker for the step-by-step instructions :slight_smile:

I created a small shell script to generate the keystore from the certificates and the private key. Hope it saves some other devs some time:

#!/bin/bash

keystoreName=openHAB.jks

read -p "Please enter a password for the new keystore: " keystorePassword

echo "-----------------------"

# Combine client certificate and private key into PKCS 12 keystore
openssl pkcs12 -export -in "./client-cert.pem" -inkey "./client-key.pem" -name shc_client -out $keystoreName -passout pass:$keystorePassword

echo "Created keystore $keystoreName from client certificate and private key"

echo "-----------------------"

# Import Smart Home certificates
keytool -keystore $keystoreName -storepass $keystorePassword -noprompt -import -alias shc_issuing_ca -file "./Smart Home Controller Issuing CA.pem"
keytool -keystore $keystoreName -storepass $keystorePassword -noprompt -import -alias shc_productive_root_ca -file "./Smart Home Controller Productive Root CA.pem"

echo "-----------------------"

# List certificates
keytool -keystore $keystoreName -storepass $keystorePassword -list

echo "-----------------------"

read -p "Press Enter to exit"
3 Likes

And of course thanks @skaestle for starting with the binding. I just checked out everything and try to get it to run.

A bit of background about me: I’m a software developer and recent owner of some Bosch Smart Home devices (3 shutter controls and 2 thermostats). Just starting to play around a bit with all this smart home stuff and openHAB. But it feels quite familiar with my background in web devlopment :slight_smile: I just have to get warm again with Java :wink:

Hi Christian!

Thanks for being brave enough to try this out already :slight_smile:
Note that currently there is neither support for shutter controls nor thermostats, and I have neither of the available at home for testing.

Now that I added support for quite some of the Bosch devices, the workflow is relatively smooth :slight_smile: If you feel like helping a bit, I’d be more than happy to assist with writing the binding, and perhaps I’ll even have a bunch of spare cycles to do a skeleton implementation. For that, I’d probably need some of the debug output that the plugin will produce one you fire it up.

Although your devices are not supported, the plugin should be able to connect to the SHC and list all registered devices (and thanks to Gerd probably also the rooms again!)

Happy to help :slight_smile:

Hi Stefan,

Yeah, no problem about the missing devices, I already thought about helping with the implementation :slight_smile: As you said with the ground work done it shouldn’t be a big problem to add some more.

I already dived into the API that Bosch provides (https://github.com/BoschSmartHome/bosch-shc-api-docs and https://apidocs.bosch-smarthome.com/local/) and was able to get the temperature from my thermostats (and trigger the shutter controls :wink: ). My main limitation is the time investment beside work and family, but I’ll try to move forward bit by bit.

As soon as I got familiar with your code base and got something done, I’ll send a pull request via GitHub :slight_smile:

1 Like

Just to avoid any confusion, the most recent branch is not the one mentioned above, but this one:

And this commit is an example of the kinds of things that have to be implemented to add a new device:

If somebody understands Maven, I’d be more than glad to try to get the binding compile with bouncycastle :slight_smile: That’d be extremely helpful to get generating the keys properly included in the binding.

Thanks, I was on the correct branch already.

Already managed to add the shutter control device to openHAB. Right now I’m trying to get the level (open ratio) of the shutter, but I guess it’s too late to get my head around it :wink: Will continue tomorrow.

I could use some tips to get a faster workflow:

  • How to reload a binding when openHAB is running without having to stop and start openHAB?
  • Is there some documentation about debugging a binding when openHAB runs in a Docker container? Or do I have to run it from an installation to be able to debug the binding? I’m using Visual Studio Code as my IDE, maybe there is a trick as well to get it to connect the debugger.

Only rough tips. You can find more details on the internet:

How to reload a binding

Use the openhab OSGI console, see https://www.openhab.org/docs/administration/console.html. Your binding is one of the bundles and you can start/stop, install/uninstall/update it.

debugging a binding when openHAB runs in a Docker container

The Java debugger can be attached to running processes on remote machines. Your docker container is such a remote machine and needs to expose the decessary ports. But because openhab runs as an OSGI container it could be more difficult as usual.

Only rough tips. You can find more details on the internet:

Ah, the Internet, I heard about it :wink:

Thanks for the tip about the openHAB console. I stumbled upon it and thought it might have an option for it, but I wasn’t sure what to google for.

Getting the debugger to connect always seems to be a bit tricky, but I guess I will get it to work. Thanks for the hint about OSGI, I didn’t know openHAB uses that platform.

1 Like

Hey there!

Got some time and motivation today as well, so I worked on the Shutter Control Handler/Thing. It already works for getting the current level and for the Up/Down commands to move the shutter up/down. I still have to review some parts and add the command for setting a specific percentage value.

I am working on a branch, so you can easily merge it into the main branch once it is in a good state. I already created a draft for a pull request if we want to discuss the code: https://github.com/stefan-kaestle/openhab2-addons/pull/2

During my work I found some things that don’t seem to be correct. Is it okay if I open some issues in GitHub for those, @skaestle? We can discuss them there one-by-one instead of in this thread. You need to enable the issue tracker in your GitHub fork first (https://softwareengineering.stackexchange.com/a/179470).

Good morning Christian!

Thanks so much for the PR, I’m excited that things are moving forward and patches are flying in! Great work!

I had a look at your PR and all seems good so far, no major issues :slight_smile:

It’s very likely that some things are not correct, so please raise them! I did enable the tracker now, so that should be a great place to collect open issues :sun_with_face:

Thanks!

1 Like

I think this is a great idea, because we can collect things and keep them separate. Even others could join and pick one of the issues.

1 Like

For the record: The command to reload a changed addon in the openHAB console is:

bundle:update org.openhab.binding.boschshc

This way one does not have to completely restart the openHAB service :+1:

1 Like

Hi OpenHab heroes,
can you roughly predict when ‘mortal’ OpenHab users :upside_down_face: can download and install BSH binding?

Thanks in advance!

Hi @kreack,

We are currently preparing a first release, which still might take some time because we have to make some adjustments to meet the openHAB guidelines.

But if you like we could send you a custom build bundle that you could put directly in your addons folder. We would anyway like to have some more testers, so this would be a win-win :slight_smile: