[openwebnet] Thermo: zone/CU address set correctly during discovery (#13803)

Fixes #13761

Signed-off-by: Massimo Valla <mvcode00@gmail.com>
This commit is contained in:
M Valla 2022-11-29 12:08:22 +01:00 committed by GitHub
parent 6bdcd15d99
commit 740d1a7f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -155,7 +155,7 @@ Temperature sensors can be configured defining a `bus_thermo_sensor` Thing with
- example sensor `5` of external zone `00` --> `where="500"`
- example: slave sensor `3` of zone `2` --> `where="302"`
The (optional) Central Unit can be configured defining a `bus_themo_cu` Thing.
The (optional) Central Unit can be configured defining a `bus_themo_cu` Thing with the `where` configuration parameter (`OpenWebNet Address`) set to `where="0"`.
##### Central Unit integration missing points

View File

@ -31,14 +31,15 @@ import org.openhab.core.thing.binding.ThingHandlerService;
import org.openwebnet4j.OpenDeviceType;
import org.openwebnet4j.message.BaseOpenMessage;
import org.openwebnet4j.message.Where;
import org.openwebnet4j.message.WhereThermo;
import org.openwebnet4j.message.WhereZigBee;
import org.openwebnet4j.message.Who;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link OpenWebNetDeviceDiscoveryService} is responsible for discovering OpenWebNet devices connected to a
* bridge/gateway
* The {@link OpenWebNetDeviceDiscoveryService} is responsible for discovering
* OpenWebNet devices connected to a bridge/gateway
*
* @author Massimo Valla - Initial contribution
* @author Andrea Conte - Energy management, Thermoregulation
@ -86,14 +87,16 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
}
/**
* Create and notify to Inbox a new DiscoveryResult based on WHERE, OpenDeviceType and BaseOpenMessage
* Create and notify to Inbox a new DiscoveryResult based on WHERE,
* OpenDeviceType and BaseOpenMessage
*
* @param where the discovered device's address (WHERE)
* @param deviceType {@link OpenDeviceType} of the discovered device
* @param message the OWN message received that identified the device (optional)
* @param message the OWN message received that identified the device
* (optional)
*/
public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable BaseOpenMessage baseMsg) {
logger.info("newDiscoveryResult() WHERE={}, deviceType={}", where, deviceType);
logger.debug("newDiscoveryResult() WHERE={}, deviceType={}", where, deviceType);
ThingTypeUID thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_GENERIC_DEVICE; // generic device
String thingLabel = OpenWebNetBindingConstants.THING_LABEL_GENERIC_DEVICE;
Who deviceWho = Who.UNKNOWN;
@ -210,6 +213,12 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
DiscoveryResult discoveryResult = null;
String whereConfig = where.value();
// remove # from discovered thermo zone or central unit
if (OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_ZONE.equals(thingTypeUID)
|| OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_CU.equals(thingTypeUID)) {
whereConfig = "" + ((WhereThermo) where).getZone();
}
if (where instanceof WhereZigBee && WhereZigBee.UNIT_02.equals(((WhereZigBee) where).getUnit())) {
logger.debug("UNIT=02 found (WHERE={}) -> will remove previous result if exists", where);
thingRemoved(thingUID); // remove previously discovered thing