Skip to content

Commit

Permalink
Fix brightness parsing
Browse files Browse the repository at this point in the history
While debugging issues with color items I discovered that two SSE events
are sent when a slider with a color item is updated.

Item:
````
label: Debug Color 1
type: Color
category: oh:mdi:palette
groupNames: []
groupType: None
function: null
tags: []
````

Sitemap:
````
Slider item=D_Color iconcolor=["itemValue"]
````

The first event contains a state in the hsb format (`10,10,10`), the
second events contains the brightness only (`10`). Parsing an integer as
brightness failed and the slider was set to `0`.
IMO an integer in the range `0..100` can be considered as brightness.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma committed Oct 1, 2023
1 parent f4950e9 commit cfe2d21
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ data class ParsedState internal constructor(
// fall through
}
}
val stateAsInt = state.toIntOrNull()
if (stateAsInt in 0..100) {
return stateAsInt
}
return null
}

Expand Down

0 comments on commit cfe2d21

Please sign in to comment.