I was looking for some time for a description of parameterGroups: in connection with widgets and their props. Somehow I had expected that you could do something with it in connection with iterations. But it seems that you can only use it to structure the set widget props.
While searching, I found some possibilities for parameters:, but no coherent documentation with examples. So here are the possibilities I found.
parameters:
- name
- label
- description
- required
- default
- type
- context
- pattern
- options
- limitToOptions
- readOnly
- groupName
- multiple
Still unclear to me are
- unit
- context (except item)
- unitLabel
- criteria
name
This is the identifier under which the element is then available in the widget. No spaces may appear in the name, for example.
label
The text can be read at the top of the input field. HTML elements are not analysed here.
description
The description appears below the input field. It may also contain simple HTML tags, even a link is permitted.
required
- true
- false
This field is used to specify whether an entry must be made or not, default is false.
default
Even if defaultValue appears from time to time in the forums, in the current versions the identifier is default. This allows me to specify a value that is always valid if no entry has been made in the input field. This only makes sense if required is set to false. Specifying a default value makes some case distinctions superfluous.
OpenHAB has a small problem here with the BOOLEAN type. It turns
default: true
when saving and reloading
default: "true"
and this is not a Boolean value. However, the default value set by OpenHAB is true, so that this specification can or must be omitted.
type
This field always appears, which suggests that there are several values here. However, I have only been able to find two so far:
- TEXT
- BOOLEAN
- INTEGER
- DECIMAL
If possible, do not link the BOOLEAN type with a default value, see above.
For number types, there are also the parameters
- min (Decimal)
- max (Decimal)
- step (decimal)
context
Here, too, one could assume that there are several possible values (see below), but I only know examples with:
item
This setting is used to include an element from the list of items
pattern
I can use this element to specify a list of possible values. Only exactly these values can then be typed in. Error messages may be generated during input. The value list is entered in the form
pattern: green|red|yellow|orange
options
This is a nicer way of specifying values. The possible values are specified, as is usual with HTML forms, via pairs of value/label
- value:
- label:
limitToOptions
- true
- false
This element only makes sense in connection with options. If the value is set to false (default), free text input is still possible. If the value is set to true, then only a selection from the defaults is possible. The value also influences the display during input.
readOnly
- true
- false
The value cannot be changed in the form, the current value is only displayed.
groupName
Here you can specify which element group (parameterGroups) the entry should belong to. Elements of the same group are kept together in the input mask.
multiple
- true
- false
This makes sense in connection with items.
parameters:
- name: test
label: Test
description: Only one test
context: item
required: false
type: TEXT
multiple: true
leads to an input window with a list of all items from which I can select several elements. I still have to try out how I can then use the resulting list.
parameterGroups:
Used to group input parameters and offers the option of providing additional descriptions for the respective group.
- name
- label
- description
The description of the respective elements corresponds to that of the parameters.
Example
The following listing is based on my animation listing and is adapted so that I can show some elements.
uid: ud_widget_props_example
tags: []
props:
parameters:
- default: orange
description: Color of path must be <b>one of</b> - green, red, yellow, orange
label: Farbe des Pfades
name: pathcolor
required: false
type: TEXT
pattern: green|red|yellow|orange
- default: 1;0
description: Direction of animation
name: direction
required: false
type: TEXT
limitToOptions: true
options:
- label: forward
value: 0;1
- label: backwards
value: 1;0
- default: 8s
description: Duration of animation
label: Dauer der Animation
name: duration
required: false
type: TEXT
options:
- label: 1 second
value: 1s
- label: 4 seconds
value: 4s
- label: 8 seconds
value: 8s
- default: red
description: Color of circle
label: Farbe des Kreises
name: circlecolor
required: false
type: TEXT
limitToOptions: true
options:
- label: Grün
value: green
- label: Rot
value: red
- label: Gelb
value: yellow
- default: "6"
description: Radius of circle
label: Radius des Kreises
name: circleradius
required: false
type: INTEGER
min: 1
max: 8
- description: Circle visible
label: Kreis sichtbar
name: visibleCircle
required: false
type: BOOLEAN
parameterGroups: []
timestamp: Mar 29, 2024, 12:33:05 PM
component: f7-card
config:
footer: =props.duration+(props.direction=='0;1'?' forward':' backwards')
style:
border: 3px solid green
border-radius: 20px
height: auto
text-align: center
width: 200px
title: Watch animation!
slots:
content:
- component: svg
config:
style:
height: 110px
width: 200px
xmlns: http://www.w3.org/2000/svg
slots:
default:
- component: path
config:
d: M0,15 h20 q60,0 60,45 t60,45 h20
fill: none
id: examplepath
stroke: =props.pathcolor
stroke-width: 1
- component: circle
config:
fill: =props.circlecolor
r: =props.circleradius
visible: =props.visibleCircle
slots:
default:
- component: animateMotion
config:
dur: =props.duration
keyPoints: =props.direction
keyTimes: 0;1
repeatCount: indefinite
slots:
default:
- component: mpath
config:
xlink:href: "#examplepath"
The following window appears for the props:
You can see that the default values are entered here, but not the implicit default value for BOOLEAN.
For the duration specifications, I did without
limitToOptions: true
Therefore, the defaults only appear if you delete the input field, but free entries such as 32s are also possible.