forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[boschshc] Support for Door/Window Sensor II
* add new thing type for Door/Window Sensor II * add channel types for bypass state and communication quality * add handler extending the basic Door/Window Sensor handler * add service implementations * register handler in discovery service * add unit tests * re-generate i18n properties file * add documentation closes openhab#15954 Signed-off-by: David Pace <[email protected]>
- Loading branch information
1 parent
eba975c
commit e335bcb
Showing
15 changed files
with
498 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...va/org/openhab/binding/boschshc/internal/devices/windowcontact/WindowContact2Handler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.windowcontact; | ||
|
||
import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_BYPASS_STATE; | ||
import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_COMMUNICATION_QUALITY; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException; | ||
import org.openhab.binding.boschshc.internal.services.bypass.BypassService; | ||
import org.openhab.binding.boschshc.internal.services.bypass.dto.BypassServiceState; | ||
import org.openhab.binding.boschshc.internal.services.communicationquality.CommunicationQualityService; | ||
import org.openhab.binding.boschshc.internal.services.communicationquality.dto.CommunicationQualityServiceState; | ||
import org.openhab.core.library.types.StringType; | ||
import org.openhab.core.thing.Thing; | ||
|
||
/** | ||
* Handler for Door/Window Contact II | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class WindowContact2Handler extends WindowContactHandler { | ||
|
||
public WindowContact2Handler(Thing thing) { | ||
super(thing); | ||
} | ||
|
||
@Override | ||
protected void initializeServices() throws BoschSHCException { | ||
super.initializeServices(); | ||
|
||
this.createService(BypassService::new, this::updateChannels, List.of(CHANNEL_BYPASS_STATE), true); | ||
this.createService(CommunicationQualityService::new, this::updateChannels, | ||
List.of(CHANNEL_COMMUNICATION_QUALITY), true); | ||
} | ||
|
||
private void updateChannels(BypassServiceState bypassServiceState) { | ||
updateState(CHANNEL_BYPASS_STATE, new StringType(bypassServiceState.state.toString())); | ||
} | ||
|
||
private void updateChannels(CommunicationQualityServiceState communicationQualityServiceState) { | ||
updateState(CHANNEL_COMMUNICATION_QUALITY, new StringType(communicationQualityServiceState.quality.toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...hc/src/main/java/org/openhab/binding/boschshc/internal/services/bypass/BypassService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.bypass; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.boschshc.internal.services.BoschSHCService; | ||
import org.openhab.binding.boschshc.internal.services.bypass.dto.BypassServiceState; | ||
|
||
/** | ||
* Service for the bypass state of devices such as the Door/Window Contact II | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class BypassService extends BoschSHCService<BypassServiceState> { | ||
|
||
public BypassService() { | ||
super("Bypass", BypassServiceState.class); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...n/java/org/openhab/binding/boschshc/internal/services/bypass/dto/BypassConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.bypass.dto; | ||
|
||
/** | ||
* Configuration object of a bypass configuration. | ||
* <p> | ||
* Example JSON: | ||
* | ||
* <pre> | ||
* "configuration": { | ||
* "enabled": false, | ||
* "timeout": 5, | ||
* "infinite": false | ||
* } | ||
* </pre> | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
public class BypassConfiguration { | ||
|
||
public boolean enabled; | ||
|
||
public int timeout; | ||
|
||
public boolean infinite; | ||
} |
46 changes: 46 additions & 0 deletions
46
...in/java/org/openhab/binding/boschshc/internal/services/bypass/dto/BypassServiceState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.bypass.dto; | ||
|
||
import org.openhab.binding.boschshc.internal.services.dto.BoschSHCServiceState; | ||
|
||
/** | ||
* Bypass service state for Door/Window Contact II | ||
* <p> | ||
* Example JSON: | ||
* | ||
* <pre> | ||
* { | ||
* "@type": "bypassState", | ||
* "state": "BYPASS_INACTIVE", | ||
* "configuration": { | ||
* "enabled": false, | ||
* "timeout": 5, | ||
* "infinite": false | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
public class BypassServiceState extends BoschSHCServiceState { | ||
|
||
public BypassServiceState() { | ||
super("bypassState"); | ||
} | ||
|
||
public BypassState state; | ||
|
||
public BypassConfiguration configuration; | ||
} |
25 changes: 25 additions & 0 deletions
25
.../src/main/java/org/openhab/binding/boschshc/internal/services/bypass/dto/BypassState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.bypass.dto; | ||
|
||
/** | ||
* Possible states of the bypass service. | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
public enum BypassState { | ||
BYPASS_INACTIVE, | ||
BYPASS_ACTIVE, | ||
UNKNOWN | ||
} |
31 changes: 31 additions & 0 deletions
31
.../binding/boschshc/internal/services/communicationquality/CommunicationQualityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.communicationquality; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.boschshc.internal.services.BoschSHCService; | ||
import org.openhab.binding.boschshc.internal.services.communicationquality.dto.CommunicationQualityServiceState; | ||
|
||
/** | ||
* Service for querying the communication quality between a device and the Smart Home Controller. | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class CommunicationQualityService extends BoschSHCService<CommunicationQualityServiceState> { | ||
|
||
public CommunicationQualityService() { | ||
super("CommunicationQuality", CommunicationQualityServiceState.class); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...boschshc/internal/services/communicationquality/dto/CommunicationQualityServiceState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.communicationquality.dto; | ||
|
||
import org.openhab.binding.boschshc.internal.services.dto.BoschSHCServiceState; | ||
|
||
/** | ||
* State of the communication quality service. | ||
* <p> | ||
* Example JSON: | ||
* | ||
* <pre> | ||
* { | ||
* "@type": "communicationQualityState", | ||
* "quality": "UNKNOWN" | ||
* } | ||
* </pre> | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
public class CommunicationQualityServiceState extends BoschSHCServiceState { | ||
|
||
public CommunicationQualityServiceState() { | ||
super("communicationQualityState"); | ||
} | ||
|
||
public CommunicationQualityState quality; | ||
} |
27 changes: 27 additions & 0 deletions
27
...inding/boschshc/internal/services/communicationquality/dto/CommunicationQualityState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.services.communicationquality.dto; | ||
|
||
/** | ||
* Possible states for the communication quality between a device and the bridge. | ||
* | ||
* @author David Pace - Initial contribution | ||
* | ||
*/ | ||
public enum CommunicationQualityState { | ||
BAD, | ||
MEDIUM, | ||
NORMAL, | ||
GOOD, | ||
UNKNOWN | ||
} |
Oops, something went wrong.