Switch state in Basic UI

Hello Community

I run Openhab 2.4 on a Raspbeerry 3 b+, everything is running without any Problems. There is just one annoying thing.
I configured some sonoff switches with paper UI and they work as expected, but on the sitemap in basic UI the switch state is shown on some switches and on some not.
Hers a screenshot from the channels.

Most of those channels are in one MQTT thing, an are On/Off switches.

Here the Sitemap code.

sitemap sonoff label=“Home” {

  Frame label=""{
       Switch item=Phone_Roli_Online label="Roli" icon="network" mappings=[OFF="Offline", ON="Online"] 
       Switch item=Phone_Christi_Online label="Christi" icon="network" mappings=[OFF="Offline", ON="Online"]

  Frame label="Geschlossen"{
       Switch item=Ruhetag
       Switch item=Sperrstunde
       Switch item=Earlyclose

  Frame label="Lichtschalter" {
       Switch item=Licht_Eingang label="Eingang"
       Switch item=Licht_Fassade label="Fassade"
       Switch item=Licht_Parkplatz label="Parkplatz"
       Switch item=Licht_Garten label="Garten"
       Switch item=Licht_Stiegenhaus label="Stiegenhaus"
       Switch item=Licht_Vorhaus label="Vorhaus"


  Frame label="Licht" {
       Switch item=Licht_Eingang_LED label="Eingang LED"
       Switch item=Licht_Windfang label="Windfang"
       Switch item=Licht_Eingang_Aussen label="Eingang"
       Switch item=Tageslicht
       Switch item=Licht_Vorhaus_1 label="Vorhaus 1"
       Switch item=Licht_Vorhaus_2 label="Vorhaus 2"

  Frame label="Garage" {
       Switch item=Sonoff_Garage2 icon="garagedoor"
       Switch item=Sonoff_Garage3 icon="garagedoor"
       Switch item=Sonoff_Garage4 icon="garagedoor"


And here the screenshot from the sitemap in Basic UI.

Has anybody a idea how this comes?


Some of your sitemap lines have labels, some don’t. Where you have a label, add a formatter to it, [ ]. Example-

Switch item=Licht_Eingang label="Eingang [%s]"

Sitemap lines with no label given will instead use the label provided in the Item definition. Again, add format [ ] to the label of the Item.

Note that a switch may also be in a state NULL or UNDEF, whivh usually displays as -

1 Like

It works with the formatter, but at the garage items are no labels, 2 show the state and one not.
That means i should use labels on all items even if i don´t need?

That’s up to you. I think perhaps you’ve missed that each Item has it’s own label. Most people set those up and don’t have a label in the sitemap.

I know that each item has its own label, thats why i didn`t set them up in the sitemap for the garage items, u can see the item labels in my last screenshot. The state is also not NULL or UNDEF, it just dont show the state.

I know how to work around, but it would be interresting how it comes, becaus those 3 items should have the same behavior.

May we see those three Items. like you showed us the channels?


Okay, so none of those Item labels have [format]. To determine, you’d edit label value to Garage 1 [%s] etc.

Which leaves why they show differently by default. PaperUI seems inconsistent about how it shows Items that are defined in files. I get to see some of mine, but not all; but of course they are uneditable being file-based. I guess all yours are created in PaperUI - and you’re sure there are no duplicates in xxx.items files.

I suspect bindings can provide some kind of default format too, but all all your Items seem to b similar bindings, so I’d rule that out.

All items are created in Paper UI, there are no duplicates, checked more than 2 times, and all items are the same binding, MQTT binding.
Ill format the labels to get the reqired result. One day ill figure it out, and it will be like, OH thats why.

Thanks for your time.

1 Like

I think this area has changed. In the past if you had no [ format ] you got nothing. Now there seems to be some kind of defaulting at work, but not reliably.