From 0e9abb0cd2ab9ec2e5e7c2a3ba8bd284becb5ff0 Mon Sep 17 00:00:00 2001
From: "piyush.c"
Date: Mon, 27 Mar 2017 23:34:30 +0530
Subject: [PATCH] [CHF-558] Health Check ZigBee Switch
---
.../keen-home-smart-vent.src/README.md | 4 +--
.../smartthings/zigbee-switch.src/.st-ignore | 2 ++
.../smartthings/zigbee-switch.src/README.md | 35 +++++++++++++++++++
.../zigbee-switch.src/zigbee-switch.groovy | 10 ++++++
4 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 devicetypes/smartthings/zigbee-switch.src/.st-ignore
create mode 100644 devicetypes/smartthings/zigbee-switch.src/README.md
diff --git a/devicetypes/keen-home/keen-home-smart-vent.src/README.md b/devicetypes/keen-home/keen-home-smart-vent.src/README.md
index 808ca0a..355c2b2 100644
--- a/devicetypes/keen-home/keen-home-smart-vent.src/README.md
+++ b/devicetypes/keen-home/keen-home-smart-vent.src/README.md
@@ -25,10 +25,10 @@ Works with:
## Device Health
-Keen Home Smart Vent with reporting interval of 5 mins.
+Keen Home Smart Vent with reporting interval of 10 mins.
SmartThings platform will ping the device after `checkInterval` seconds of inactivity in last attempt to reach the device before marking it `OFFLINE`
-* __12min__ checkInterval
+* __22min__ checkInterval
## Troubleshooting
diff --git a/devicetypes/smartthings/zigbee-switch.src/.st-ignore b/devicetypes/smartthings/zigbee-switch.src/.st-ignore
new file mode 100644
index 0000000..f78b46e
--- /dev/null
+++ b/devicetypes/smartthings/zigbee-switch.src/.st-ignore
@@ -0,0 +1,2 @@
+.st-ignore
+README.md
diff --git a/devicetypes/smartthings/zigbee-switch.src/README.md b/devicetypes/smartthings/zigbee-switch.src/README.md
new file mode 100644
index 0000000..be8c067
--- /dev/null
+++ b/devicetypes/smartthings/zigbee-switch.src/README.md
@@ -0,0 +1,35 @@
+# Leviton Switch (ZigBee)
+
+Cloud Execution
+
+Works with:
+
+* [Leviton Switch (ZigBee)](https://www.smartthings.com/works-with-smartthings/leviton/leviton-switch)
+
+## Table of contents
+
+* [Capabilities](#capabilities)
+* [Health](#device-health)
+* [Troubleshooting](#Troubleshooting)
+
+## Capabilities
+
+* **Actuator** - represents that a Device has commands
+* **Configuration** - _configure()_ command called when device is installed or device preferences updated
+* **Refresh** - _refresh()_ command for status updates
+* **Switch** - can detect state (possible values: on/off)
+* **Health Check** - indicates ability to get device health notifications
+
+## Device Health
+
+A Zigbee Switch with reporting interval of 10 mins.
+SmartThings platform will ping the device after `checkInterval` seconds of inactivity in last attempt to reach the device before marking it `OFFLINE`
+
+* __22min__ checkInterval
+
+## Troubleshooting
+
+If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the device is out of range.
+Pairing needs to be tried again by placing the device closer to the hub.
+Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following link:
+* [Leviton Switch Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/209686003-How-to-connect-Leviton-ZigBee-devices)
diff --git a/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy b/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy
index 34192de..20637eb 100644
--- a/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy
+++ b/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy
@@ -18,6 +18,7 @@ metadata {
capability "Configuration"
capability "Refresh"
capability "Switch"
+ capability "Health Check"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
@@ -75,11 +76,20 @@ def on() {
zigbee.on()
}
+/**
+ * PING is used by Device-Watch in attempt to reach the Device
+ * */
+def ping() {
+ return refresh()
+}
+
def refresh() {
zigbee.onOffRefresh() + zigbee.onOffConfig()
}
def configure() {
+ // Device-Watch allows 2 check-in misses from device + ping (plus 2 min lag time)
+ sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
log.debug "Configuring Reporting and Bindings."
zigbee.onOffRefresh() + zigbee.onOffConfig()
}