]> git.basschouten.com Git - openhab-addons.git/commitdiff
Adding "thingTypeVersion" property at thing creation (#15463)
authorGaël L'hopital <gael@lhopital.org>
Sat, 9 Sep 2023 09:07:26 +0000 (11:07 +0200)
committerGitHub <noreply@github.com>
Sat, 9 Sep 2023 09:07:26 +0000 (11:07 +0200)
Signed-off-by: clinique <gael@lhopital.org>
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/providers/NetatmoThingTypeProvider.java

index da58f434894e978b25d34dd5152d08c88f0a184a..d9c5283faf08a451bf584200945163c317b61ad1 100644 (file)
@@ -159,7 +159,7 @@ public enum ModuleType {
     public final ThingTypeUID thingTypeUID;
     public final FeatureArea feature;
     public final String apiName;
-    public final int thingTypeVersion;
+    public final String thingTypeVersion;
 
     ModuleType(FeatureArea feature, String apiName, int thingTypeVersion, @Nullable ModuleType bridge,
             Set<Class<? extends Capability>> capabilities, ChannelGroup... channelGroups) {
@@ -169,7 +169,7 @@ public enum ModuleType {
         this.apiName = apiName;
         this.channelGroups = Set.of(channelGroups);
         this.thingTypeUID = new ThingTypeUID(BINDING_ID, name().toLowerCase().replace("_", "-"));
-        this.thingTypeVersion = thingTypeVersion;
+        this.thingTypeVersion = Integer.toString(thingTypeVersion);
     }
 
     public boolean isLogical() {
index 692be0465a7fd8cd9923b1779e1b400c173d073f..e21f5f39da9bc6002038cf95515d44da8c62a8a0 100644 (file)
@@ -98,7 +98,7 @@ public class Capability {
         properties = new HashMap<>(thing.getProperties());
         firstLaunch = properties.isEmpty();
         if (firstLaunch) {
-            properties.put(PROPERTY_THING_TYPE_VERSION, Integer.toString(moduleType.thingTypeVersion));
+            properties.put(PROPERTY_THING_TYPE_VERSION, moduleType.thingTypeVersion);
             if (!moduleType.isLogical()) {
                 String name = moduleType.apiName.isBlank() ? moduleType.name() : moduleType.apiName;
                 properties.put(PROPERTY_MODEL_ID, name);
index cb66f0e220775351481176b79d1a21c225ba9902..25df69272bee069c9895067911af5171d46c2d6c 100644 (file)
@@ -17,6 +17,7 @@ import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
 import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -75,6 +76,7 @@ public class NetatmoThingTypeProvider implements ThingTypeProvider {
                         .withRepresentationProperty(NAThingConfiguration.ID)
                         .withExtensibleChannelTypeIds(moduleType.getExtensions())
                         .withChannelGroupDefinitions(getGroupDefinitions(moduleType))
+                        .withProperties(Map.of(PROPERTY_THING_TYPE_VERSION, moduleType.thingTypeVersion))
                         .withConfigDescriptionURI(moduleType.getConfigDescription());
 
                 ThingTypeUID bridgeType = moduleType.getBridge().thingTypeUID;