From 2f889de11a0a210b538050d6e0beb79b5ae3dfce Mon Sep 17 00:00:00 2001 From: Rohan Desai Date: Thu, 8 Sep 2016 10:36:28 -0700 Subject: [PATCH 1/2] fixes for dynamic execution --- .../curb/curb-control.src/curb-control.groovy | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/smartapps/curb/curb-control.src/curb-control.groovy b/smartapps/curb/curb-control.src/curb-control.groovy index 3a1c83d..4cea160 100644 --- a/smartapps/curb/curb-control.src/curb-control.groovy +++ b/smartapps/curb/curb-control.src/curb-control.groovy @@ -65,7 +65,16 @@ void updateSwitch() { private void updateAll(devices) { def command = request.JSON?.command if (command) { - devices."$command"() + switch(command) { + case "on": + devices.on() + break; + case "off": + devices.off() + break; + default: + httpError(403, "Access denied. This command is not supported by current capability.") + } } } @@ -77,7 +86,16 @@ private void update(devices) { if (!device) { httpError(404, "Device not found") } else { - device."$command"() + switch(command) { + case "on": + device.on() + break; + case "off": + device.off() + break; + default: + httpError(403, "Access denied. This command is not supported by current capability.") + } } } } From 48e9a4bd6afca9efbb9166faabe5c1ff64f2642d Mon Sep 17 00:00:00 2001 From: Rohan Desai Date: Thu, 8 Sep 2016 10:46:40 -0700 Subject: [PATCH 2/2] removed semi colons --- smartapps/curb/curb-control.src/curb-control.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smartapps/curb/curb-control.src/curb-control.groovy b/smartapps/curb/curb-control.src/curb-control.groovy index 4cea160..3bd1ec4 100644 --- a/smartapps/curb/curb-control.src/curb-control.groovy +++ b/smartapps/curb/curb-control.src/curb-control.groovy @@ -68,10 +68,10 @@ private void updateAll(devices) { switch(command) { case "on": devices.on() - break; + break case "off": devices.off() - break; + break default: httpError(403, "Access denied. This command is not supported by current capability.") } @@ -89,10 +89,10 @@ private void update(devices) { switch(command) { case "on": device.on() - break; + break case "off": device.off() - break; + break default: httpError(403, "Access denied. This command is not supported by current capability.") }