[SOLVED] Dynamic Icon with dash-character in raw state

  • Platform information:
    • Hardware: Raspberry Pi with OpenHABian
    • OS: Raspbian GNU/Linux 10 (buster)
    • Java Runtime Environment: openjdk version “1.8.0_222”
    • openHAB version: 2.4.0
  • Issue of the topic: Dynamic Icon with dash-character in raw state

Is it somehow possible to create dynamic icons when there’s a dash character in raw state?
I have devices which are presenting states like “AUTO-MODE” or “MANU-MODE”. I already tried to put in icon files named “device-auto-mode.svg” or “device-AUTO-MODE”. But OpenHAB always displays the default icon “device.svg”. What am I doing wrong? Or is it not possible?

Also all UIs (PaperUI, ClassicUI, BasicUI) don’t show the raw state of the channel. They always display something like a translation in my language (Auto-Modus, Manu-Modus) and I don’t know why.
I created a map file with content:

AUTO-MODE=Auto
MANU-MODE=Manu

The item is configured like this:

String  ModeLivingRoom  "Modus [MAP(transform.map):%s]" <device> (gHeatLivingRoom, gMode,)                             {channel="..."}

Sitemap is configured like this:

Selection item=ModeLivingRoom

Only if I configure it like this, tranformations are displayed:

Selection item=ModeLivingRoom mappings=["AUTO-MODE"=Auto, "MANU-MODE"=Manu]

Any help would be appriciated.

Thanks.

Not possible. It’s a limitation due to the way dynamic icons are served, the - dash character has special significance. Including it in icon filename or in string Item state breaks the method.

Some bindings can make default suggestions for the contents of selection boxes, because a binding may know about the device by discovery. The binding can provide different defaults for different locale/language.

If you look at your Item with REST API you will likely see the added data.

When you add your own maps and mappings etc. it should override those defaults.

If the binding is providing states that prevent dynamic icons from working, that could be considered a bug. Perhaps an underscore would be better.

1 Like

You could use some kind of proxy item. i have done this with my homeatic devices in some way

OK. I have found a solution which is working for me. I just created a dummy Item where I can change the states and a rule where it sends the command to the devices if the state is changed. Also when the state on the device changes the dummy Item is also changed.

Would you mind telling us what binding and device is involved here? I’m still thinking this could be avoided at source.

These are MAX! Devices by eq-3. I use them with homegear binding.