From 53b8890216f6da4a089067d6b8515049a488c964 Mon Sep 17 00:00:00 2001 From: kylerw Date: Mon, 9 Jan 2017 11:16:41 -0700 Subject: [PATCH 1/2] Push Current Value during each subscription update, push the current value of each subscribed device. My ST development is nearly non-existent so there may be a more efficient way to do this but this is working for me. --- .../stj/mqtt-bridge.src/mqtt-bridge.groovy | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy index 8829b19..76034d8 100644 --- a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy +++ b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy @@ -489,6 +489,9 @@ def updateSubscription() { } settings[key].each {device -> attributes[attribute].push(device.displayName) + + def currval = device.currentValue("${attribute}") + pushCurrentValue(device.displayName, "${currval}", attribute) } } } @@ -504,6 +507,20 @@ def updateSubscription() { bridge.deviceNotification(json) } +def pushCurrentValue(displayName, currValue, attribute) { + def json = new JsonOutput().toJson([ + path: "/push", + body: [ + name: displayName, + value: currValue, + type: attribute + ] + ]) + log.debug "Forwarding device event to bridge: ${json}" + bridge.deviceNotification(json) + /////////////////// +} + // Receive an event from the bridge def bridgeHandler(evt) { def json = new JsonSlurper().parseText(evt.value) From 4ea2ed839be9fb3852c0160a8dff56c7ad428c2d Mon Sep 17 00:00:00 2001 From: kylerw Date: Wed, 11 Jan 2017 08:51:28 -0700 Subject: [PATCH 2/2] Update mqtt-bridge.groovy --- smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy index 76034d8..33682b8 100644 --- a/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy +++ b/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy @@ -490,7 +490,8 @@ def updateSubscription() { settings[key].each {device -> attributes[attribute].push(device.displayName) - def currval = device.currentValue("${attribute}") + //def currval = device.currentValue("${attribute}") + def currval = device.currentState("${attribute}").value pushCurrentValue(device.displayName, "${currval}", attribute) } }