Hi,
I have a problem with a binding. I have to create channels dynamicly on runtime. It works nice, but I have a problem with the using of the StateDescription class.
For String item types it works and I get the list of predefined state options. But for decimal values the max, min, step values seems to be ignored by the PaperUI. ( I can edit all values and set values outside of the min/max range. The format-string is ignored too).
String: (option is a string array) works for options:
StateDescription state = new StateDescription(null, null, null, “%s”, readOnly, options);
Number is not working for min max, step, all are ignored:
StateDescription state = new StateDescription(minVal, maxVal, BigDecimal.valueOf(0.5), “%.2f”,
** readOnly, null);**
The ReadOnly Flag is always ignored, on String type too.
What could be the problem? Why is PaperUI ignoring this parameters? My mistake or a bug?
It would be greate if someone could help me here…
Markus
Code:
List<BigDecimal> subValParas = (List<BigDecimal>) serObj.serviceTreeMap.get(subKey)
.getValueParameter();
BigDecimal minVal = subValParas.get(0);
BigDecimal maxVal = subValParas.get(1);
StateDescription state = new StateDescription(minVal, maxVal, BigDecimal.valueOf(0.5), "%.2f",
readOnly, null);
ChannelTypeUID channelTypeUID = new ChannelTypeUID(
thing.getUID().getAsString() + ":" + subKey);
ChannelType channelType = new ChannelType(channelTypeUID, false, "NumberType",
ChannelKind.STATE, subKey, subKey, null, null, state, null,
configDescriptionUriChannel);
channelTypeProvider.addChannelType(channelType);
Channel newChannel = ChannelBuilder
.create(new ChannelUID(thing.getUID(), subKey), "Number")
.withType(channelTypeUID).withDescription(subKey).withLabel(subKey)
.withKind(ChannelKind.STATE).build();
dynamicStateDescriptionProvider.setDescription(newChannel.getUID(), state);
subChannels.add(newChannel);
.
.
.
ThingBuilder thingBuilder = editThing();
for (Channel channel : subChannels) {
thingBuilder.withoutChannel(channel.getUID());
}
thingBuilder.withChannels(subChannels);
updateThing(thingBuilder.build());