Skip to content

Commit

Permalink
[boschshc] Initial contribution - Bindings for Bosch Smart Home devic…
Browse files Browse the repository at this point in the history
…es (openhab#8629)

* Initial code from create_openhab_binding_skeleton.sh

Signed-off-by: Stefan Kaestle <[email protected]>
Signed-off-by: Christian Oeing <[email protected]>
Signed-off-by: Gerd Zanker <[email protected]>

Co-authored-by: Stefan Kaestle <[email protected]>
Co-authored-by: Gerd Zanker <[email protected]>
Co-authored-by: Christian Oeing <[email protected]>
Co-authored-by: Hilbrand Bouwkamp <[email protected]>
Co-authored-by: Fabian Wolter <[email protected]>
Co-authored-by: Connor Petty <[email protected]>
Signed-off-by: John Marshall <[email protected]>
  • Loading branch information
7 people authored and themillhousegroup committed May 10, 2021
1 parent 325ae95 commit df64f44
Show file tree
Hide file tree
Showing 65 changed files with 4,464 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
/bundles/org.openhab.binding.bluetooth.roaming/ @cpmeister
/bundles/org.openhab.binding.bluetooth.ruuvitag/ @ssalonen
/bundles/org.openhab.binding.boschindego/ @jofleck
/bundles/org.openhab.binding.boschshc/ @stefan-kaestle @coeing @GerdZanker
/bundles/org.openhab.binding.bosesoundtouch/ @marvkis @tratho
/bundles/org.openhab.binding.broadlink/ @themillhousegroup
/bundles/org.openhab.binding.bsblan/ @hypetsch
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
<artifactId>org.openhab.binding.boschindego</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.boschshc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.bosesoundtouch</artifactId>
Expand Down
52 changes: 52 additions & 0 deletions bundles/org.openhab.binding.boschshc/DEVELOPERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# For Developers

## Build

To only build the Bosch SHC binding code execute

mvn -pl :org.openhab.binding.boschshc install

## Execute

After compiling a new ``org.openhab.binding.boschshc.jar``
copy it into the ``addons`` folder of your openHAB test instance.

For the first time the jar is loaded automatically as a bundle.

It should also be reloaded automatically when the jar changed.

To reload the bundle manually you need to execute:

bundle:update "openHAB Add-ons :: Bundles :: BoschSHC Binding"

or get the ID and update the bundle using the ID:

bundle:list
-> Get ID for "openHAB Add-ons :: Bundles :: BoschSHC Binding"
bundle:update <ID>


## Debugging

To get debug output and traces of the Bosch SHC binding code
add the following lines into ``userdata/etc/log4j2.xml`` Loggers XML section.

<!-- Bosch SHC for debugging -->
<Logger level="TRACE" name="org.openhab.binding.boschshc"/>

## Pairing and Certificates

We need secured and paired connection from the openHAB binding instance to the Bosch SHC.

Read more about the pairing process in [register a new client to the bosch smart home controller](https://github.com/BoschSmartHome/bosch-shc-api-docs/tree/master/postman#register-a-new-client-to-the-bosch-smart-home-controller)

A precondition for the secured connection to the Bosch SHC is a self singed key + certificate.
The key + certificate will be created and stored with the public Bosch SHC certificates in a Java Key store (jks).

The public certificates files are from https://github.com/BoschSmartHome/bosch-shc-api-docs/tree/master/best_practice.
File copies stored in ``src/main/resource``.

All three certificates and the key will be used for the HTTPS connection between
this openHAB binding and the Bosch SHC.

During pairing the openHAB binding will exchange the self singed certificate with SHC.
21 changes: 21 additions & 0 deletions bundles/org.openhab.binding.boschshc/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons

## Third-party Content

bcpkix-jdk15on
bcprov-jdk15on
* License: Bouncy Castle License
* Project: https://www.bouncycastle.org
* Source: https://github.com/bcgit/bc-java
170 changes: 170 additions & 0 deletions bundles/org.openhab.binding.boschshc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# BoschSHC Binding

Binding for the Bosch Smart Home Controller.

- [BoschSHC Binding](#boschshc-binding)
- [Supported Things](#supported-things)
- [Bosch In-Wall switches & Bosch Smart Plugs](#bosch-in-wall-switches--bosch-smart-plugs)
- [Bosch TwinGuard smoke detector](#bosch-twinguard-smoke-detector)
- [Bosch Window/Door contacts](#bosch-windowdoor-contacts)
- [Bosch Motion Detector](#bosch-motion-detector)
- [Bosch Shutter Control in-wall](#bosch-shutter-control-in-wall)
- [Bosch Thermostat](#bosch-thermostat)
- [Bosch Climate Control](#bosch-climate-control)
- [Limitations](#limitations)
- [Discovery](#discovery)
- [Binding Configuration](#binding-configuration)
- [Getting the device IDs](#getting-the-device-ids)
- [Thing Configuration](#thing-configuration)
- [Item Configuration](#item-configuration)

## Supported Things

### Bosch In-Wall switches & Bosch Smart Plugs

**Thing Type ID**: `in-wall-switch`

| Channel Type ID | Item Type | Description |
|--------------------|---------------|----------------------------------------------|
| power-switch | Switch | Current state of the switch. |
| power-consumption | Number:Power | Current power consumption (W) of the device. |
| energy-consumption | Number:Energy | Energy consumption of the device. |

### Bosch TwinGuard smoke detector

**Thing Type ID**: `twinguard`

| Channel Type ID | Item Type | Description |
|--------------------|----------------------|---------------------------------------------------------------------------------------------------|
| temperature | Number:Temperature | Current measured temperature. |
| temperature-rating | String | Rating of the currently measured temperature. |
| humidity | Number:Dimensionless | Current measured humidity. |
| humidity-rating | String | Rating of current measured humidity. |
| purity | Number:Dimensionless | Purity of the air (ppm). Range from 500 to 5500 ppm. A higher value indicates a higher pollution. |
| purity-rating | String | Rating of current measured purity. |
| air-description | String | Overall description of the air quality. |
| combined-rating | String | Combined rating of the air quality. |

### Bosch Window/Door contacts

**Thing Type ID**: `window-contact`

| Channel Type ID | Item Type | Description |
|-----------------|-----------|------------------------------|
| contact | Contact | Contact state of the device. |

### Bosch Motion Detector

**Thing Type ID**: `motion-detector`

| Channel Type ID | Item Type | Description |
|-----------------|-----------|--------------------------------|
| latest-motion | DateTime | The date of the latest motion. |

### Bosch Shutter Control in-wall

**Thing Type ID**: `shutter-control`

| Channel Type ID | Item Type | Description |
|-----------------|---------------|------------------------------------------|
| level | Rollershutter | Current open ratio (0 to 100, Step 0.5). |

### Bosch Thermostat

**Thing Type ID**: `thermostat`

| Channel Type ID | Item Type | Description |
|-----------------------|----------------------|------------------------------------------------|
| temperature | Number:Temperature | Current measured temperature. |
| valve-tappet-position | Number:Dimensionless | Current open ratio of valve tappet (0 to 100). |

### Bosch Climate Control

**Thing Type ID**: `climate-control`

| Channel Type ID | Item Type | Description |
|----------------------|--------------------|-------------------------------|
| temperature | Number:Temperature | Current measured temperature. |
| setpoint-temperature | Number:Temperature | Desired temperature. |

## Limitations

- Discovery of Things
- Discovery of Bridge

## Discovery

Configuration via configuration files or UI (see below).

## Bridge Configuration

You need to provide the IP address and the system password of your Bosch Smart Home Controller.
The IP address of the controller is visible in the Bosch Smart Home Mobile App (More -> System -> Smart Home Controller) or in your network router UI.
The system password is set by you during your initial registration steps in the _Bosch Smart Home App_.

A keystore file with a self signed certificate is created automatically.
This certificate is used for pairing between the Bridge and the Bosch SHC.

*Press and hold the Bosch Smart Home Controller Bridge button until the LED starts blinking after you save your settings for pairing*.

## Getting the device IDs

Bosch IDs for found devices are displayed in the openHAB log on bootup (`OPENHAB_FOLDER/userdata/logs/openhab.log`)

Example:

```
2020-08-11 12:42:49.490 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Heizung id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.495 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=-RoomClimateControl- id=roomClimateControl_hz_1
2020-08-11 12:42:49.497 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=-VentilationService- id=ventilationService
2020-08-11 12:42:49.498 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Großes Fenster id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.501 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=-IntrusionDetectionSystem- id=intrusionDetectionSystem
2020-08-11 12:42:49.502 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Rollladen id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.502 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Heizung id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.503 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Heizung Haus id=hdm:ICom:819410185:HC1
2020-08-11 12:42:49.503 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=-RoomClimateControl- id=roomClimateControl_hz_6
2020-08-11 12:42:49.504 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=PhilipsHueBridgeManager id=hdm:PhilipsHueBridge:PhilipsHueBridgeManager
2020-08-11 12:42:49.505 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Rollladen id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.506 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Rollladen id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.507 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Central Heating id=hdm:ICom:819410185
```

## Thing Configuration

You define your Bosch devices by adding them either to a `.things` file in your `$OPENHAB_CONF/things` folder like this:

```
Bridge boschshc:shc:1 [ ipAddress="192.168.x.y", password="XXXXXXXXXX" ] {
Thing in-wall-switch bathroom "Bathroom" [ id="hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX" ]
Thing in-wall-switch bedroom "Bedroom" [ id="hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX" ]
Thing in-wall-switch kitchen "Kitchen" [ id="hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX" ]
Thing in-wall-switch corridor "Corridor" [ id="hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX" ]
Thing in-wall-switch livingroom "Living Room" [ id="hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX" ]
Thing in-wall-switch coffeemachine "Coffee Machine" [ id="hdm:HomeMaticIP:3014F711A0000XXXXXXXXXXXX" ]
Thing twinguard tg-corridor "Twinguard Smoke Detector" [ id="hdm:ZigBee:000d6f000XXXXXXX" ]
Thing window-contact window-kitchen "Window Kitchen" [ id="hdm:HomeMaticIP:3014F711A00000XXXXXXXXXX" ]
Thing window-contact entrance "Entrance door" [ id="hdm:HomeMaticIP:3014F711A00000XXXXXXXXXX" ]
Thing motion-detector motion-corridor "Bewegungsmelder" [ id="hdm:ZigBee:000d6f000XXXXXXX" ]
}
```

Or by adding them via UI: Settings -> Things -> "+" -> Bosch Smart Home Binding.

## Item Configuration

You define the items which should be linked to your Bosch devices via a `.items` file in your `$OPENHAB_CONF/items` folder like this:

```
Switch Bosch_Bathroom "Bath Room" { channel="boschshc:in-wall-switch:1:bathroom:power-switch" }
Switch Bosch_Bedroom "Bed Room" { channel="boschshc:in-wall-switch:1:bedroom:power-switch" }
Switch Bosch_Kitchen "Kitchen" { channel="boschshc:in-wall-switch:1:kitchen:power-switch" }
Switch Bosch_Corridor "Corridor" { channel="boschshc:in-wall-switch:1:corridor:power-switch" }
Switch Bosch_Living_Room "Living Room" { channel="boschshc:in-wall-switch:1:livingroom:power-switch" }
Switch Bosch_Lelit "Lelit" { channel="boschshc:in-wall-switch:1:coffeemachine:power-switch" }
```

Or by adding them via UI: Settings -> Items -> "+".
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.boschshc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.boschshc</artifactId>

<name>openHAB Add-ons :: Bundles :: BoschSHC Binding</name>

<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.52</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.52</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.boschshc-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-boschshc" description="BoschSHC Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.boschshc/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.boschshc.internal.devices;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link BoschSHCBindingConstants} class defines common constants, which
* are used across the whole binding.
*
* @author Stefan Kästle - Initial contribution
* @author Christian Oeing - added Shutter Control, ThermostatHandler
*/
@NonNullByDefault
public class BoschSHCBindingConstants {

private static final String BINDING_ID = "boschshc";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_SHC = new ThingTypeUID(BINDING_ID, "shc");

public static final ThingTypeUID THING_TYPE_INWALL_SWITCH = new ThingTypeUID(BINDING_ID, "in-wall-switch");
public static final ThingTypeUID THING_TYPE_TWINGUARD = new ThingTypeUID(BINDING_ID, "twinguard");
public static final ThingTypeUID THING_TYPE_WINDOW_CONTACT = new ThingTypeUID(BINDING_ID, "window-contact");
public static final ThingTypeUID THING_TYPE_MOTION_DETECTOR = new ThingTypeUID(BINDING_ID, "motion-detector");
public static final ThingTypeUID THING_TYPE_SHUTTER_CONTROL = new ThingTypeUID(BINDING_ID, "shutter-control");
public static final ThingTypeUID THING_TYPE_THERMOSTAT = new ThingTypeUID(BINDING_ID, "thermostat");
public static final ThingTypeUID THING_TYPE_CLIMATE_CONTROL = new ThingTypeUID(BINDING_ID, "climate-control");

// List of all Channel IDs
// Auto-generated from thing-types.xml via script, don't modify
public static final String CHANNEL_POWER_SWITCH = "power-switch";
public static final String CHANNEL_TEMPERATURE = "temperature";
public static final String CHANNEL_TEMPERATURE_RATING = "temperature-rating";
public static final String CHANNEL_HUMIDITY = "humidity";
public static final String CHANNEL_HUMIDITY_RATING = "humidity-rating";
public static final String CHANNEL_ENERGY_CONSUMPTION = "energy-consumption";
public static final String CHANNEL_POWER_CONSUMPTION = "power-consumption";
public static final String CHANNEL_PURITY = "purity";
public static final String CHANNEL_AIR_DESCRIPTION = "air-description";
public static final String CHANNEL_PURITY_RATING = "purity-rating";
public static final String CHANNEL_COMBINED_RATING = "combined-rating";
public static final String CHANNEL_CONTACT = "contact";
public static final String CHANNEL_LATEST_MOTION = "latest-motion";
public static final String CHANNEL_LEVEL = "level";
public static final String CHANNEL_VALVE_TAPPET_POSITION = "valve-tappet-position";
public static final String CHANNEL_SETPOINT_TEMPERATURE = "setpoint-temperature";
}
Loading

0 comments on commit df64f44

Please sign in to comment.