mirror of
https://github.com/home-assistant/android
synced 2024-10-15 12:32:54 +00:00
Don't force on/yes/y/off/no/n to booleans for service button (#3858)
- Relax string conversion to boolean as this breaks other use cases.
This commit is contained in:
parent
fb1bdc05bb
commit
50a8b9eee2
|
@ -205,21 +205,9 @@ class WidgetDynamicFieldAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun String.toBooleanOrNull(): Boolean? {
|
||||
// Parse all valid YAML boolean values
|
||||
return when (this.trim().lowercase(Locale.getDefault())) {
|
||||
private fun String.toBooleanOrNull(): Boolean? = when (lowercase()) {
|
||||
"true" -> true
|
||||
"on" -> true
|
||||
"yes" -> true
|
||||
"y" -> true
|
||||
|
||||
"false" -> false
|
||||
"off" -> false
|
||||
"no" -> false
|
||||
"n" -> false
|
||||
|
||||
// If it's not a valid YAML boolean, return null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue