// 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();
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.
/**
* 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;
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":
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;