From 31d4c7dc27f13d2416f620f3523a4a592da7b8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Sat, 9 Sep 2023 11:07:26 +0200 Subject: [PATCH] Adding "thingTypeVersion" property at thing creation (#15463) Signed-off-by: clinique --- .../openhab/binding/netatmo/internal/api/data/ModuleType.java | 4 ++-- .../netatmo/internal/handler/capability/Capability.java | 2 +- .../netatmo/internal/providers/NetatmoThingTypeProvider.java | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java index da58f434894..d9c5283faf0 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java @@ -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> 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() { diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java index 692be0465a7..e21f5f39da9 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java @@ -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); diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/providers/NetatmoThingTypeProvider.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/providers/NetatmoThingTypeProvider.java index cb66f0e2207..25df69272be 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/providers/NetatmoThingTypeProvider.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/providers/NetatmoThingTypeProvider.java @@ -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;