Remove trailing commas and spaces from entity_id for button widgets (#2314)

This commit is contained in:
Patrick Decat 2022-02-26 23:17:27 +01:00 committed by GitHub
parent abadab61a7
commit 1736efc82e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -402,8 +402,14 @@ class ButtonWidgetConfigureActivity : BaseActivity(), IconDialog.Callback {
// Analyze and send service data
val serviceDataMap = HashMap<String, Any>()
dynamicFields.forEach {
if (it.value != null) {
serviceDataMap[it.field] = it.value!!
var value = it.value
if (value != null) {
if (it.field == "entity_id" && value is String) {
// Remove trailing commas and spaces
val trailingRegex = "[, ]+$".toRegex()
value = value.replace(trailingRegex, "")
}
serviceDataMap[it.field] = value
}
}