Slider ignores stateDescription

problem:
If I use a simple configuration of a slider, min- and max-values are ignored. Sliding to a value above the max-value results in:

[ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@1210a777': 63 is out of range

excerpt of configurations:

#widget:
- component: oh-slider-card
  config:
    item: =myItem
//myItem.items:
...
stateDescription=" "[pattern="%.0f", readOnly="false", min="0", max="40", step="1"]

//Doesn't work either:
stateDescription=" "[pattern="%.0f", readOnly="false", min=0, max=40, step=1]

UI reads:

{"link":"http://openhab:8080/rest/items/myItem","state":"40","stateDescription":{"minimum":0,"maximum":40,"step":1,"pattern":"%.0f","readOnly":false,"options":[]}

my questions:

  1. Is stateDescription the wrong approach to define the default min and max values, especially for widget components in the UI?
  2. Do I really have to define … for each slider (or other components)?
    Especially for dynamic widgets, this wouldn’t be very handy.
- component: oh-slider-card
  config:
    item: =myItem
    min: 0 
    max: 40 
    step: 1 

You are right, at present the slider does not reference the state description to automatically set the min and max values. So, yes you do have to set them manually.

However, this is, in my opinion, a pretty reasonable request that would benefit many users and you should consider filing a feature request in the UI repository for it.

https://github.com/openhab/openhab-webui/issues/2966

Not sure if everything is correct, but it was my first time. :innocent:

1 Like