mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-25 21:04:10 +00:00
Modifying 'Simple Control'
This commit is contained in:
@@ -106,11 +106,31 @@ def handleDevicesWithIDs()
|
|||||||
for (devId in ids)
|
for (devId in ids)
|
||||||
{
|
{
|
||||||
def device = allDevices.find { it.id == devId }
|
def device = allDevices.find { it.id == devId }
|
||||||
if (device) {
|
// Check if we have a device that responds to the specified command
|
||||||
if (arguments) {
|
if (device && device.hasCommand(command)) {
|
||||||
device."$command"(*arguments)
|
switch (command)
|
||||||
} else {
|
{
|
||||||
device."$command"()
|
case "on":
|
||||||
|
device.on()
|
||||||
|
break
|
||||||
|
case "off":
|
||||||
|
device.off()
|
||||||
|
break
|
||||||
|
case "setLevel":
|
||||||
|
device.setLevel(*arguments)
|
||||||
|
break
|
||||||
|
case "playText":
|
||||||
|
device.playText(*arguments)
|
||||||
|
break
|
||||||
|
case "lock":
|
||||||
|
device.lock()
|
||||||
|
break
|
||||||
|
case "unlock":
|
||||||
|
device.unlock()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
httpError(400, "Command ${command} cannot be sent to the target device")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
success = true
|
success = true
|
||||||
} else {
|
} else {
|
||||||
@@ -176,11 +196,31 @@ def updateDevice()
|
|||||||
render status: 400, data: '{"msg": "command is required"}'
|
render status: 400, data: '{"msg": "command is required"}'
|
||||||
} else {
|
} else {
|
||||||
def device = allDevices.find { it.id == params.id }
|
def device = allDevices.find { it.id == params.id }
|
||||||
if (device) {
|
// Check if we have a device that responds to the specified command
|
||||||
if (arguments) {
|
if (device && device.hasCommand(command)) {
|
||||||
device."$command"(*arguments)
|
switch (command)
|
||||||
} else {
|
{
|
||||||
device."$command"()
|
case "on":
|
||||||
|
device.on()
|
||||||
|
break
|
||||||
|
case "off":
|
||||||
|
device.off()
|
||||||
|
break
|
||||||
|
case "setLevel":
|
||||||
|
device.setLevel(*arguments)
|
||||||
|
break
|
||||||
|
case "playText":
|
||||||
|
device.playText(*arguments)
|
||||||
|
break
|
||||||
|
case "lock":
|
||||||
|
device.lock()
|
||||||
|
break
|
||||||
|
case "unlock":
|
||||||
|
device.unlock()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
httpError(400, "Command ${command} cannot be sent to the target device")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
render status: 204, data: "{}"
|
render status: 204, data: "{}"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user