import org.openhab.core.thing.type.ChannelTypeBuilder;
import org.openhab.core.thing.type.ChannelTypeProvider;
import org.openhab.core.thing.type.ChannelTypeUID;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
+import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
return null;
}
- private StateDescription getSensorStateDescription(SensorEnum sensorType) {
+ private StateDescriptionFragment getSensorStateDescription(SensorEnum sensorType) {
// the digitalSTROM resolution for temperature in kelvin is not correct but sensor-events and cached values are
// shown in °C so we will use this unit for temperature sensors
String unitShortCut = sensorType.getUnitShortcut();
if (sensorType.toString().contains("TEMPERATURE")) {
unitShortCut = "°C";
}
- return new StateDescription(null, null, null, sensorType.getPattern() + " " + unitShortCut, true, null);
+ return StateDescriptionFragmentBuilder.create().withPattern(sensorType.getPattern() + " " + unitShortCut)
+ .withReadOnly(true).build();
}
private String getStageChannelOption(String type, String option) {
return buildIdentifier(type, STAGE, OPTION, option);
}
- private StateDescription getStageDescription(String channelID, Locale locale) {
+ private StateDescriptionFragment getStageDescription(String channelID, Locale locale) {
if (channelID.contains(STAGE.toLowerCase())) {
List<StateOption> stateOptions = new ArrayList<>();
if (channelID.contains(LIGHT)) {
locale)));
}
}
- return new StateDescription(null, null, null, null, false, stateOptions);
+ return StateDescriptionFragmentBuilder.create().withReadOnly(false).withOptions(stateOptions).build();
}
if (channelID.contains(TEMPERATURE_CONTROLLED)) {
- return new StateDescription(new BigDecimal(0), new BigDecimal(50), new BigDecimal(0.1), "%.1f °C", false,
- null);
+ return StateDescriptionFragmentBuilder.create().withMinimum(new BigDecimal(0))
+ .withMaximum(new BigDecimal(50)).withStep(new BigDecimal(0.1)).withPattern("%.1f °C")
+ .withReadOnly(false).build();
}
return null;
}
return ChannelTypeBuilder.state(channelTypeUID, getLabelText(channelID, locale), NUMBER)
.withDescription(getDescText(channelID, locale)).withCategory(getSensorCategory(sensorType))
.withTags(getSimpleTags(channelID, locale))
- .withStateDescription(getSensorStateDescription(sensorType)).build();
+ .withStateDescriptionFragment(getSensorStateDescription(sensorType)).build();
} catch (IllegalArgumentException e) {
if (SUPPORTED_OUTPUT_CHANNEL_TYPES.contains(channelID)) {
return ChannelTypeBuilder
.state(channelTypeUID, getLabelText(channelID, locale), getItemType(channelID))
.withDescription(getDescText(channelID, locale)).withCategory(getCategory(channelID))
.withTags(getTags(channelID, locale))
- .withStateDescription(getStageDescription(channelID, locale)).build();
+ .withStateDescriptionFragment(getStageDescription(channelID, locale)).build();
}
MeteringTypeEnum meteringType = getMeteringType(channelID);
if (meteringType != null) {
if (MeteringTypeEnum.CONSUMPTION.equals(meteringType)) {
pattern = "%d W";
}
+
return ChannelTypeBuilder.state(channelTypeUID, getLabelText(channelID, locale), NUMBER)
.withDescription(getDescText(channelID, locale)).withCategory(CATEGORY_ENERGY)
.withTags(
new HashSet<>(Arrays.asList(getLabelText(channelID, locale), getText(DS, locale))))
- .withStateDescription(new StateDescription(null, null, null, pattern, true, null)).build();
+ .withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withPattern(pattern)
+ .withReadOnly(true).build())
+ .build();
}
try {
DeviceBinarayInputEnum binarayInputType = DeviceBinarayInputEnum
.state(channelTypeUID, getLabelText(channelID, locale), getItemType(channelID))
.withDescription(getDescText(channelID, locale))
.withCategory(getBinaryInputCategory(binarayInputType))
- .withTags(getSimpleTags(channelTypeUID.getId(), locale))
- .withStateDescription(new StateDescription(null, null, null, null, true, null)).build();
+ .withTags(getSimpleTags(channelTypeUID.getId(), locale)).withStateDescriptionFragment(
+ StateDescriptionFragmentBuilder.create().withReadOnly(true).build())
+ .build();
} catch (IllegalArgumentException e1) {
// ignore
}
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
ChannelType channelType = ChannelTypeBuilder.state(channelTypeUID, "Send Button Press", "String")
.withDescription("Send a button press to device " + getThing().getLabel())
- .withStateDescription(new StateDescription(null, null, null, null, false, states)).build();
+ .withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withOptions(states).build())
+ .build();
factory.addChannelType(channelType);
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ChannelType channelType = ChannelTypeBuilder.state(channelTypeUID, "Current Activity", "String")
.withDescription("Current activity for " + getThing().getLabel())
- .withStateDescription(new StateDescription(null, null, null, "%s", false, states)).build();
+ .withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withPattern("%s")
+ .withReadOnly(false).withOptions(states).build())
+ .build();
factory.addChannelType(channelType);
.withDescription(description) //
.withCategory(checkCategory(unitOfMeasure, category, state.isReadOnly())) //
.withTags(checkTags(unitOfMeasure, state.isReadOnly())) //
- .withStateDescription(state.toStateDescription()) //
+ .withStateDescriptionFragment(state) //
.withConfigDescriptionURI(configDescriptionUriChannel).build();
} catch (URISyntaxException ex) {
logger.warn("Can't create ConfigDescription URI '{}', ConfigDescription for channels not avilable!",
import org.openhab.core.thing.type.ChannelType;
import org.openhab.core.thing.type.ChannelTypeBuilder;
import org.openhab.core.thing.type.ChannelTypeUID;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
/**
* An {@link AbstractComponent}s derived class consists of one or multiple channels.
type = ChannelTypeBuilder.trigger(channelTypeUID, label)
.withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL)).build();
} else {
- StateDescription description = valueState.createStateDescription(command_topic == null).build()
- .toStateDescription();
+ StateDescriptionFragment description = valueState.createStateDescription(command_topic == null).build();
type = ChannelTypeBuilder.state(channelTypeUID, label, channelState.getItemType())
.withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL))
- .withStateDescription(description).build();
+ .withStateDescriptionFragment(description).build();
}
Configuration configuration = new Configuration();
if (attributes.retained) {
return ChannelTypeBuilder.state(channelTypeUID, attributes.name, channelState.getItemType())
.withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HOMIE_CHANNEL))
- .withStateDescription(channelState.getCache().createStateDescription(!attributes.settable).build()
- .toStateDescription())
+ .withStateDescriptionFragment(
+ channelState.getCache().createStateDescription(!attributes.settable).build())
.build();
} else {
// Non-retained and settable property -> State channel
final ChannelTypeUID channelTypeUID = new ChannelTypeUID(BINDING_ID, channel.getUID().getId() + "Type");
final String label = channel.getLabel();
final ChannelType channelType = ChannelTypeBuilder.state(channelTypeUID, label == null ? "" : label, itemType)
- .withStateDescription(sdb.withReadOnly(Boolean.TRUE).build().toStateDescription())
+ .withStateDescriptionFragment(sdb.withReadOnly(Boolean.TRUE).build())
.withConfigDescriptionURI(NUTBindingConstants.DYNAMIC_CHANNEL_CONFIG_QUANTITY_TYPE).build();
channelTypeProvider.addChannelType(channelType);
return channelTypeUID;
stateDescription = stateDescription.withPattern(pattern);
}
final StateChannelTypeBuilder builder = ChannelTypeBuilder.state(channelTypeUID, label, itemType)
- .withStateDescription(stateDescription.build().toStateDescription());
+ .withStateDescriptionFragment(stateDescription.build());
if (tag != null) {
builder.withTag(tag);
}
stateDescriptionBuilder = ChannelTypeBuilder
.state(new ChannelTypeUID(SmartMeterBindingConstants.BINDING_ID, obisChannelId), obis,
CoreItemFactory.NUMBER + ":" + dimension)
- .withStateDescription(StateDescriptionFragmentBuilder.create().withReadOnly(true)
- .withPattern("%.2f %unit%").build().toStateDescription())
+ .withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withReadOnly(true)
+ .withPattern("%.2f %unit%").build())
.withConfigDescriptionURI(URI.create(SmartMeterBindingConstants.CHANNEL_TYPE_METERREADER_OBIS));
} else {
stateDescriptionBuilder = ChannelTypeBuilder
.state(new ChannelTypeUID(SmartMeterBindingConstants.BINDING_ID, obisChannelId), obis,
CoreItemFactory.STRING)
- .withStateDescription(
- StateDescriptionFragmentBuilder.create().withReadOnly(true).build().toStateDescription());
-
+ .withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withReadOnly(true).build());
}
return stateDescriptionBuilder.build();
}
}
ChannelType ct = ChannelTypeBuilder
.state(new ChannelTypeUID(TACmiBindingConstants.BINDING_ID, shortName), shortName, itemType)
- .withDescription("Auto-created for " + shortName)
- .withStateDescription(sdb.build().toStateDescription()).build();
+ .withDescription("Auto-created for " + shortName).withStateDescriptionFragment(sdb.build())
+ .build();
channelTypeProvider.addChannelType(ct);
channelBuilder.withType(ct.getUID());
} else {
import org.openhab.core.thing.type.ChannelTypeBuilder;
import org.openhab.core.thing.type.ChannelTypeProvider;
import org.openhab.core.thing.type.ChannelTypeUID;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
+import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
/**
return channelTypeUID;
}
- private void createChannelType(StateDescription state) {
+ private void createChannelType(StateDescriptionFragment state) {
channelType = ChannelTypeBuilder.state(channelTypeUID, "Input source", "String")
- .withDescription("Select the input source of the AVR").withStateDescription(state).build();
+ .withDescription("Select the input source of the AVR").withStateDescriptionFragment(state).build();
}
- private StateDescription getDefaultStateDescription() {
+ private StateDescriptionFragment getDefaultStateDescription() {
List<StateOption> options = new ArrayList<>();
options.add(new StateOption(INPUT_NET_RADIO, "Net Radio"));
options.add(new StateOption(INPUT_PC, "PC"));
options.add(new StateOption(INPUT_PANDORA, "Pandora"));
options.add(new StateOption(INPUT_NAPSTER, "Napster"));
options.add(new StateOption(INPUT_SPOTIFY, "Spotify"));
- StateDescription state = new StateDescription(null, null, null, "%s", false, options);
- return state;
+ return StateDescriptionFragmentBuilder.create().withPattern("%s").withReadOnly(false).withOptions(options)
+ .build();
}
public void changeAvailableInputs(Map<String, String> availableInputs) {
for (Entry<String, String> inputEntry : availableInputs.entrySet()) {
options.add(new StateOption(inputEntry.getKey(), inputEntry.getValue()));
}
- createChannelType(new StateDescription(null, null, null, "%s", false, options));
+ createChannelType(StateDescriptionFragmentBuilder.create().withPattern("%s").withReadOnly(false)
+ .withOptions(options).build());
}
@NonNullByDefault({})
import org.openhab.core.thing.type.ChannelTypeBuilder;
import org.openhab.core.thing.type.ChannelTypeProvider;
import org.openhab.core.thing.type.ChannelTypeUID;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
+import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
/**
return channelTypeUID;
}
- private StateDescription getDefaultStateDescription() {
+ private StateDescriptionFragment getDefaultStateDescription() {
List<StateOption> options = IntStream.rangeClosed(1, 40)
.mapToObj(i -> new StateOption(Integer.toString(i), "Item_" + i)).collect(toList());
-
- StateDescription state = new StateDescription(null, null, null, "%s", false, options);
- return state;
+ return StateDescriptionFragmentBuilder.create().withPattern("%s").withReadOnly(false).withOptions(options)
+ .build();
}
public void changePresetNames(List<PresetInfoState.Preset> presets) {
List<StateOption> options = presets.stream()
.map(preset -> new StateOption(String.valueOf(preset.getValue()), preset.getName())).collect(toList());
-
- StateDescription state = new StateDescription(null, null, null, "%s", false, options);
- createChannelType(state);
+ createChannelType(StateDescriptionFragmentBuilder.create().withPattern("%s").withReadOnly(false)
+ .withOptions(options).build());
}
- private void createChannelType(StateDescription state) {
+ private void createChannelType(StateDescriptionFragment state) {
channelType = ChannelTypeBuilder.state(channelTypeUID, "Preset", "Number")
- .withDescription("Select a saved channel by its preset number").withStateDescription(state).build();
+ .withDescription("Select a saved channel by its preset number").withStateDescriptionFragment(state)
+ .build();
}
@NonNullByDefault({})
channelTypeUID = new ChannelTypeUID(BINDING_ID,
CHANNEL_PLAYBACK_PRESET_TYPE_NAMED + handler.getThing().getUID().getId());
- StateDescription state = getDefaultStateDescription();
- createChannelType(state);
+ createChannelType(getDefaultStateDescription());
}
@Override