From 148e66ac54c9660399fb5981c528236e6b69fbce Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 11:52:03 -0700 Subject: [PATCH 1/2] ICP-12929 Standardize how Fibaro preference default text is created There was an existing pattern to to print the enum value of a preference rather than the raw enum, so I've just adopted it across all the fibaro DTHs that were using the incorrect method. --- .../fibaro-co-sensor-zw5.src/fibaro-co-sensor-zw5.groovy | 6 ++++-- .../fibaro-door-window-sensor-2.groovy | 7 ++++--- .../fibaro-double-switch-2-zw5.groovy | 5 +++-- .../fibaro-motion-sensor-zw5.groovy | 4 ++-- .../fibaro-single-switch-2-zw5.groovy | 5 +++-- .../fibaro-wall-plug-eu-zw5.groovy | 5 +++-- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/devicetypes/fibargroup/fibaro-co-sensor-zw5.src/fibaro-co-sensor-zw5.groovy b/devicetypes/fibargroup/fibaro-co-sensor-zw5.src/fibaro-co-sensor-zw5.groovy index 2ec083842e9..2c35cb117c8 100644 --- a/devicetypes/fibargroup/fibaro-co-sensor-zw5.src/fibaro-co-sensor-zw5.groovy +++ b/devicetypes/fibargroup/fibaro-co-sensor-zw5.src/fibaro-co-sensor-zw5.groovy @@ -67,7 +67,7 @@ metadata { } preferences { - parameterMap().findAll{(it.num as Integer) != 54}.each { + parameterMap().each { input ( title: "${it.num}. ${it.title}", description: it.descr, @@ -75,10 +75,12 @@ metadata { element: "paragraph" ) + def defVal = it.def as Integer + def descrDefVal = it.options ? it.options.get(defVal) : defVal input ( name: it.key, title: null, - description: "Default: $it.def" , + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, diff --git a/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy b/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy index 7bb49ba3728..323b09cf06e 100644 --- a/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy +++ b/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy @@ -89,18 +89,19 @@ metadata { required: false ) - parameterMap().findAll{(it.num as Integer) != 54}.each { + parameterMap().each { input ( title: "${it.num}. ${it.title}", description: it.descr, type: "paragraph", element: "paragraph" ) - + def defVal = it.def as Integer + def descrDefVal = it.options ? it.options.get(defVal) : defVal input ( name: it.key, title: null, - description: "Default: $it.def" , + description: "$DescrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, diff --git a/devicetypes/fibargroup/fibaro-double-switch-2-zw5.src/fibaro-double-switch-2-zw5.groovy b/devicetypes/fibargroup/fibaro-double-switch-2-zw5.src/fibaro-double-switch-2-zw5.groovy index d5b3550d8e8..01e563ef9b3 100644 --- a/devicetypes/fibargroup/fibaro-double-switch-2-zw5.src/fibaro-double-switch-2-zw5.groovy +++ b/devicetypes/fibargroup/fibaro-double-switch-2-zw5.src/fibaro-double-switch-2-zw5.groovy @@ -50,11 +50,12 @@ metadata { type: "paragraph", element: "paragraph" ) - + def defVal = it.def as Integer + def descrDefVal = it.options ? it.options.get(defVal) : defVal input ( name: it.key, title: null, - description: "Default: $it.def" , + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, diff --git a/devicetypes/fibargroup/fibaro-motion-sensor-zw5.src/fibaro-motion-sensor-zw5.groovy b/devicetypes/fibargroup/fibaro-motion-sensor-zw5.src/fibaro-motion-sensor-zw5.groovy index 5da49a3d6f9..2443d2f86cc 100644 --- a/devicetypes/fibargroup/fibaro-motion-sensor-zw5.src/fibaro-motion-sensor-zw5.groovy +++ b/devicetypes/fibargroup/fibaro-motion-sensor-zw5.src/fibaro-motion-sensor-zw5.groovy @@ -89,7 +89,7 @@ metadata { type: "paragraph", element: "paragraph" ) - parameterMap().findAll { (it.num as Integer) != 54 }.each { + parameterMap().each { input( title: "${it.num}. ${it.title}", description: it.descr, @@ -101,7 +101,7 @@ metadata { input( name: it.key, title: null, - description: "Default: $descrDefVal", + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, diff --git a/devicetypes/fibargroup/fibaro-single-switch-2-zw5.src/fibaro-single-switch-2-zw5.groovy b/devicetypes/fibargroup/fibaro-single-switch-2-zw5.src/fibaro-single-switch-2-zw5.groovy index f86701f6afe..6fdbc6262d5 100644 --- a/devicetypes/fibargroup/fibaro-single-switch-2-zw5.src/fibaro-single-switch-2-zw5.groovy +++ b/devicetypes/fibargroup/fibaro-single-switch-2-zw5.src/fibaro-single-switch-2-zw5.groovy @@ -52,11 +52,12 @@ metadata { type: "paragraph", element: "paragraph" ) - + def defVal = it.def as Integer + def descrDefVal = it.options ? it.options.get(defVal) : defVal input ( name: it.key, title: null, - description: "Default: $it.def" , + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, diff --git a/devicetypes/fibargroup/fibaro-wall-plug-eu-zw5.src/fibaro-wall-plug-eu-zw5.groovy b/devicetypes/fibargroup/fibaro-wall-plug-eu-zw5.src/fibaro-wall-plug-eu-zw5.groovy index 74896f194e9..2f425ade486 100644 --- a/devicetypes/fibargroup/fibaro-wall-plug-eu-zw5.src/fibaro-wall-plug-eu-zw5.groovy +++ b/devicetypes/fibargroup/fibaro-wall-plug-eu-zw5.src/fibaro-wall-plug-eu-zw5.groovy @@ -52,11 +52,12 @@ metadata { type: "paragraph", element: "paragraph" ) - + def defVal = it.def as Integer + def descrDefVal = it.options ? it.options.get(defVal) : defVal input ( name: it.key, title: null, - description: "Default: $it.def" , + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null, From 585f7f99e8c87fdf555ea7b699418307fce34f79 Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 11:57:10 -0700 Subject: [PATCH 2/2] fixup --- .../fibaro-door-window-sensor-2.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy b/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy index 323b09cf06e..d7d0ce0dfee 100644 --- a/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy +++ b/devicetypes/fibargroup/fibaro-door-window-sensor-2.src/fibaro-door-window-sensor-2.groovy @@ -101,7 +101,7 @@ metadata { input ( name: it.key, title: null, - description: "$DescrDefVal", + description: "$descrDefVal", type: it.type, options: it.options, range: (it.min != null && it.max != null) ? "${it.min}..${it.max}" : null,