Item stateDescription and sitemaps? [FIXED]

openHAB version: 4.1.2

If I have stateDescription set for an item, should that work with sitemaps so it shows the current state of the item?
For me it don’t seem so. But if I add mappings to the sitemap it works.

Number House_Mode "Hus läge" <house> {stateDescription="" [options="0=Borta, 1=Hemma, 2=Sover"]}


sitemap test label="My home automation" {
        Switch item=House_Mode
        Switch item=House_Mode mappings=[0="Borta", 1="Hemma", 2="Sover"]

Please confirm using Basic UI.
I believe it should work.

Same issue in Basic UI.

Is it different if the item is of type String ?

I will debug your current use case.

With item type as String it works!

String House_Mode1 "Hus läge" <house> {stateDescription="" [options="0=Borta, 1=Hemma, 2=Sover"]}

sitemap test label="My home automation" {
        Switch item=House_Mode1
        Switch item=House_Mode1 mappings=[0="Borta", 1="Hemma", 2="Sover"]

I noticed that dynamic icon works with Switch item=House_Mode1 (but not with Switch item=House_Mode1 mappings=[0="Borta", 1="Hemma", 2="Sover"] )

In Basic UI there is no dynamic icon at all.

It would be nice if it works with item type Number, because then you can analyze the value over time with graphs.

You defined custom icons ?
Because I found only this one in the classic icon set:

How are named your custom icons ?

They must be named house-0 , house-1, house-2 and not house-Borta for example.
Should already work for your example with String item type and for your example with Number item type and mappings.

I found where is the issue. As the sitemap element is a Switch, the core framework converts the item state as an OnOffType (OFF if 0, ON if not). There is only one exception when the Switch sitemap element has mappings. In that case, the item state is returned unchanged and comparison with button value is succeeded. We should have a second exception when the item has state options.

When the item state is a StringType, the convert into OnOffType is failing and the state is returned unchanged. It explains why it works.

The line to change is this one:

I will prepare a fix.

Fix is now proposed:


Now when you ask I have to check, not sure.

Actually I must have added the old icons. These are the one I have with house*



Nice! Thanks for the help!

Even if I was already 99.9% sure, I checked the icon URL requested by Basic UI and I can confirm that state in URL is 0, 1 or 2, not depending on whether you set state options or not.

Fix is now merged and will be available in next snapshot tomorrow.

1 Like