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 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 diff --git a/versions.properties b/versions.properties index 23734b561c..c4377848b5 100644 --- a/versions.properties +++ b/versions.properties @@ -47,6 +47,7 @@ version.com.google.guava..guava=28.0-jre ## # available=31.0-jre ## # available=31.0.1-android ## # available=31.0.1-jre + version.org.openbase..jul.communication.mqtt.test=3.3-SNAPSHOT version.org.openbase..jul.transformation=3.3-SNAPSHOT version.org.testcontainers..junit-jupiter=1.18.3 @@ -55,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.1.0 -## # available=3.1.1 -## # available=3.2.0 +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