Switch, adjust item label depending on current

Hello,
I have a KNX switch actor which can measure the electrical current.
Currently I have two items, a number item and the actual switch item:

Switch Steckdose_Outdoor_Terrasse "Steckdose Terrasse"            (gOutdoor) { knx="12/3/20+<13/3/20" }
Number Steckdose_Outdoor_Terrasse_Strom "Steckdose Strom [%d mA]"       (gOutdoor) { knx="<7.012:5/3/21" }

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.

Has anyone an Idea how to achieve this?

BR
Marco

Hello,

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:

Switch item=Flur_Deckenlicht visibility=[Flur_Deckenlicht_Unreach == OFF] icon="lamp_globe_light"
Text   item=Flur_Deckenlicht visibility=[Flur_Deckenlicht_Unreach != OFF] icon="error2" label="Flur Deckenlicht [N/A ✘]"

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:

It was the first step and taken from the demo sitemap after a fresh installation.

I’ll replace the groups where I need better control of the Layout.

I like your Grafana graphs. But you cannot have them interactively where you can zoom in and out with the mouse, can you?

yes you can but it’s not in the example yet.

See: InfluxDB+Grafana persistence and graphing --> “…as dynamic ‘Webview’ Element with JavaScript library”

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.


Behaviour is a bit quirky

Oha :zipper_mouth_face: learn something new everyday… I did not know that and actually thought the option is not available by design.

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?

Hi @marco_hoefle,

Did you manage to get the label updated without the need to refresh the browser?
I’m having the same issue at the moment.

Thanks!

Hello Frederic,
didnt work reliable, I switched to the “visibility” method without showing dynamic values.
BR
Marco

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.