OH3: oh-slider in widget - props "type: NUMBER" not working

openHAB version: 3.1.0 M2
(same behaviour as in 3.0.0 stable)

Hi @ysc ,

When I embed oh-slider or oh-slider-card in a widget I can’t set min, max, step, etc. via props as “type: NUMBER”.
I believe that these parameters need to be of “type: NUMBER” to properly function.

Whenever I use “type: NUMBER” the line gets lost when I reload the widget.

It seems as if the “type: NUMBER” is just not accepted. Only “TEXT” and “BOOLEAN” do not get lost after save and reload of the widget.

YAML before save, reload
uid: slider in widget
tags: []
props:
  parameters:
    - description: Location (room) or device name
      label: Title
      name: title
      required: false
      type: TEXT
    - context: item
      description: Item for timer duration
      label: Timer Duration
      name: itemTimerDuration
      required: false
      type: TEXT
    - description: Timer minimum duration
      label: Timer minimum
      name: TimerMinimum
      required: false
      type: NUMBER
    - description: Timer maximum duration
      label: Timer maximum
      name: TimerMaximum
      required: false
      type: NUMBER
    - description: Timer step
      label: Timer step
      name: TimerStep
      required: false
      type: NUMBER
    - description: Timer scale steps
      label: Timer scale steps
      name: TimerScaleSteps
      required: false
      type: NUMBER
    - description: Timer scale sub steps
      label: Timer scale sub steps
      name: TimerScaleSubSteps
      required: false
      type: NUMBER
  parameterGroups: []
timestamp: Mar 2, 2021, 3:53:32 PM
component: f7-card
config:
  title: =props.title
  class:
    - no-padding
slots:
  default:
    - component: f7-row
      config:
        visible: true
        class:
          - margin-top-half
          - margin-left-half
          - margin-right-half
          - margin-bottom-half
      slots:
        default:
          - component: f7-col
            slots:
              default:
                - component: oh-slider
                  config:
                    item: =props.itemTimerDuration
                    min: =props.TimerMinimum
                    max: =props.TimerMaximum
                    step: =props.TimerStep
                    scaleSteps: =props.TimerScaleSteps
                    scaleSubSteps: =props.TimerScaleSubSteps
                    scale: true
                    unit: min
                    label: true
YAML after save, reload with "type: NUMBER" lost
uid: slider in widget
tags: []
props:
  parameters:
    - description: Location (room) or device name
      label: Title
      name: title
      required: false
      type: TEXT
    - context: item
      description: Item for timer duration
      label: Timer Duration
      name: itemTimerDuration
      required: false
      type: TEXT
    - description: Timer minimum duration
      label: Timer minimum
      name: TimerMinimum
      required: false
    - description: Timer maximum duration
      label: Timer maximum
      name: TimerMaximum
      required: false
    - description: Timer step
      label: Timer step
      name: TimerStep
      required: false
    - description: Timer scale steps
      label: Timer scale steps
      name: TimerScaleSteps
      required: false
    - description: Timer scale sub steps
      label: Timer scale sub steps
      name: TimerScaleSubSteps
      required: false
  parameterGroups: []
timestamp: Mar 2, 2021, 4:47:20 PM
component: f7-card
config:
  title: =props.title
  class:
    - no-padding
slots:
  default:
    - component: f7-row
      config:
        visible: true
        class:
          - margin-top-half
          - margin-left-half
          - margin-right-half
          - margin-bottom-half
      slots:
        default:
          - component: f7-col
            slots:
              default:
                - component: oh-slider
                  config:
                    item: =props.itemTimerDuration
                    min: =props.TimerMinimum
                    max: =props.TimerMaximum
                    step: =props.TimerStep
                    scaleSteps: =props.TimerScaleSteps
                    scaleSubSteps: =props.TimerScaleSubSteps
                    scale: true
                    unit: min
                    label: true

Am I doing something wrong or is this a bug?

Many thanks!

```
code goes here
```

Because the spaces are meaningful in YAML it’s hard to review without the code fences. It will help if you try again.

The docs that Yannick recently wrote imply that NUMBER should be allowed. So I would guess there is something else going on but it’s hard to tell without the code fences working.

copied code fences from your post and got it working.
I updated the initial post.
Thank you.

That’s exactly why I got lost…

Not that it’s easier to read, one difference between the example in the docs and your’s is the docs as an advanced: true for the NUMBER parameter. I’m not sure what that means but it’s worth experimenting with that.

applying…

does not stop the “type: NUMBER” from getting lost.

There is no type NUMBER, the type for min/max/step in oh-slider & oh-slider-card is DECIMAL.

As mentioned in Building Pages - Components & Widgets | openHAB the “props>parameters” array elements follow the config description schema described here:
https://openhab.org/schemas/config-description-1.0.0.xsd (only in YAML, not XML)
So the valid values for type are:

        <xs:simpleType name="parameterType">
                <xs:restriction base="xs:string">
                        <xs:enumeration value="text" />
                        <xs:enumeration value="integer" />
                        <xs:enumeration value="decimal" />
                        <xs:enumeration value="boolean" />
                </xs:restriction>
        </xs:simpleType>
1 Like

OK, then there is an error in the docs, right?

At the top of the component tree there’s we can find a root component. Pages are examples of root components. They have additional attributes:

uid: component1
props:
 parameterGroups:
   - name: group1
     label: Property group
   ...
 parameters:
  - name: prop1
    label: Prop 1
    type: BOOLEAN
    groupName: group1
    description: What prop1 does
  - name: prop2
    label: Prop 2
    type: TEXT
    context: item
    description: Choose an item for this prop
  - name: prop3
    type: NUMBER # !!!! This should be DECIMAL or INTEGER
    advanced: true
    ...
tags: ["tag1", "tag2"]
component: ...
config: ...
slots: ...
  • an uid (its Unique IDentifier)
  • a props structure describing its own properties; props define parameters and parameter groups following a subset of the configuration description schema found in bindings, services and throughout openHAB: see Configuration Descriptions
  • a set of tags

The example is using NUMBER.

And even for someone like me, that link to the Configuration Descriptions was not helpful. I probably could have gotten down to that snippet of schema if I had gone to the code (maybe not?) but most users will read the first couple of lines of that page, think “this is for developers” and move on. That’s kind of what I did when trying to answer this question.

I can take a note to maybe come back and update the UI docs with the enumeration of what’s allowed because I don’t think the Configuration Descriptions page is suitable for average users.

Yup… oops.

Fair point… my (admittedlty technical) point was - this is serialized in the JSON DB as a ConfigDescriptionParameterDTO (openHAB Core 3.1.0-SNAPSHOT API) and the “type” field in this case is not a regular String but a ConfigDescriptionParameter.Type (openHAB Core 3.1.0-SNAPSHOT API) therefore if you fall out of these enumeration values, it will not be persisted correctly so you will lose data.

1 Like

Thank you @ysc and @rlkoshak
This solved the problem.