From a6cc506803b87692797dc6c0fc265617eb6dc547 Mon Sep 17 00:00:00 2001 From: jackchi Date: Tue, 11 Oct 2016 16:18:06 -0700 Subject: [PATCH 1/2] [CHF-417] Fix for onOffConfig older periodic values --- .../smartthings/smartpower-outlet.src/smartpower-outlet.groovy | 2 +- devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy | 2 +- .../smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy | 2 +- .../zigbee-white-color-temperature-bulb.groovy | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy index ec7cdad..2a46720 100644 --- a/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy +++ b/devicetypes/smartthings/smartpower-outlet.src/smartpower-outlet.groovy @@ -143,7 +143,7 @@ def refresh() { def configure() { // Device-Watch allows 3 check-in misses from device (plus 1 min lag time) // enrolls with default periodic reporting until newer 5 min interval is confirmed - sendEvent(name: "checkInterval", value: 3 * 60 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity zigbee.onOffConfig(0, 300) + powerConfig() + refresh() diff --git a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy index b0239e6..cb34038 100644 --- a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy +++ b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy @@ -104,7 +104,7 @@ def configure() { log.debug "Configuring Reporting and Bindings." // Device-Watch allows 3 check-in misses from device (plus 1 min lag time) // enrolls with default periodic reporting until newer 5 min interval is confirmed - sendEvent(name: "checkInterval", value: 3 * 60 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) // 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 ab1f76a..f0a15ad 100644 --- a/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy +++ b/devicetypes/smartthings/zigbee-rgbw-bulb.src/zigbee-rgbw-bulb.groovy @@ -145,7 +145,7 @@ def configure() { log.debug "Configuring Reporting and Bindings." // Device-Watch allows 3 check-in misses from device (plus 1 min lag time) // enrolls with default periodic reporting until newer 5 min interval is confirmed - sendEvent(name: "checkInterval", value: 3 * 60 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) // 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 8a210f2..01b6938 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 @@ -128,7 +128,7 @@ def configure() { log.debug "Configuring Reporting and Bindings." // Device-Watch allows 3 check-in misses from device (plus 1 min lag time) // enrolls with default periodic reporting until newer 5 min interval is confirmed - sendEvent(name: "checkInterval", value: 3 * 60 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) // 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 9a5d506668e6e2271e1fdbe71ade7e094eba4dde Mon Sep 17 00:00:00 2001 From: Lars Finander Date: Fri, 14 Oct 2016 16:18:51 -0600 Subject: [PATCH 2/2] DVCSMP-2131 Philips Hue: Handle case if bridge username becomes invalid --- .../hue-connect.src/hue-connect.groovy | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index d793cf4..d39d451 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -37,7 +37,10 @@ preferences { def mainPage() { def bridges = bridgesDiscovered() - if (state.username && bridges) { + + if (state.refreshUsernameNeeded) { + return bridgeLinking() + } else if (state.username && bridges) { return bulbDiscovery() } else { return bridgeDiscovery() @@ -102,13 +105,22 @@ def bridgeLinking() { def nextPage = "" def title = "Linking with your Hue" - def paragraphText + def paragraphText if (selectedHue) { + if (state.refreshUsernameNeeded) { + paragraphText = "The current Hue username is invalid.\n\nPlease press the button on your Hue Bridge to re-link. " + } else { paragraphText = "Press the button on your Hue Bridge to setup a link. " - } else { - paragraphText = "You haven't selected a Hue Bridge, please Press \"Done\" and select one before clicking next." - } + } + } else { + paragraphText = "You haven't selected a Hue Bridge, please Press \"Done\" and select one before clicking next." + } if (state.username) { //if discovery worked + if (state.refreshUsernameNeeded) { + state.refreshUsernameNeeded = false + // Issue one poll with new username to cancel local polling with old username + poll() + } nextPage = "bulbDiscovery" title = "Success!" paragraphText = "Linking to your hub was a success! Please click 'Next'!" @@ -915,8 +927,15 @@ private handleCommandResponse(body) { updates[childDeviceNetworkId]."$eventType" = v } } - } else if (payload.error) { - log.warn "Error returned from Hue bridge error = ${body?.error}" + } else if (payload?.error) { + log.warn "Error returned from Hue bridge, error = ${payload?.error}" + // Check for unauthorized user + if (payload?.error?.type?.value == 1) { + log.error "Hue username is not valid" + state.refreshUsernameNeeded = true + state.username = null + } + return [] } }