Instead of the static name “Steckdose Terrasse” I would prefer “Steckdose Terrasse, Strom: 2483 mA” to have one item less.
I still need the switch button though.
you can not change the label of an item dynamically. It’s a label and supposed to be constant.
That said, what you can do is display different sitemap elements depending on certain conditions. An example of how I use that feature is:
Adding the current current reading to your label is not possible but honestly also not meaningful. That part should go into the right part of a sitemap element. You will need to look for another solution.
Hello Thom,
thanks for your explanation that labels of Items cannot dynamically be changed.
Right now all items which are “draussen” are part of Group gOutdoor
Currently:
Frame label="Haus"
{
Group item=gEG label="Erdgeschoss" icon="groundfloor"
Group item=gOG label="Obergeschoss" icon="firstfloor"
Group item=gKG label="Keller" icon="cellar"
Group item=gOutdoor label="draussen" icon="garden"
}
When doing that with the visibility feature I suppose I cant use groups anymore and I have to do
something like
Frame label="Haus"
{
Group item=gEG label="Erdgeschoss" icon="groundfloor"
Group item=gOG label="Obergeschoss" icon="firstfloor"
Group item=gKG label="Keller" icon="cellar"
// Group item=gOutdoor label="draussen" icon="garden"
Text label="draussen" icon="garden"
{
Frame
{
Switch item=Steckdose_Outdoor_Terrasse
// Text item=Steckdose_Outdoor_Terrasse_Strom visibility=[Steckdose_Outdoor_Terrasse_Strom > 0]
Text item=Steckdose_Outdoor_Terrasse_Strom visibility=[Steckdose_Outdoor_Terrasse == ON]
}
}
}
Hmmm yes. In general I would not go with this design. It’s not really neat if you think about it. Maybe you can take some ideas from the list of best practices I’ve posted over here:
There is a way to set the value of the item.label string within a rule.
It doesn’t seem to be documented. It might be unsupported and go away in future releases.
Hello thanks for the hints.
I am almost there. I have this rule:
rule "rule-Steckdose-label"
when
Item Steckdose_Outdoor_Terrasse_Strom received update
then
var Number strom = (Steckdose_Outdoor_Terrasse_Strom.state as DecimalType)/1000.0;
var lab = (Math::round(strom.floatValue * 100.0)/100.0).toString
logInfo("Strom", lab)
Steckdose_Outdoor_Terrasse.label = "Steckdose Terrasse, Strom: " + lab + " A"
end
I need to refresh the browser window to see the updated label. However, the rule itself is triggered as the log is updated.
Is it the same for you?
Modifying the item label dynamically still does not work in basicui as of today. It does however work in the iOS app. It would be great if it could work in basicui also, since we can then make more compact designs where 2 items can become 1 in many instances.