diff --git a/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/channel/Channels.java b/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/channel/Channels.java index c44e1c220..82f63ad9b 100644 --- a/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/channel/Channels.java +++ b/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/channel/Channels.java @@ -62,7 +62,7 @@ public class Channels { // inside the thing-types.xml file. A better solution would be to create the channel types // dynamically based on the WebThing description to make most of the meta data of a WebThing. // The goal of the WebThing meta data is to enable semantic interoperability for connected things - channelBuilder.withType(new ChannelTypeUID(BINDING_ID, itemType.getType())); + channelBuilder.withType(new ChannelTypeUID(BINDING_ID, itemType.getType().toLowerCase())); channelBuilder.withDescription(property.description); channelBuilder.withLabel(property.title); var defaultTag = itemType.getTag(); diff --git a/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeMapping.java b/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeMapping.java index efd19299b..7e1789e1c 100644 --- a/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeMapping.java +++ b/bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeMapping.java @@ -17,6 +17,7 @@ import java.util.Locale; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.webthing.internal.client.dto.Property; +import org.openhab.core.library.CoreItemFactory; /** * The {@link TypeMapping} class defines the mapping of Item types <-> WebThing Property types. @@ -31,12 +32,12 @@ public class TypeMapping { /** * maps a property type to an item type - * + * * @param propertyMetadata the property meta data * @return the associated item type */ public static ItemType toItemType(Property propertyMetadata) { - String type = "string"; + String type = CoreItemFactory.STRING; @Nullable String tag = null; @@ -48,46 +49,46 @@ public class TypeMapping { case "MotionProperty": case "OnOffProperty": case "PushedProperty": - type = "switch"; + type = CoreItemFactory.SWITCH; tag = "Switchable"; break; case "CurrentProperty": case "FrequencyProperty": case "InstantaneousPowerProperty": case "VoltageProperty": - type = "number"; + type = CoreItemFactory.NUMBER; break; case "HeatingCoolingProperty": case "ImageProperty": case "VideoProperty": - type = "string"; + type = CoreItemFactory.STRING; break; case "BrightnessProperty": case "HumidityProperty": - type = "dimmer"; + type = CoreItemFactory.DIMMER; break; case "ColorModeProperty": - type = "string"; + type = CoreItemFactory.STRING; tag = "lighting"; break; case "ColorProperty": - type = "color"; + type = CoreItemFactory.COLOR; tag = "Lighting"; break; case "ColorTemperatureProperty": - type = "dimmer"; + type = CoreItemFactory.DIMMER; tag = "Lighting"; break; case "OpenProperty": - type = "contact"; + type = CoreItemFactory.CONTACT; tag = "ContactSensor"; break; case "TargetTemperatureProperty": - type = "number"; + type = CoreItemFactory.NUMBER; tag = "TargetTemperature"; break; case "TemperatureProperty": - type = "number"; + type = CoreItemFactory.NUMBER; tag = "CurrentTemperature"; break; case "ThermostatModeProperty": @@ -95,23 +96,23 @@ public class TypeMapping { case "LevelProperty": if ((propertyMetadata.unit != null) && propertyMetadata.unit.toLowerCase(Locale.ENGLISH).equals("percent")) { - type = "dimmer"; + type = CoreItemFactory.DIMMER; } else { - type = "number"; + type = CoreItemFactory.NUMBER; } break; default: switch (propertyMetadata.type.toLowerCase(Locale.ENGLISH)) { case "boolean": - type = "switch"; + type = CoreItemFactory.SWITCH; tag = "Switchable"; break; case "integer": case "number": - type = "number"; + type = CoreItemFactory.NUMBER; break; default: - type = "string"; + type = CoreItemFactory.STRING; break; } break;