From 8dc36eb8f6e7a037b372c9c0e7a7f12b157a0133 Mon Sep 17 00:00:00 2001 From: jackchi Date: Thu, 18 Aug 2016 14:51:43 -0700 Subject: [PATCH] [CHF-201] [CHF-206] Health Check Core Devices --- .../aeon-multisensor-6.groovy | 4 --- .../aeon-multisensor-gen5.groovy | 3 -- .../aeon-multisensor.groovy | 4 --- .../cree-bulb.src/cree-bulb.groovy | 23 +++++++++++++++ .../smartpower-outlet.groovy | 25 ++++++++--------- .../smartsense-moisture-sensor.groovy | 24 +++++++++++++++- .../smartsense-motion-sensor.groovy | 24 +++++++++++++++- .../smartsense-multi-sensor.groovy | 28 +++++++++++++++++-- .../smartsense-open-closed-sensor.groovy | 24 +++++++++++++++- .../smartsense-temp-humidity-sensor.groovy | 23 ++++++++++++++- 10 files changed, 151 insertions(+), 31 deletions(-) diff --git a/devicetypes/smartthings/aeon-multisensor-6.src/aeon-multisensor-6.groovy b/devicetypes/smartthings/aeon-multisensor-6.src/aeon-multisensor-6.groovy index 7ff06b6..4b194db 100644 --- a/devicetypes/smartthings/aeon-multisensor-6.src/aeon-multisensor-6.groovy +++ b/devicetypes/smartthings/aeon-multisensor-6.src/aeon-multisensor-6.groovy @@ -22,7 +22,6 @@ metadata { capability "Configuration" capability "Sensor" capability "Battery" - capability "Health Check" attribute "tamper", "enum", ["detected", "clear"] attribute "batteryStatus", "string" @@ -328,9 +327,6 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) { } def configure() { - // allow device user configured or default 16 min to check in; double the periodic reporting interval - sendEvent(name: "checkInterval", value: 2* (timeOptionValueMap[reportInterval] ?: (2*8*60)), displayed: false) - // This sensor joins as a secure device if you double-click the button to include it log.debug "${device.displayName} is configuring its settings" def request = [] diff --git a/devicetypes/smartthings/aeon-multisensor-gen5.src/aeon-multisensor-gen5.groovy b/devicetypes/smartthings/aeon-multisensor-gen5.src/aeon-multisensor-gen5.groovy index 8cc44a9..04888d3 100644 --- a/devicetypes/smartthings/aeon-multisensor-gen5.src/aeon-multisensor-gen5.groovy +++ b/devicetypes/smartthings/aeon-multisensor-gen5.src/aeon-multisensor-gen5.groovy @@ -20,7 +20,6 @@ metadata { capability "Configuration" capability "Sensor" capability "Battery" - capability "Health Check" command "configureAfterSecure" @@ -248,8 +247,6 @@ def configureAfterSecure() { def configure() { // log.debug "configure()" //["delay 30000"] + secure(zwave.securityV1.securityCommandsSupportedGet()) - // allow device 16 min to check in; double the periodic reporting interval - sendEvent(name: "checkInterval", value: 2*8*60, displayed: false) } private setConfigured() { diff --git a/devicetypes/smartthings/aeon-multisensor.src/aeon-multisensor.groovy b/devicetypes/smartthings/aeon-multisensor.src/aeon-multisensor.groovy index 9a6b164..5d6de58 100644 --- a/devicetypes/smartthings/aeon-multisensor.src/aeon-multisensor.groovy +++ b/devicetypes/smartthings/aeon-multisensor.src/aeon-multisensor.groovy @@ -20,7 +20,6 @@ metadata { capability "Illuminance Measurement" capability "Sensor" capability "Battery" - capability "Health Check" fingerprint deviceId: "0x2001", inClusters: "0x30,0x31,0x80,0x84,0x70,0x85,0x72,0x86" } @@ -181,9 +180,6 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) { } def configure() { - // allow device 10 min to check in; double the periodic reporting interval - sendEvent(name: "checkInterval", value: 2*5*60, displayed: false) - delayBetween([ // send binary sensor report instead of basic set for motion zwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: 2).format(), diff --git a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy index 70548b0..ed5e751 100644 --- a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy +++ b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy @@ -23,6 +23,7 @@ metadata { capability "Refresh" capability "Switch" capability "Switch Level" + capability "Health Check" fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,1000", outClusters: "0000,0019" } @@ -66,6 +67,12 @@ def parse(String description) { def resultMap = zigbee.getEvent(description) if (resultMap) { sendEvent(resultMap) + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() } else { log.debug "DID NOT PARSE MESSAGE for description : $description" @@ -85,6 +92,21 @@ def setLevel(value) { zigbee.setLevel(value) + ["delay 500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.levelRefresh() + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig() + zigbee.levelConfig() } @@ -95,5 +117,6 @@ def poll() { def configure() { log.debug "Configuring Reporting and Bindings." + sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"]) zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() } diff --git a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy index 4a71834..b978cc0 100644 --- a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy +++ b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy @@ -102,11 +102,11 @@ def parse(String description) { def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off' sendEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true) // Temporary fix for the case when Device is OFFLINE and is connected again - if (state.lastOnOff == null){ - state.lastOnOff = now() - sendEvent(name: "deviceWatch-lastActivity", value: state.lastOnOff, description: "Last Activity is on ${new Date(state.lastOnOff)}", displayed: false, isStateChange: true) + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) } - state.lastOnOff = now() + state.lastActivity = now() } } else { @@ -123,18 +123,17 @@ def on() { zigbee.on() } /** - * PING is used by Device-Watch in attempt to reach the Outlet + * PING is used by Device-Watch in attempt to reach the Device * */ def ping() { - // send read attribute onOFF if the last time we heard from the outlet is outside of the checkInterval - if (state.lastOnOff < (now() - (1000 * device.currentValue("checkInterval"))) ){ - log.info "ping, alive=no, lastOnOff=${new Date(state.lastOnOff)}" - state.lastOnOff = null + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null return zigbee.onOffRefresh() - } else { // if the last onOff activity is within the checkInterval we artificially create a Device-Watch event - log.info "ping, alive=yes, lastOnOff=${new Date(state.lastOnOff)}" - sendEvent(name: "deviceWatch-lastActivity", value: state.lastOnOff, description: "Last Activity is on ${new Date(state.lastOnOff)}", displayed: false, isStateChange: true) + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) } } @@ -143,7 +142,7 @@ def refresh() { } def configure() { - sendEvent(name: "checkInterval", value: 1200, displayed: false) + sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"]) zigbee.onOffConfig() + powerConfig() + refresh() } diff --git a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy index 26ff46f..746787c 100644 --- a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy +++ b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy @@ -101,6 +101,13 @@ def parse(String description) { map = parseIasMessage(description) } + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() + log.debug "Parse returned $map" def result = map ? createEvent(map) : null @@ -271,6 +278,21 @@ private Map getMoistureResult(value) { ] } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { log.debug "Refreshing Temperature and Battery" def refreshCmds = [ @@ -282,7 +304,7 @@ def refresh() { } def configure() { - sendEvent(name: "checkInterval", value: 7200, displayed: false) + sendEvent(name: "checkInterval", value: 7200, displayed: false, data: [protocol: "zigbee"]) String zigbeeEui = swapEndianHex(device.hub.zigbeeEui) log.debug "Configuring Reporting, IAS CIE, and Bindings." diff --git a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy index 1ee8143..1dab182 100644 --- a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy +++ b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy @@ -105,6 +105,13 @@ def parse(String description) { map = parseIasMessage(description) } + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() + log.debug "Parse returned $map" def result = map ? createEvent(map) : null @@ -282,6 +289,21 @@ private Map getMotionResult(value) { ] } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { log.debug "refresh called" def refreshCmds = [ @@ -293,7 +315,7 @@ def refresh() { } def configure() { - sendEvent(name: "checkInterval", value: 7200, displayed: false) + sendEvent(name: "checkInterval", value: 7200, displayed: false, data: [protocol: "zigbee"]) String zigbeeEui = swapEndianHex(device.hub.zigbeeEui) log.debug "Configuring Reporting, IAS CIE, and Bindings." diff --git a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy index 9bb6d2b..72973e5 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -127,6 +127,13 @@ def parse(String description) { map = parseIasMessage(description) } + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() + def result = map ? createEvent(map) : null if (description?.startsWith('enroll request')) { @@ -228,9 +235,9 @@ private Map parseIasMessage(String description) { ZoneStatus zs = zigbee.parseZoneStatus(description) Map resultMap = [:] - if(garageSensor != "Yes") { + if (garageSensor != "Yes"){ resultMap = zs.isAlarm1Set() ? getContactResult('open') : getContactResult('closed') - } + } return resultMap } @@ -364,6 +371,21 @@ private getAccelerationResult(numValue) { ] } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { log.debug "Refreshing Values " @@ -391,7 +413,7 @@ def refresh() { } def configure() { - sendEvent(name: "checkInterval", value: 7200, displayed: false) + sendEvent(name: "checkInterval", value: 7200, displayed: false, data: [protocol: "zigbee"]) log.debug "Configuring Reporting" diff --git a/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy b/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy index 8133463..90fb06b 100644 --- a/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy +++ b/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy @@ -92,6 +92,13 @@ def parse(String description) { map = parseIasMessage(description) } + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() + log.debug "Parse returned $map" def result = map ? createEvent(map) : null @@ -234,6 +241,21 @@ private Map getContactResult(value) { ] } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { log.debug "Refreshing Temperature and Battery" def refreshCmds = [ @@ -245,7 +267,7 @@ def refresh() { } def configure() { - sendEvent(name: "checkInterval", value: 7200, displayed: false) + sendEvent(name: "checkInterval", value: 7200, displayed: false, data: [protocol: "zigbee"]) String zigbeeEui = swapEndianHex(device.hub.zigbeeEui) log.debug "Configuring Reporting, IAS CIE, and Bindings." diff --git a/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy b/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy index e06dc78..70bf317 100644 --- a/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy +++ b/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy @@ -83,6 +83,13 @@ def parse(String description) { map = parseCustomMessage(description) } + // Temporary fix for the case when Device is OFFLINE and is connected again + if (state.lastActivity == null){ + state.lastActivity = now() + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } + state.lastActivity = now() + log.debug "Parse returned $map" return map ? createEvent(map) : null } @@ -239,6 +246,20 @@ private Map getHumidityResult(value) { ] } +/** + * PING is used by Device-Watch in attempt to reach the Device + * */ +def ping() { + if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){ + log.info "ping, alive=no, lastActivity=${state.lastActivity}" + state.lastActivity = null + return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level + } else { + log.info "ping, alive=yes, lastActivity=${state.lastActivity}" + sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true) + } +} + def refresh() { log.debug "refresh temperature, humidity, and battery" @@ -254,7 +275,7 @@ def refresh() } def configure() { - sendEvent(name: "checkInterval", value: 7200, displayed: false) + sendEvent(name: "checkInterval", value: 7200, displayed: false, data: [protocol: "zigbee"]) log.debug "Configuring Reporting and Bindings." def configCmds = [