openhab-core icon indicating copy to clipboard operation
openhab-core copied to clipboard

Enhance icon number state matching rule to work with values outside 0-100 range

Open mclassen2 opened this issue 2 years ago • 3 comments

I noticed using icon with different icon is max 100 won`t pickup different icon over 100 for Number items i have name-200.svg or name-200.png will not pick up on home.sitemap 100 or under is fine please fix to support to great 100 for icon coustom thank you

mclassen2 avatar Aug 14 '23 00:08 mclassen2

did more testing with my icon custom it only work same number as nameicon-200.svg it will not work if for exmaple 199 or 201 won`t work will show nameicon.svg instead of nameicon-100.svg or nameicon-200.svg i believe there buggy

mclassen2 avatar Aug 14 '23 00:08 mclassen2

The implementation isn't that smart and currently uses a loop:

https://github.com/openhab/openhab-core/blob/c12067a63bf053ff1d71b632ef0ab36c9c1a9faf/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java#L92-L100

It is probably limited to 0-100 and not any value to reduce CPU load. Perhaps it can evaluate the options based on the available resources instead of brute force iterating over every value.

It would also be nice when it works with negative values.

The current limitation is also stated in the docs:

Number State Matching Rule: For Number Items the equal or next lowest state icon that can be found will be used. The default icon will be used for negative numbers, or above 100 i.e. the available filename range is icon-0 to icon-99 only. Dimmer type Items work in the same way, being limited to 0-100 anyway.

wborn avatar Aug 14 '23 07:08 wborn

For sitemap UIs at least, #3820 will allow you defining rules to match states to icons.

lolodomo avatar Oct 07 '23 15:10 lolodomo