From 385463772b9966fac60a3af0be58a8b97ba34b6d Mon Sep 17 00:00:00 2001 From: OpenT2T Date: Fri, 12 May 2017 18:23:08 -0700 Subject: [PATCH] Modifying 'Publish a SmartApp for OpenT2T - Fix register all device change handler' --- .../opent2t-smartapp-test.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy b/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy index 2bae32c..6825333 100644 --- a/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy +++ b/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy @@ -157,6 +157,17 @@ def registerAllDeviceSubscriptions() { registerChangeHandler(inputs) } +//Subscribe to events from a list of devices +def registerChangeHandler(myList) { + myList.each { myDevice -> + def theAtts = myDevice.supportedAttributes + theAtts.each {att -> + subscribe(myDevice, att.name, deviceEventHandler) + log.info "Registering for ${myDevice.displayName}.${att.name}" + } + } +} + //Endpoints function: Subscribe to events from a specific device def registerDeviceChange() { def subscriptionEndpt = params.subscriptionURL