Hello,
I’ve moved my setup from Openhab1 to Openhab2.
My dynamic icons are not working anymore.
I’ve tested changing the icon with the provided by the setup.
This is my item definition:
Number alarm_switch_node25_motion01 "Alarm Switch Motion" <shield>
The icon is static this one:
When I press the button on the sitemap, it changes the value:
alarm_switch_node25_motion01 changed from 1 to 0
OR
alarm_switch_node25_motion01 changed from 0 to 1
But the icon doesn’t change. It remains a black shield, even if I have those images as well in the same folder and I could open it via browser from my openhab server url:
Dynamic icons work a little different in OH2. The file name has to match the mapped definition, not the item definition. So in your case it’s alarm-off, alarm-alert, alarm-armed and alarm (the default).
There are some threads here which explain this deeper. But I can’t find them at the moment. I think @rlkoshak wrote something about that?!
I’ve tried to copy shield-alert.png, shield-armed.png, shield-off.png, shield.png, as well as shield-0.png, shield-1.png, shield-2.png into /etc/openhab2/icons/classic but nothing changes.
I’ve got it.
The name must be numeric, shield-0 shield-1 shield-2 and placed in icons/classic.
The problem is it works on basicui but NOT on classicui.
I have a switch whos raw states are “on” and “off”… not 0 and 1, right?
So I need a transformation to map on / off to 0 and 1 to match the icons state names?
That’s what I do with my alarm.map (off=0 on=1).
Doesn’t work with and doesn’t work without a transformation.
What am I missing?
edit: or can it be it’s not possible to use an icon with -0 and -1 in the name for a switch item?