Skip to content

Commit

Permalink
Remove any state description dependencies when fetching icon state
Browse files Browse the repository at this point in the history
When transmitting item state for fetching icons, we must not use state
formatting, but either use the plain numeric value or "<value> <unit>".

Fixes openhab#3606

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 committed Mar 11, 2024
1 parent bf596dd commit d5e8177
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@ internal fun String?.toOH2WidgetIconResource(
!useState || item == null -> null
// For NULL states, we send 'null' as state when fetching the icon (BasicUI set a predecent for doing so)
item.state == null -> "null"
// Number items need to use state formatted as per their state description
// Number items need to follow the format "<value>" or "<value> <unit>"
item.isOfTypeOrGroupType(Item.Type.Number) || item.isOfTypeOrGroupType(Item.Type.NumberWithDimension)-> {
item.state.asNumber?.toString(Locale.US)
item.state.asNumber?.let { numberState ->
val unitSuffix = numberState.unit?.let { " $it" } ?: ""
"${numberState.formatValue()}$unitSuffix"
}
}
item.isOfTypeOrGroupType(Item.Type.Color) -> when {
// Color sliders just use the brightness part of the color
Expand Down

0 comments on commit d5e8177

Please sign in to comment.