From 45d4687caa2ee55e004dea125cc21f73fbf4e127 Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Sat, 25 Jun 2022 12:46:19 +0200 Subject: [PATCH 1/5] switch openhab to v3.2 --- versions.properties | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/versions.properties b/versions.properties index b287925b0a..66febff476 100644 --- a/versions.properties +++ b/versions.properties @@ -127,9 +127,7 @@ version.org.springframework.boot..spring-boot-starter-websocket=2.6.3 version.org.springframework..spring-webmvc=5.3.15 -version.org.openhab.core.bundles..org.openhab.core.io.rest.core=3.1.0 -## # available=3.1.1 -## # available=3.2.0 +version.org.openhab.core.bundles..org.openhab.core.io.rest.core=3.2.0 plugin.org.springframework.boot=2.6.2 ## # available=2.6.3 From f31d0f9ed1cfa5b7fb84fb9cb1ace9d8986d9185 Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Sat, 25 Jun 2022 12:46:37 +0200 Subject: [PATCH 2/5] apply api changes --- .../synchronizer/SynchronizationProcessor.java | 15 ++++++++------- .../ThingDeviceUnitSynchronization.java | 5 +++-- .../synchronizer/ThingUnitSynchronization.java | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/SynchronizationProcessor.java b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/SynchronizationProcessor.java index a884d979d8..6dac5b1436 100644 --- a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/SynchronizationProcessor.java +++ b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/SynchronizationProcessor.java @@ -49,6 +49,7 @@ import org.openhab.core.io.rest.core.thing.EnrichedThingDTO; import org.openhab.core.items.dto.ItemDTO; import org.openhab.core.thing.ThingUID; +import org.openhab.core.thing.dto.AbstractThingDTO; import org.openhab.core.thing.dto.ChannelDTO; import org.openhab.core.thing.dto.ThingDTO; import org.openhab.core.thing.link.dto.ItemChannelLinkDTO; @@ -84,7 +85,7 @@ public class SynchronizationProcessor { * @return a device unit config for the thing as described above * @throws NotAvailableException if no device could be found */ - public static UnitConfig getDeviceForThing(final ThingDTO thingDTO) throws CouldNotPerformException { + public static UnitConfig getDeviceForThing(final AbstractThingDTO thingDTO) throws CouldNotPerformException { // iterate over all devices for (final UnitConfig deviceUnitConfig : Registries.getUnitRegistry().getUnitConfigsByUnitTypeFiltered(UnitType.DEVICE, false)) { // get the most global meta config @@ -135,7 +136,7 @@ public static String getUniquePrefix(final String uniqueId) { return uniquePrefix.toString(); } - public static UnitConfig getLocationForThing(final ThingDTO thingDTO) throws CouldNotPerformException, InterruptedException { + public static UnitConfig getLocationForThing(final AbstractThingDTO thingDTO) throws CouldNotPerformException, InterruptedException { if (thingDTO.location != null) { List locationConfigs = Registries.getUnitRegistry(true).getUnitConfigsByLabelAndUnitType(thingDTO.location, UnitType.LOCATION); @@ -178,7 +179,7 @@ public static DeviceClass getDeviceClassByDiscoveryResult(final DiscoveryResultD return resolveDeviceClass(discoveryResult.label, discoveryResult.thingTypeUID, properties); } - public static DeviceClass getDeviceClassForThing(final ThingDTO thingDTO) throws CouldNotPerformException { + public static DeviceClass getDeviceClassForThing(final AbstractThingDTO thingDTO) throws CouldNotPerformException { return resolveDeviceClass(thingDTO.label, thingDTO.thingTypeUID, thingDTO.properties); } @@ -193,7 +194,7 @@ public static GatewayClass getGatewayClassByDiscoveryResult(final DiscoveryResul return resolveGatewayClass(discoveryResult.label, discoveryResult.thingTypeUID, properties); } - public static GatewayClass getGatewayClassForThing(final ThingDTO thingDTO) throws CouldNotPerformException { + public static GatewayClass getGatewayClassForThing(final AbstractThingDTO thingDTO) throws CouldNotPerformException { return resolveGatewayClass(thingDTO.label, thingDTO.thingTypeUID, thingDTO.properties); } @@ -368,7 +369,7 @@ public static Map generateServiceMap(final UnitConf return serviceTypePatternMap; } - private static String getChannelUID(final UnitConfig unitConfig, final ServiceType serviceType, final ServicePattern servicePattern, final ThingDTO thingDTO) throws CouldNotPerformException { + private static String getChannelUID(final UnitConfig unitConfig, final ServiceType serviceType, final ServicePattern servicePattern, final EnrichedThingDTO thingDTO) throws CouldNotPerformException { String channelUID = ""; // todo: validate that unit host is available by using UnitConfigProcessor.isHostUnitAvailable(unitConfig) and make sure apps are handled as well. final UnitConfig deviceUnitConfig = Registries.getUnitRegistry().getUnitConfigById(unitConfig.getUnitHostId()); @@ -410,7 +411,7 @@ private static String getChannelUID(final UnitConfig unitConfig, final ServiceTy return channelUID; } - public static void registerAndValidateItems(final UnitConfig unitConfig, final ThingDTO thingDTO) throws CouldNotPerformException { + public static void registerAndValidateItems(final UnitConfig unitConfig, final EnrichedThingDTO thingDTO) throws CouldNotPerformException { final List itemChannelLinks = OpenHABRestCommunicator.getInstance().getItemChannelLinks(); for (final Entry entry : generateServiceMap(unitConfig).entrySet()) { final ServiceType serviceType = entry.getKey(); @@ -581,7 +582,7 @@ public static boolean updateUnitToThing(final EnrichedThingDTO thing, final Unit * @param thingDTO the thing to be removed. * @throws CouldNotPerformException if removing the thing fails. */ - public static void deleteThing(final ThingDTO thingDTO) throws CouldNotPerformException { + public static void deleteThing(final EnrichedThingDTO thingDTO) throws CouldNotPerformException { final List itemChannelLinks = OpenHABRestCommunicator.getInstance().getItemChannelLinks(); for (final ChannelDTO channel : thingDTO.channels) { for (final ItemChannelLinkDTO itemChannelLink : itemChannelLinks) { diff --git a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingDeviceUnitSynchronization.java b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingDeviceUnitSynchronization.java index 7e5e78bb0e..0866efea20 100644 --- a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingDeviceUnitSynchronization.java +++ b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingDeviceUnitSynchronization.java @@ -44,6 +44,7 @@ import org.openbase.type.domotic.unit.device.DeviceClassType.DeviceClass; import org.openbase.type.domotic.unit.gateway.GatewayClassType.GatewayClass; import org.openhab.core.io.rest.core.thing.EnrichedThingDTO; +import org.openhab.core.thing.dto.AbstractThingDTO; import org.openhab.core.thing.dto.ThingDTO; import java.util.ArrayList; @@ -97,7 +98,7 @@ public void update(IdentifiableEnrichedThingDTO identifiableEnrichedThingDTO) th @Override public void register(IdentifiableEnrichedThingDTO identifiableEnrichedThingDTO) throws CouldNotPerformException, InterruptedException { logger.debug("Synchronize {} ...", identifiableEnrichedThingDTO.getDTO().UID); - final ThingDTO thingDTO = identifiableEnrichedThingDTO.getDTO(); + final EnrichedThingDTO thingDTO = identifiableEnrichedThingDTO.getDTO(); try { final UnitConfig deviceUnitConfig = SynchronizationProcessor.getDeviceForThing(thingDTO); @@ -111,7 +112,7 @@ public void register(IdentifiableEnrichedThingDTO identifiableEnrichedThingDTO) } } - private void registerDevice(ThingDTO thingDTO) throws CouldNotPerformException, InterruptedException { + private void registerDevice(EnrichedThingDTO thingDTO) throws CouldNotPerformException, InterruptedException { //TODO: should this entire action be rolled back if one part fails? // get device class for thing DeviceClass deviceClass; diff --git a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingUnitSynchronization.java b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingUnitSynchronization.java index 39a9458f81..2d0a0cb97c 100644 --- a/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingUnitSynchronization.java +++ b/module/device/openhab/src/main/java/org/openbase/bco/device/openhab/registry/synchronizer/ThingUnitSynchronization.java @@ -120,12 +120,12 @@ public boolean isSupported(IdentifiableEnrichedThingDTO identifiableEnrichedThin return identifiableEnrichedThingDTO.getId().startsWith(BCO_BINDING_ID); } - private String getUnitId(ThingDTO thingDTO) { + private String getUnitId(EnrichedThingDTO thingDTO) { String[] split = thingDTO.UID.split(":"); return split[split.length - 1]; } - private void registerAndValidateItems(final ThingDTO thingDTO) throws CouldNotPerformException { + private void registerAndValidateItems(final EnrichedThingDTO thingDTO) throws CouldNotPerformException { // save current item channel links to compute if some already exist final List itemChannelLinks = OpenHABRestCommunicator.getInstance().getItemChannelLinks(); // retrieve the unit belonging to the thing From 3f2fde9a10a6a6bafcf0e9796c37219202ec7ac4 Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Wed, 1 Nov 2023 17:15:02 +0100 Subject: [PATCH 3/5] upgrade to openhab 4.0.3A --- versions.properties | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/versions.properties b/versions.properties index 7fb4e31771..e63b0356c2 100644 --- a/versions.properties +++ b/versions.properties @@ -56,9 +56,7 @@ version.org.springframework.boot..spring-boot-starter-webflux=3.1.2 version.org.springframework.boot..spring-boot-starter-jetty=3.1.2 version.org.springframework.boot..spring-boot-starter-websocket=3.1.2 version.org.springframework..spring-webmvc=6.0.11 -version.org.openhab.core.bundles..org.openhab.core.io.rest.core=3.2.0 -## # available=3.1.1 -## # available=3.2.0 +version.org.openhab.core.bundles..org.openhab.core.io.rest.core=4.0.3 plugin.org.springframework.boot=3.1.2 plugin.io.spring.dependency-management=1.1.2 version.kotlin=1.9.0 From e09d60608e193c02890794fc223ba24d695dcd94 Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Mon, 6 Nov 2023 23:56:37 +0100 Subject: [PATCH 4/5] fix health check configuration --- docker/Dockerfile | 5 +++-- docker/bco-demo/Dockerfile | 4 ++-- docker/device-manager/openhab/Dockerfile | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5c7958491d..c246598051 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -75,7 +75,8 @@ ENV \ BCO_HOME="/home/bco/data" \ BCO_LOGS="/home/bco/data/log" \ BCO_BINARY="/usr/bin/bco" \ - BCO_OPTIONS="" + MQTT_BROKER="mqtt-broker" \ + BCO_OPTIONS="--host ${MQTT_BROKER}" # Basic build-time metadata as defined at http://label-schema.org LABEL org.label-schema.build-date=$BUILD_DATE \ @@ -111,7 +112,7 @@ ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] # Configure healthcheck # todo: make sure only the registry availability is checks since devices are not maintained by this instance. -HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate >/dev/null || exit 1 +HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate --host ${MQTT_BROKER} > /dev/null || exit 1 # switch to root, let the entrypoint drop back to bco user USER root diff --git a/docker/bco-demo/Dockerfile b/docker/bco-demo/Dockerfile index 1a7a5d11e0..ee63d55f56 100644 --- a/docker/bco-demo/Dockerfile +++ b/docker/bco-demo/Dockerfile @@ -23,7 +23,7 @@ FROM openbaseorg/bco:${BCO_BASE_IMAGE_VERSION} ENV \ JAVA_OPTS="" \ OPENHAB_CONF="/etc/openhab2" \ - BCO_OPTIONS="--db /tmp/bco/db" \ + BCO_OPTIONS="--db /tmp/bco/db --host ${MQTT_BROKER}" \ BCO_MODULE_PREPARE_SCRIPT="bco-module-prepare.sh" # Basic build-time metadata as defined at http://label-schema.org @@ -51,7 +51,7 @@ COPY --from=builder /workspace/db /usr/share/bco/db/ # Configure healthcheck # todo: make sure only device offered by this device manager are checked -HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate >/dev/null || exit 1 +HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate --host ${MQTT_BROKER} >/dev/null || exit 1 # switch to root, let the entrypoint drop back to bco user USER root diff --git a/docker/device-manager/openhab/Dockerfile b/docker/device-manager/openhab/Dockerfile index 16fbd837cc..02ce876f34 100644 --- a/docker/device-manager/openhab/Dockerfile +++ b/docker/device-manager/openhab/Dockerfile @@ -6,7 +6,6 @@ FROM openbaseorg/bco:${BCO_BASE_IMAGE_VERSION} ENV \ JAVA_OPTS="" \ OPENHAB_CONF="/etc/openhab2" \ - BCO_OPTIONS="" \ BCO_MODULE_PREPARE_SCRIPT="bco-module-prepare.sh" # Basic build-time metadata as defined at http://label-schema.org @@ -33,7 +32,7 @@ RUN ln -s /usr/local/bin/${BCO_MODULE_PREPARE_SCRIPT} && \ # Configure healthcheck # todo: make sure only device offered by this device manager are checked -HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate >/dev/null || exit 1 +HEALTHCHECK --interval=15m --timeout=2m CMD bco-validate --host ${MQTT_BROKER} >/dev/null || exit 1 # switch to root, let the entrypoint drop back to bco user USER root From b59bbafc6795590608b0d4cefdae4b5fcec12301 Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Tue, 7 Nov 2023 01:08:39 +0100 Subject: [PATCH 5/5] bump openhab version to 4.0.4 --- versions.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.properties b/versions.properties index e63b0356c2..c4377848b5 100644 --- a/versions.properties +++ b/versions.properties @@ -56,7 +56,7 @@ version.org.springframework.boot..spring-boot-starter-webflux=3.1.2 version.org.springframework.boot..spring-boot-starter-jetty=3.1.2 version.org.springframework.boot..spring-boot-starter-websocket=3.1.2 version.org.springframework..spring-webmvc=6.0.11 -version.org.openhab.core.bundles..org.openhab.core.io.rest.core=4.0.3 +version.org.openhab.core.bundles..org.openhab.core.io.rest.core=4.0.4 plugin.org.springframework.boot=3.1.2 plugin.io.spring.dependency-management=1.1.2 version.kotlin=1.9.0