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:
Switch item=alarm_switch_node25_motion01 label="Allarm" mappings=[0=OFF, 1="Alert", 2="ARMED"]
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
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:
(those are taken from opehab.org)
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.
You can try defining bitmap as icon type in the configurations options of classicui:
It is discussed in the Necessary Changes section of the migration tutorial and in the icons section of the Items docs.
sorry to bring this topic back up but I don’t understand why my icon does stay black and doesn’t turn green when turn the switch on.
Switch alarm “Alarmanlage [MAP(alarm.map):%d]”
(I tried %s as well)
the default shield icon has 3 “states” shield (black), shield-0 (red) and shield-1 (green).
Please find all details regarding Icons in documentation (revised since this thread was last discussed):
Thx for your quick reply!
I read through the dynamic icon section already. MAP transformations are important.
I get confused with raw state vs transformed state.
Defauld Classic Icon names are shield, shield-0, shield-1, can’t change that.
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?
You need to provide:
These can be copies of the original in the folder