From f95e906d6e4c0510ace7eef215b6d2197679b8d8 Mon Sep 17 00:00:00 2001 From: jackchi Date: Wed, 14 Sep 2016 13:46:54 -0700 Subject: [PATCH 1/2] [CHF-363] Set HealthCheck interval to 12 min --- .../smartthings/cree-bulb.src/cree-bulb.groovy | 12 +++++++----- .../smartthings/hue-bloom.src/hue-bloom.groovy | 2 +- devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy | 2 +- .../smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy | 2 +- .../hue-white-ambiance-bulb.groovy | 2 +- .../smartpower-outlet.src/smartpower-outlet.groovy | 4 ++-- .../smartsense-moisture-sensor.groovy | 4 ++-- .../smartsense-motion-sensor.groovy | 4 ++-- .../smartsense-multi-sensor.groovy | 4 ++-- .../smartsense-open-closed-sensor.groovy | 4 ++-- .../smartsense-temp-humidity-sensor.groovy | 4 ++-- .../zigbee-dimmer.src/zigbee-dimmer.groovy | 4 ++-- .../zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy | 4 ++-- .../zigbee-white-color-temperature-bulb.groovy | 4 ++-- 14 files changed, 29 insertions(+), 27 deletions(-) diff --git a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy index f956800..0c9214d 100644 --- a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy +++ b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy @@ -19,7 +19,6 @@ metadata { capability "Actuator" capability "Configuration" - capability "Polling" capability "Refresh" capability "Switch" capability "Switch Level" @@ -97,14 +96,17 @@ def refresh() { zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig() + zigbee.levelConfig() } -def poll() { - zigbee.onOffRefresh() + zigbee.levelRefresh() +def healthPoll() { + def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh() + cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it))} } def configure() { + unschedule() + schedule("0 0/5 * * * ? *", "healthPoll") log.debug "Configuring Reporting and Bindings." - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) // minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() } diff --git a/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy b/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy index ff4405a..cd5171e 100644 --- a/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy +++ b/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy @@ -57,7 +57,7 @@ metadata { } void installed() { - sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false) + sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false) } // parse events into attributes diff --git a/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy b/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy index 6642672..d963d06 100644 --- a/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy +++ b/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy @@ -66,7 +66,7 @@ metadata { } void installed() { - sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false) + sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false) } // parse events into attributes diff --git a/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy b/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy index 4d8bfbb..ab658fd 100644 --- a/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy +++ b/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy @@ -50,7 +50,7 @@ metadata { } void installed() { - sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false) + sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false) } // parse events into attributes diff --git a/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy b/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy index b24b1dd..1d0cd38 100644 --- a/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy +++ b/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy @@ -55,7 +55,7 @@ metadata { } void installed() { - sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false) + sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false) } // parse events into attributes diff --git a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy index f4e6e0d..878bc9d 100644 --- a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy +++ b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy @@ -128,8 +128,8 @@ def refresh() { } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + 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 415fd73..1cce229 100644 --- a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy +++ b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy @@ -292,8 +292,8 @@ def refresh() { } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, 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 1a7ecec..d8f3e7a 100644 --- a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy +++ b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy @@ -303,8 +303,8 @@ def refresh() { } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, 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 6ce4044..36e081f 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -401,8 +401,8 @@ def refresh() { } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, 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 7d9c4c9..298247f 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 @@ -255,8 +255,8 @@ def refresh() { } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, 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 96b56e5..e32b18a 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 @@ -264,8 +264,8 @@ def refresh() } def configure() { - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) log.debug "Configuring Reporting and Bindings." def humidityConfigCmds = [ diff --git a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy index b977c8b..b22c2ef 100644 --- a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy +++ b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy @@ -89,8 +89,8 @@ def refresh() { def configure() { log.debug "Configuring Reporting and Bindings." - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() } diff --git a/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy b/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy index 367e480..d42cd8a 100644 --- a/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy +++ b/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy @@ -133,8 +133,8 @@ def refresh() { def configure() { log.debug "Configuring Reporting and Bindings." - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, 0x20, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, 0x20, 1, 3600, 0x01) + zigbee.readAttribute(0x0006, 0x00) + zigbee.readAttribute(0x0008, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) } diff --git a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy index 5a37fab..bcbfe7c 100644 --- a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy +++ b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy @@ -113,8 +113,8 @@ def refresh() { def configure() { log.debug "Configuring Reporting and Bindings." - // Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min - sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"]) + // Device-Watch allows 2 check-in misses from device + sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() } From c1478d3e96e75a253980e72f8986737b16af10c8 Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Sat, 17 Sep 2016 12:47:51 -0500 Subject: [PATCH 2/2] hue: fix HTTP request headers Previously, the whitespace characters from the file were used for newlines in HTTP headers. In order for the HTTP headers sent to the hue to be valid, line separators must always be \r\n. Oddly, the hue seemed to accept and respond to requests with the invalid header that was being sent but it would cause increased latency for all other API clients. In addition to the missing carriage returns, the GET request was also missing the required blank line which marks the end of the request headers. https://smartthings.atlassian.net/browse/PROB-1366 http://status.smartthings.com/incidents/13j8g8g2w7ly https://community.smartthings.com/t/new-hue-delay/57569 --- .../hue-connect.src/hue-connect.groovy | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index 8df8621..ccd0146 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -1175,9 +1175,8 @@ private poll() { def host = getBridgeIP() def uri = "/api/${state.username}/lights/" log.debug "GET: $host$uri" - sendHubCommand(new physicalgraph.device.HubAction("""GET ${uri} HTTP/1.1 -HOST: ${host} -""", physicalgraph.device.Protocol.LAN, selectedHue)) + sendHubCommand(new physicalgraph.device.HubAction("GET ${uri} HTTP/1.1\r\n" + + "HOST: ${host}\r\n\r\n", physicalgraph.device.Protocol.LAN, selectedHue)) } private isOnline(id) { @@ -1193,13 +1192,11 @@ private put(path, body) { log.debug "PUT: $host$uri" log.debug "BODY: ${bodyJSON}" - sendHubCommand(new physicalgraph.device.HubAction("""PUT $uri HTTP/1.1 -HOST: ${host} -Content-Length: ${length} - -${bodyJSON} -""", physicalgraph.device.Protocol.LAN, "${selectedHue}")) - + sendHubCommand(new physicalgraph.device.HubAction("PUT $uri HTTP/1.1\r\n" + + "HOST: ${host}\r\n" + + "Content-Length: ${length}\r\n" + + "\r\n" + + "${bodyJSON}", physicalgraph.device.Protocol.LAN, "${selectedHue}")) } /*