iconUseState / dynamic icons only in some List Items / Standard Standalone Cards possible?

i’m working on a rollershutter widget and i’d like to display the position with a dynamic icon.


the icons are saved as .svg in the /classic/ folder.
this is working with

    - component: oh-list-item
        icon: oh:blinds
        iconUseState: true
        item: IconState

but i really don’t need a oh-list-item.
i took a look at the Component Reference | openHAB and it seems iconUseState is only viable for oh-colorpicker-item, oh-label-card, oh-label-item, oh-label-cell, oh-list-item, right?

is it really not possible to use dynamic icons with components like oh-button etc.?

For many components it doesn’t make sense to have the iconUseState property because they are not linked to an item. Sure, an oh-button can send a command to an item, but it is not holding or in any way tied to that item’s state.

Fortunately, in any of the cases where you can input the icon to use for a component, you can use an expression. Typically, for simple binary state changes this will just be something in the form of a simple ternary operation:

icon: "=(item.OfInterest.state == 'ON') ? 'oh:someIcon'  : 'oh:someOtherIcon'"

Your case with multiple states will require some nested conditions to get the full range of options.

but it wouldn’t hurt to implement this also for other components, would it? there’s probably a technical background why it’s not there.

yes, that’s how i didi it for now:

icon: "=(items[props.item + '_lm'].state > 89) ? 'blades_90_' : (items[props.item + '_lm'].state > 79) ? 'blades_80_' : (items[props.item + '_lm'].state > 69) ? 'blades_70_' : (items[props.item + '_lm'].state > 59) ? 'blades_60_' : (items[props.item + '_lm'].state > 49) ? 'blades_50_' : (items[props.item + '_lm'].state > 39) ? 'blades_40_' : (items[props.item + '_lm'].state > 29) ? 'blades_30_' : (items[props.item + '_lm'].state > 19) ? 'blades_20_' : (items[props.item + '_lm'].state > 9) ? 'blades_10_' : 'blades_00_' + themeOptions.dark "

edit: apparently i have to put the + themeOptions.dark after every option with the way i created it.
is it possible to just append it at the end?

thanks for the info Justin. again!