[openwebnet] Fixes #8524 and #8547, updated openwebnet4j lib to 0.3.1. Updated README (#8645)

Signed-off-by: Massimo Valla <mvcode00@gmail.com>
This commit is contained in:
M Valla 2020-10-05 17:50:38 +02:00 committed by GitHub
parent a857592f07
commit e32a262c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 9 deletions

View File

@ -66,7 +66,7 @@ For other gateways you can add them manually, see [Thing Configuration](#thing-c
Devices can also be discovered if activated while an Inbox Scan is active: start a new Scan, wait 15-20 seconds and then _while the Scan is still active_ (spinning arrow in Inbox), activate the physical device (for example dim the dimmer) to have it discovered by the binding.
If a device cannot be discovered automatically it's always possible to add them manually, see [Configuring Devices](#configuring-devices).
If a device cannot be discovered automatically it's always possible to add it manually, see [Configuring Devices](#configuring-devices).
### ZigBee Discovery
@ -210,5 +210,6 @@ Special thanks for helping on testing this binding go to:
[@k0nti](https://community.openhab.org/u/k0nti/),
[@gilberto.cocchi](https://community.openhab.org/u/gilberto.cocchi/),
[@llegovich](https://community.openhab.org/u/llegovich),
[@gabriele.daltoe](https://community.openhab.org/u/gabriele.daltoe)
[@gabriele.daltoe](https://community.openhab.org/u/gabriele.daltoe),
[@feodor](https://community.openhab.org/u/feodor)
and many others at the fantastic openHAB community!

View File

@ -23,7 +23,7 @@
<dependency>
<groupId>com.github.openwebnet4j</groupId>
<artifactId>openwebnet4j</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<scope>compile</scope>
</dependency>

View File

@ -314,16 +314,26 @@ public class OpenWebNetBridgeHandler extends ConfigStatusBridgeHandler implement
/**
* Un-register a device from this bridge handler
*
* @param oId the device OpenWebNet id
* @param ownId the device OpenWebNet id
*/
protected void unregisterDevice(String oId) {
if (registeredDevices.remove(oId) != null) {
logger.debug("un-registered device ownId={}", oId);
protected void unregisterDevice(String ownId) {
if (registeredDevices.remove(ownId) != null) {
logger.debug("un-registered device ownId={}", ownId);
} else {
logger.warn("could not un-register ownId={} (not found)", oId);
logger.warn("could not un-register ownId={} (not found)", ownId);
}
}
/**
* Get an already registered device on this bridge handler
*
* @param ownId the device OpenWebNet id
* @return the registered device Thing handler or null if the id cannot be found
*/
public @Nullable OpenWebNetThingHandler getRegisteredDevice(String ownId) {
return registeredDevices.get(ownId);
}
@Override
public void onEventMessage(@Nullable OpenMessage msg) {
logger.trace("RECEIVED <<<<< {}", msg);

View File

@ -138,6 +138,15 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
deviceWho = baseMsg.getWho();
}
}
String ownId = bridgeHandler.ownIdFromWhoWhere(where, deviceWho);
if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_BUS_ON_OFF_SWITCH) {
if (bridgeHandler.getRegisteredDevice(ownId) != null) {
logger.debug("dimmer/switch with WHERE={} already registered, skipping this discovery result", where);
return;
}
}
String tId = bridgeHandler.thingIdFromWhere(where);
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, tId);
@ -159,7 +168,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
}
Map<String, Object> properties = new HashMap<>(2);
properties.put(OpenWebNetBindingConstants.CONFIG_PROPERTY_WHERE, bridgeHandler.normalizeWhere(where));
properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, bridgeHandler.ownIdFromWhoWhere(where, deviceWho));
properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, ownId);
if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_GENERIC_DEVICE) {
thingLabel = thingLabel + " (WHO=" + deviceWho + ", WHERE=" + whereLabel + ")";
} else {