Skip to content

Commit

Permalink
Parse float as brightness
Browse files Browse the repository at this point in the history
Similar to openhab#3490, but also for brightness in floats, e.g. `23.0`.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma committed Dec 11, 2023
1 parent 132cb10 commit 4b5c0bb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ data class ParsedState internal constructor(
// fall through
}
}
val stateAsInt = state.toIntOrNull()
if (stateAsInt in 0..100) {
return stateAsInt
val stateAsFloat = state.toFloatOrNull() ?: return null
if (stateAsFloat in 0f .. 100f) {
return stateAsFloat.toInt()
}
return null
}
Expand Down

0 comments on commit 4b5c0bb

Please sign in to comment.