From aab564471c823bb326e3a7e7cfe8b6930f85a50c Mon Sep 17 00:00:00 2001 From: "St. John Johnson" Date: Wed, 1 Feb 2017 23:48:40 -0800 Subject: [PATCH] Push current state every 30 minutes This will push the current state of all attributes every 30 minutes, so if the bridge was down, it will eventually recover to current state. --- smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy index 8829b19..cbd3a83 100644 --- a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy +++ b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy @@ -475,6 +475,8 @@ def initialize() { // Update the bridge updateSubscription() + // Auto-update every 30 minutes + schedule("0 0/30 * * * ?", updateSubscription) } // Update the bridge"s subscription @@ -489,6 +491,12 @@ def updateSubscription() { } settings[key].each {device -> attributes[attribute].push(device.displayName) + // Send current value + inputHandler([ + displayName: device.displayName, + value: device.currentState(attribute).value, + name: attribute + ]) } } } @@ -500,7 +508,6 @@ def updateSubscription() { ]) log.debug "Updating subscription: ${json}" - bridge.deviceNotification(json) }