Foreword
In the UI you can easily add metadata to Items.
This post is my notes on adding the same metadata in existing *.items files in order for the UI to do its magic.
State Description
Via the UI, the following options are available:
To populate these fields via configuration files (example values):
Number nTest "Test Number Item" {
stateDescription=""[
pattern="%d%%",
min="0",
max="100",
step="1",
options="1=Red, 2=Green, 3=Blue"
]
}
The pattern
field can also contain a transformation. Syntax is (example transform):
pattern="MAP(switch2online.map):%s"
Default Widgets
You can set the default widgets for standalone, list and cell presentation from the Item itself. Within configuration files, for example:
Number nTest "Test Number Item" {
stateDescription=""[
pattern="%d%%",
min="0",
max="100",
step="1",
options="1=Red, 2=Green, 3=Blue"
],
widget="oh-slider-card",
listWidget="oh-slider-item",
cellWidget="oh-slider-cell"
}
Available widgets and their names
Adjusting metadata of the widgets
Number nTest "Test Number Item" {
stateDescription=""[
pattern="%d%%",
min="0",
max="100",
step="1",
options="1=Red, 2=Green, 3=Blue"
],
widget="oh-slider-card",
listWidget="oh-slider-item"[
title="My title",
subtitle="My subtitle",
icon="oh:water"
],
cellWidget="oh-slider-cell"
}
General
You can use the UI to work out what the main metadata namespace is. For example, selecting Auto-Update from the list presents a page with this title:
Therefore autoupdate
is the namespace to use:
Number nTest "Test Number Item" {
stateDescription=""[
pattern="%d%%",
min="0",
max="100",
step="1",
options="1=Red, 2=Green, 3=Blue"
],
widget="oh-slider-card",
listWidget="oh-slider-item"[
title="My title",
subtitle="My subtitle",
icon="oh:water"
],
cellWidget="oh-slider-cell",
autoupdate="false"
}
You can then use the code tab to work out what the extra metadata options are. For example, to expand the Default List Item Widget click on it and start entering nonsense data in to the fields:
Then move to the code tab:
value: oh-slider-item
config:
icon: oh:water
title: My title
subtitle: My subtitle
min: 5
max: 20
step: 2
vertical: 0
label: true
scale: true
scaleSteps: 2
scaleSubSteps: 5
unit: DEG
Which would translate to:
Number nTest "Test Number Item" {
stateDescription=""[
pattern="%d%%",
min="0",
max="100",
step="1",
options="1=Red, 2=Green, 3=Blue"
],
widget="oh-slider-card",
listWidget="oh-slider-item"[
title="My title",
subtitle="My subtitle",
icon="oh:water",
min=5,
max=20,
step=2,
vertical=0,
label=true,
scale=true,
scaleSteps=2,
scaleSubSteps=5,
unit="DEG"
],
cellWidget="oh-slider-cell",
autoupdate="false"
}