From 3d05d42cb8940f1ad697c75c6159fce447566d35 Mon Sep 17 00:00:00 2001 From: Lars Finander Date: Sun, 11 Sep 2016 22:56:24 -0600 Subject: [PATCH] Add offline events to Philips Hue -Handles case when bridge goes offline -Handles case when indiviudual lights go offline --- .../hue-connect.src/hue-connect.groovy | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index f0aad65..577168f 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -740,16 +740,21 @@ private void checkBridgeStatus() { d.sendEvent(name: "idNumber", value: it.value.idNumber) } - if (it.value.lastActivity < time) { // it.value.lastActivity != null && - log.warn "Bridge $it.key is Offline" - d.sendEvent(name: "status", value: "Offline") - // set all lights to offline since bridge is not reachable - state.bulbs?.each {it.value.online = false} - } else { + if (it.value.lastActivity < time) { // it.value.lastActivity != null && + log.warn "Bridge $it.key is Offline" + d.sendEvent(name: "status", value: "Offline") + + state.bulbs?.each { + it.value.online = false + } + getChildDevices().each { + it.sendEvent(name: "DeviceWatch-DeviceOffline", value: "offline") + } + } else { d.sendEvent(name: "status", value: "Online")//setOnline(false) - } - } - } + } + } + } } def isValidSource(macAddress) { @@ -955,6 +960,7 @@ private handlePoll(body) { } else { state.bulbs[bulb.key]?.online = false log.warn "$device is not reachable by Hue bridge" + device.sendEvent(name: "DeviceWatch-DeviceOffline", value: "offline") } } }