From 730ccccd45718b817ff3565ad447d124c276b9bd Mon Sep 17 00:00:00 2001
From: "piyush.c"
Date: Wed, 28 Sep 2016 12:35:02 +0530
Subject: [PATCH] CHF-273 Updated Health Check capability implementation for
"Tyco-Door-Window-Sensor".
---
.../tyco-door-window-sensor.src/.st-ignore | 2 +
.../tyco-door-window-sensor.src/README.md | 42 +++++++++++++++++++
.../tyco-door-window-sensor.groovy | 33 +++++++--------
3 files changed, 60 insertions(+), 17 deletions(-)
create mode 100644 devicetypes/smartthings/tyco-door-window-sensor.src/.st-ignore
create mode 100644 devicetypes/smartthings/tyco-door-window-sensor.src/README.md
diff --git a/devicetypes/smartthings/tyco-door-window-sensor.src/.st-ignore b/devicetypes/smartthings/tyco-door-window-sensor.src/.st-ignore
new file mode 100644
index 0000000..f78b46e
--- /dev/null
+++ b/devicetypes/smartthings/tyco-door-window-sensor.src/.st-ignore
@@ -0,0 +1,2 @@
+.st-ignore
+README.md
diff --git a/devicetypes/smartthings/tyco-door-window-sensor.src/README.md b/devicetypes/smartthings/tyco-door-window-sensor.src/README.md
new file mode 100644
index 0000000..13d9ce1
--- /dev/null
+++ b/devicetypes/smartthings/tyco-door-window-sensor.src/README.md
@@ -0,0 +1,42 @@
+# Tyco Door Window Sensor
+
+
+
+Works with:
+
+* [Tyco Door Window Sensor](https://support.smartthings.com/hc/en-us/articles/204834100-Tyco-Door-Window-Sensor)
+
+## Table of contents
+
+* [Capabilities](#capabilities)
+* [Health](#device-health)
+* [Battery](#battery-specification)
+
+## Capabilities
+
+* **Battery** - defines device uses a battery
+* **Configuration** - _configure()_ command called when device is installed or device preferences updated
+* **Contact Sensor** - can detect contact (open/close)
+* **Refresh** - _refresh()_ command for status updates
+* **Temperature Measurement** - can measure the device temperature
+* **Health Check** - indicates ability to get device health notifications
+
+## Device Health
+
+Contact sensor with maxReportTime of 5 mins.
+Check-in interval is double the value of maxReportTime for Zigbee device.
+This gives the device twice the amount of time to respond before it is marked as offline.
+Check-in interval = 12 min
+
+## Battery Specification
+
+3V CR2032 battery is required.
+
+## Troubleshooting
+
+If the device doesn't pair when trying from the SmartThings mobile app, it is possible that either the sensor needs to be reseted or the sensor is out of range.
+Reset needs to be done by inserting the battery in the sensor and then quickly pressing the adjacent black button 10 times. Pairing should be tried again now.
+It may happen that sensor is out of range, then pairing needs to be tried again by placing the sensor closer to the hub.
+Instructions related to pairing, resetting and removing the different motion sensors from SmartThings can be found in the following links
+for the different models:
+* [Tyco Door Window Sensor (MCT-340)](https://support.smartthings.com/hc/en-us/articles/204834100-Tyco-Door-Window-Sensor)
diff --git a/devicetypes/smartthings/tyco-door-window-sensor.src/tyco-door-window-sensor.groovy b/devicetypes/smartthings/tyco-door-window-sensor.src/tyco-door-window-sensor.groovy
index e8f1e46..da6297a 100644
--- a/devicetypes/smartthings/tyco-door-window-sensor.src/tyco-door-window-sensor.groovy
+++ b/devicetypes/smartthings/tyco-door-window-sensor.src/tyco-door-window-sensor.groovy
@@ -16,12 +16,13 @@
import physicalgraph.zigbee.clusters.iaszone.ZoneStatus
metadata {
- definition (name: "Tyco Door/Window Sensor", namespace: "smartthings", author: "SmartThings") {
+ definition (name: "Tyco Door/Window Sensor", namespace: "smartthings", author: "SmartThings", category: "C2") {
capability "Battery"
capability "Configuration"
capability "Contact Sensor"
capability "Refresh"
capability "Temperature Measurement"
+ capability "Health Check"
command "enrollResponse"
@@ -229,44 +230,42 @@ private Map getContactResult(value) {
]
}
+/**
+ * PING is used by Device-Watch in attempt to reach the Device
+ * */
+def ping() {
+ return zigbee.readAttribute(0x0402, 0x0000) // Read the Temperature Cluster
+}
+
def refresh()
{
log.debug "Refreshing Temperature and Battery"
- [
+ def refreshCmds = [
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20"
]
+
+ return refreshCmds + enrollResponse()
}
def configure() {
+ // Device-Watch allows 2 check-in misses from device
+ sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
log.debug "Configuring Reporting, IAS CIE, and Bindings."
- def configCmds = [
+ def enrollCmds = [
"delay 1000",
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 1500",
- "zcl global send-me-a-report 1 0x20 0x20 600 3600 {01}", "delay 200",
- "send 0x${device.deviceNetworkId} 1 1", "delay 1500",
-
- "zcl global send-me-a-report 0x402 0 0x29 300 3600 {6400}", "delay 200",
- "send 0x${device.deviceNetworkId} 1 1", "delay 1500",
-
-
//"raw 0x500 {01 23 00 00 00}", "delay 200",
//"send 0x${device.deviceNetworkId} 1 1", "delay 1500",
-
-
- "zdo bind 0x${device.deviceNetworkId} 1 1 0x402 {${device.zigbeeId}} {}", "delay 500",
- "zdo bind 0x${device.deviceNetworkId} 1 1 1 {${device.zigbeeId}} {}",
-
- "delay 500"
]
- return configCmds + enrollResponse() + refresh() // send refresh cmds as part of config
+ return configCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
}
def enrollResponse() {