mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
Adding "thingTypeVersion" property at thing creation (#15463)
Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
parent
9f753e879a
commit
31d4c7dc27
@ -159,7 +159,7 @@ public enum ModuleType {
|
|||||||
public final ThingTypeUID thingTypeUID;
|
public final ThingTypeUID thingTypeUID;
|
||||||
public final FeatureArea feature;
|
public final FeatureArea feature;
|
||||||
public final String apiName;
|
public final String apiName;
|
||||||
public final int thingTypeVersion;
|
public final String thingTypeVersion;
|
||||||
|
|
||||||
ModuleType(FeatureArea feature, String apiName, int thingTypeVersion, @Nullable ModuleType bridge,
|
ModuleType(FeatureArea feature, String apiName, int thingTypeVersion, @Nullable ModuleType bridge,
|
||||||
Set<Class<? extends Capability>> capabilities, ChannelGroup... channelGroups) {
|
Set<Class<? extends Capability>> capabilities, ChannelGroup... channelGroups) {
|
||||||
@ -169,7 +169,7 @@ public enum ModuleType {
|
|||||||
this.apiName = apiName;
|
this.apiName = apiName;
|
||||||
this.channelGroups = Set.of(channelGroups);
|
this.channelGroups = Set.of(channelGroups);
|
||||||
this.thingTypeUID = new ThingTypeUID(BINDING_ID, name().toLowerCase().replace("_", "-"));
|
this.thingTypeUID = new ThingTypeUID(BINDING_ID, name().toLowerCase().replace("_", "-"));
|
||||||
this.thingTypeVersion = thingTypeVersion;
|
this.thingTypeVersion = Integer.toString(thingTypeVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLogical() {
|
public boolean isLogical() {
|
||||||
|
@ -98,7 +98,7 @@ public class Capability {
|
|||||||
properties = new HashMap<>(thing.getProperties());
|
properties = new HashMap<>(thing.getProperties());
|
||||||
firstLaunch = properties.isEmpty();
|
firstLaunch = properties.isEmpty();
|
||||||
if (firstLaunch) {
|
if (firstLaunch) {
|
||||||
properties.put(PROPERTY_THING_TYPE_VERSION, Integer.toString(moduleType.thingTypeVersion));
|
properties.put(PROPERTY_THING_TYPE_VERSION, moduleType.thingTypeVersion);
|
||||||
if (!moduleType.isLogical()) {
|
if (!moduleType.isLogical()) {
|
||||||
String name = moduleType.apiName.isBlank() ? moduleType.name() : moduleType.apiName;
|
String name = moduleType.apiName.isBlank() ? moduleType.name() : moduleType.apiName;
|
||||||
properties.put(PROPERTY_MODEL_ID, name);
|
properties.put(PROPERTY_MODEL_ID, name);
|
||||||
|
@ -17,6 +17,7 @@ import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -75,6 +76,7 @@ public class NetatmoThingTypeProvider implements ThingTypeProvider {
|
|||||||
.withRepresentationProperty(NAThingConfiguration.ID)
|
.withRepresentationProperty(NAThingConfiguration.ID)
|
||||||
.withExtensibleChannelTypeIds(moduleType.getExtensions())
|
.withExtensibleChannelTypeIds(moduleType.getExtensions())
|
||||||
.withChannelGroupDefinitions(getGroupDefinitions(moduleType))
|
.withChannelGroupDefinitions(getGroupDefinitions(moduleType))
|
||||||
|
.withProperties(Map.of(PROPERTY_THING_TYPE_VERSION, moduleType.thingTypeVersion))
|
||||||
.withConfigDescriptionURI(moduleType.getConfigDescription());
|
.withConfigDescriptionURI(moduleType.getConfigDescription());
|
||||||
|
|
||||||
ThingTypeUID bridgeType = moduleType.getBridge().thingTypeUID;
|
ThingTypeUID bridgeType = moduleType.getBridge().thingTypeUID;
|
||||||
|
Loading…
Reference in New Issue
Block a user