StateDescription for number items not working?

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());

I found the problem by myself. Thx.

Hi Markus.
I’m facing similar problems today…
Could you please explain what was the problem? Maybe it helps me to figure out, what’s going wrong in my case :slight_smile:
Thank you and regards,
Osman

HI,

in my case it was a simple cache problem in the browser. I didn’t find out whether I can refresh it from code but a simple “ctrl+F5” in browser is enough. It refresh the side and shows all Channels correctly.

Markus

Hi Markus,

great, thank you! Your “solution” worked also in my case :slight_smile:
Now I’m happy as I know my binding is working (I spent hours seekeing the bug).

IMHO this is a bug in PaperUI. It should send the apropriate headers to the browser so the caching is invalidated or somehow disabled in such cases.
What do you thing? Should we file a new issue in GitHub?

THX and BR,
Osman

Hi,

nice, and yes, youre right, it is a bug.
Could you do it? Create a bugreport in gitgub? I’m a bit out of Time…

Greetings
Markus

Done. BR, Osman

thx!