From 3a3c94d7f0ad3b9700f6aac0a56c04183dadbb13 Mon Sep 17 00:00:00 2001 From: rboy1 <3846367+rboy1@users.noreply.github.com> Date: Fri, 8 Nov 2019 14:52:52 -0500 Subject: [PATCH 1/3] Child contact sensor for multi component devices Device handlers for multi endpoint devices which have contact sensors endopints require child contact sensor DTH's. This generic child DTH serves the purpose and supports contact sensor, battery and health check. --- .../child-contact-sensor.groovy | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy diff --git a/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy new file mode 100644 index 00000000000..26bf833a699 --- /dev/null +++ b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy @@ -0,0 +1,61 @@ +/** + * Copyright 2018 SmartThings, RBoy Apps + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + * + */ +metadata { + definition(name: "Child Contact Sensor", namespace: "smartthings", author: "SmartThings", mnmn: "SmartThings", vid: "generic-contact", ocfDeviceType: "x.com.st.d.sensor.contact") { + capability "Contact Sensor" + capability "Sensor" + capability "Battery" + capability "Health Check" + } + + tiles(scale: 2) { + multiAttributeTile(name: "contact", type: "generic", width: 6, height: 4, canChangeIcon: true) { + tileAttribute("device.contact", key: "PRIMARY_CONTROL") { + attributeState("open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#e86d13") + attributeState("closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00A0DC") + } + } + valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { + state "battery", label: 'Battery: ${currentValue}%', unit: "" + } + + main "contact" + details(["contact", "battery"]) + } +} + +def installed() { + configure() +} + +def updated() { + configure() +} + +def configure() { + parent.configureChild() + refresh() +} + +def ping() { + refresh() +} + +def refresh() { + parent.refreshChild() +} + +def uninstalled() { + parent.deleteChild() +} From c8eae77053f704902cd289c17231781e70ea90a4 Mon Sep 17 00:00:00 2001 From: rboy1 <3846367+rboy1@users.noreply.github.com> Date: Tue, 12 Nov 2019 13:20:31 -0500 Subject: [PATCH 2/3] Removed battery not required for contact endpoints --- .../child-contact-sensor.src/child-contact-sensor.groovy | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy index 26bf833a699..82b27a1eb09 100644 --- a/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy +++ b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy @@ -15,7 +15,6 @@ metadata { definition(name: "Child Contact Sensor", namespace: "smartthings", author: "SmartThings", mnmn: "SmartThings", vid: "generic-contact", ocfDeviceType: "x.com.st.d.sensor.contact") { capability "Contact Sensor" capability "Sensor" - capability "Battery" capability "Health Check" } @@ -26,12 +25,9 @@ metadata { attributeState("closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00A0DC") } } - valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { - state "battery", label: 'Battery: ${currentValue}%', unit: "" - } main "contact" - details(["contact", "battery"]) + details(["contact"]) } } From 2f30fa4b82c846825c370e65c98f6d29208464dc Mon Sep 17 00:00:00 2001 From: rboy1 <3846367+rboy1@users.noreply.github.com> Date: Tue, 12 Nov 2019 15:35:51 -0500 Subject: [PATCH 3/3] Update date --- .../child-contact-sensor.src/child-contact-sensor.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy index 82b27a1eb09..df5502acdaa 100644 --- a/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy +++ b/devicetypes/smartthings/child-contact-sensor.src/child-contact-sensor.groovy @@ -1,5 +1,5 @@ /** - * Copyright 2018 SmartThings, RBoy Apps + * Copyright 2019 SmartThings, RBoy Apps * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at: