mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-08 05:31:56 +00:00
Revert "MSA-1408: initial submission for Curb"
This commit is contained in:
@@ -1,103 +0,0 @@
|
|||||||
/**
|
|
||||||
* Curb Control
|
|
||||||
*
|
|
||||||
* Copyright 2016 Savanni D'Gerinel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "Curb Control",
|
|
||||||
namespace: "curb-v2",
|
|
||||||
author: "Savanni D'Gerinel",
|
|
||||||
description: "Control point for Curb/SmartThings integration",
|
|
||||||
category: "Green Living",
|
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
|
||||||
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
|
||||||
oauth: true)
|
|
||||||
|
|
||||||
|
|
||||||
preferences {
|
|
||||||
section("Allow Endpoint to Control These Things...") {
|
|
||||||
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mappings {
|
|
||||||
|
|
||||||
path("/switches") {
|
|
||||||
action: [
|
|
||||||
GET: "listSwitches"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/switches/:id") {
|
|
||||||
action: [
|
|
||||||
GET: "showSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/switches/:id/:command") {
|
|
||||||
action: [
|
|
||||||
PUT: "updateSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {}
|
|
||||||
|
|
||||||
def updated() {}
|
|
||||||
|
|
||||||
|
|
||||||
//switches
|
|
||||||
def listSwitches() {
|
|
||||||
switches.collect{device(it,"switch")}
|
|
||||||
}
|
|
||||||
|
|
||||||
def showSwitch() {
|
|
||||||
show(switches, "switch")
|
|
||||||
}
|
|
||||||
void updateSwitch() {
|
|
||||||
update(switches)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def deviceHandler(evt) {}
|
|
||||||
|
|
||||||
private void update(devices) {
|
|
||||||
log.debug "update, request: params: ${params}, devices: $devices.id"
|
|
||||||
|
|
||||||
|
|
||||||
//def command = request.JSON?.command
|
|
||||||
def command = params.command
|
|
||||||
//let's create a toggle option here
|
|
||||||
if (command)
|
|
||||||
{
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
} else {
|
|
||||||
if(command == "toggle")
|
|
||||||
{
|
|
||||||
if(device.currentValue('switch') == "on")
|
|
||||||
device.off();
|
|
||||||
else
|
|
||||||
device.on();;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private show(devices, type) {
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
def attributeName = type == "motionSensor" ? "motion" : type
|
|
||||||
def s = device.currentState(attributeName)
|
|
||||||
[id: device.id, label: device.displayName, value: s?.value, unitTime: s?.date?.time, type: type]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private device(it, type) {
|
|
||||||
it ? [id: it.id, label: it.label, type: type] : null
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user