From 5e48e710d4da3c15e0fc03d11b17c3484a09647d Mon Sep 17 00:00:00 2001 From: Lars Finander Date: Mon, 24 Oct 2016 14:44:08 -0600 Subject: [PATCH] DVCSMP-2168 Philips Hue/LIFX: Send device watch registration -Send device watch register events in update() --- smartapps/smartthings/hue-connect.src/hue-connect.groovy | 9 +++++++++ .../smartthings/lifx-connect.src/lifx-connect.groovy | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index 7ee6e60..621d0d0 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -299,6 +299,7 @@ def initialize() { state.bridgeRefreshCount = 0 state.bulbRefreshCount = 0 state.updating = false + setupDeviceWatch() if (selectedHue) { addBridge() addBulbs() @@ -321,6 +322,14 @@ def uninstalled(){ state.username = null } +private setupDeviceWatch() { + def hub = location.hubs[0] + // Make sure that all child devices are enrolled in device watch + getChildDevices().each { + it.sendEvent(name: "DeviceWatch-Enroll", value: "{\"protocol\": \"LAN\", \"scheme\":\"untracked\", \"hubHardwareId\": \"${hub?.hub?.hardwareID}\"}") + } +} + private upgradeDeviceType(device, newHueType) { def deviceType = getDeviceType(newHueType) diff --git a/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy b/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy index 7fc13c9..41f20ef 100644 --- a/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy +++ b/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy @@ -271,9 +271,17 @@ def initialize() { updateDevices() // Check for new devices and remove old ones every 3 hours runEvery5Minutes('updateDevices') + setupDeviceWatch() } // Misc +private setupDeviceWatch() { + def hub = location.hubs[0] + // Make sure that all child devices are enrolled in device watch + getChildDevices().each { + it.sendEvent(name: "DeviceWatch-Enroll", value: "{\"protocol\": \"LAN\", \"scheme\":\"untracked\", \"hubHardwareId\": \"${hub?.hub?.hardwareID}\"}") + } +} Map apiRequestHeaders() { return ["Authorization": "Bearer ${state.lifxAccessToken}",