Skip to content

Commit 0987df4

Browse files
JosarConfectrician
authored andcommitted
items.md: override labels (openhab#738)
* items.md: override labels Added information about how to override label text and state representation on sitemaps. Signed-off-by: Josua Arndt <josuaarndt@live.de> * Typos * Add item override example Signed-off-by: Josua Arndt <josuaarndt@live.de> * Added UoM link Signed-off-by: Josua Arndt <josuaarndt@live.de> * Update code fences and example comments Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
1 parent cb42e0a commit 0987df4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

configuration/items.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ Graphical UIs will display the label text when the Item is included, e.g. in [Ba
208208
Some I/O services (e.g. the Amazon Alexa skill) also use the label to match an external voice command to an Item.
209209

210210
In textual configurations the label, in quotation marks, appears next to the optional state presentation field in square brackets (see below).
211-
The label for the Item in the following example is "Temperature":
211+
The label for the Item in the following example is "Temperature and the optional state representation is set to be displayed, e.g. as "23.9 °C":
212212

213213
```java
214214
Number Livingroom_Temperature "Temperature [%.1f °C]"
215215
```
216216

217+
Channel labels can be overwritten by Item definitions and Item labels can be overwritten in [Sitemaps]({{base}}/configuration/sitemaps.html#element-types).
218+
217219
{: #state}
218220
### State
219221

configuration/sitemaps.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,25 @@ This provides the flexibility to present Items in the way desired in your home a
152152
If no label or icon are specified in the Sitemap, then the label and/or icon you assigned to the Item will be displayed.
153153
Setting a value for `label` or `icon` of a Sitemap element will override the values defined for the linked Item.
154154

155+
It has to be considered that if the label defined in a Channel or an Item contains text and state, these representations have to be overwritten separately in the Sitemap.
156+
In the following example a Item which has a label and state defined is overwritten.
157+
158+
```java
159+
sitemap demo label="My home automation" {
160+
Frame label="Temperature" {
161+
// Overrides only the text, but will keep the state format from the Item definition
162+
Text item=Livingroom_Temperature label="Livingroom"
163+
// Overrides the text and hides any state representation.
164+
Text item=Livingroom_Temperature label="Livingroom []"
165+
// Overrides the text and state representation
166+
// and also changes the state unit to Fahrenheit
167+
// if the value of the item supports UoM (link below) the value will be transformed.
168+
Text item=Livingroom_Temperature label="Livingroom [%.2f °F]"
169+
}
170+
}
171+
```
172+
UoM = [Units of Measurment]({{base}}/concepts/units-of-measurement.html)
173+
155174
- Additional parameters such as `mappings` and `valuecolor` are described below.
156175

157176
### Element Type 'Frame'

0 commit comments

Comments
 (0)