Cant get iconcolor to work

  • Platform information:
    • openHAB version: 4.2.2

Hi, since a few days runing OpenHabn using basicUI , but cant get iconcolor to work
If i use the classic icon “lightbulb”, when turning on/off light, i see it changing to yellow…

But i want to have iconify or material design icons, for some reason, i cant get it to work, as for test, the icon is always “blue”

the states are correct, the mappings also work; ponly icon color doesnt…

2024-10-26 16:04:36.970 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'licht_inkomhal' changed from OFF to ON
2024-10-26 16:04:39.029 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'licht_inkomhal' changed from ON to OFF

            Switch icon=if:mdi:lightbulb item=licht_inkomhal label="Inkomhal" mappings=[ON="Aan", OFF="Uit"] iconcolor=[ON="yellow", OFF="red", "blue"]

Wht am i missing?

also tried like
"ON"="yellow" instead of ON="yellow"

image

{
  "uid": "test",
  "component": "Sitemap",
  "config": {
    "label": "NewSitemap"
  },
  "slots": {
    "widgets": [
      {
        "component": "Switch",
        "config": {
          "item": "IconTest",
          "iconcolor": [
            "IconTest==ON=green",
            "IconTest==OFF=red",
            "blue"
          ]
        }
      }
    ]
  }
}

icon

1 Like

Aha, that’s something to try , gonna test tomorrow!!

Ok , now it’s working indeed, strange , it’s also documented that it should work without the itemname specified?

I will investigate. It is supposed to work without specifying the item. Maybe the presence of “mappings” is the cause.
Please try without mappings to confirm that only this case is concerned.

1 Like

I also tried without mappings, didn’t work either :frowning:

it seems for a rollershutter item i dont need to add item, it works like this:

only for lightbulb i need to add the item?

Please show how it defined your item.

Well on the switch I had to include the itemname…

This is not what I call the item definition.
Your item is defined in config file or in Main UI ?
Your sitemap was built using a config file or with Main UI ?

Hi, items are indeed created with main UI, also sitemap is with mainUI

Only the things are with code, they are mqtt

What I notice , if you look on code, the first one doesn’t work, the second one works, where I included the itemname…

Below is the json, I also use mappings, for the mappings it adds \ \ in the strings, while it doesn’t for the iconcolor…

Maybe that’s the issue?

As mentioned in the other topic, this is certainly a bug in sitemap generator (Main UI) only.

hey @sihui

what about rollershutter icon rukes? it works like below (for color), then no itemname is needed:

image

for icon rules, i cant get it to work? what am i missing here?, its always displaying the default icon, … the color works, its showing “red” , but icon is always “if:cbi:tilt-window-opened”

can you test it with code? i dont use the code now, maybe its a bug too, and i can stop testing …

created a new thread here, cant get icon color to work :frowning:

Please check your quotation marks, you have set them wrong!

I tried both , but it’s the same


What if you remove the blue ???

Then the color doesn’t change at all, it stays default white

If you look a few posts back, I have also mappings defined, in the code i see like ON="xx"

Maybe I need to include those backslash too in the code?