mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 05:11:52 +00:00
Compare commits
7 Commits
MSA-1809-1
...
MSA-1817-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f140fe0d29 | ||
|
|
65ae2c0ddf | ||
|
|
7e806275ce | ||
|
|
1ed57aab45 | ||
|
|
4eea7ff90f | ||
|
|
b2264538c9 | ||
|
|
f45ab69045 |
@@ -108,8 +108,8 @@ def parse(String description) {
|
||||
}
|
||||
} else if (descMap.clusterInt == 0x0406 && descMap.attrInt == 0x0000) {
|
||||
def value = descMap.value.endsWith("01") ? "active" : "inactive"
|
||||
log.warn "Doing a read attr motion event"
|
||||
resultMap = getMotionResult(value)
|
||||
log.debug "Doing a read attr motion event"
|
||||
map = getMotionResult(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
82
smartapps/teapps/turn-off.src/turn-off.groovy
Normal file
82
smartapps/teapps/turn-off.src/turn-off.groovy
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Turn Off
|
||||
*
|
||||
* Copyright 2017 Trevor
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
definition(
|
||||
name: "Turn Off",
|
||||
namespace: "TEAPPS",
|
||||
author: "Trevor",
|
||||
description: "Turn off a light after its been turned on.",
|
||||
category: "Convenience",
|
||||
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")
|
||||
|
||||
|
||||
preferences {
|
||||
|
||||
section("Lights") {
|
||||
input "lights", "capability.switch", required: true, title: "Which lights to turn off after being turned on?", multiple: true
|
||||
input "offsetHours", "number", title: "How long until the light is turned off (hours)?"
|
||||
input "offsetMinutes", "number", title: "How long until the light is turned off (minutes)?"
|
||||
input "offsetSeconds", "number", title: "How long until the light is turned off (seconds)?"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
// TODO: subscribe to attributes, devices, locations, etc.
|
||||
|
||||
//Subscribe to the light device being turned on
|
||||
subscribe(lights, "switch.on", lightHandler)
|
||||
|
||||
|
||||
}
|
||||
|
||||
// TODO: implement event handlers
|
||||
def lightHandler(evt) {
|
||||
|
||||
if("on" == evt.value)
|
||||
//Light was turned on
|
||||
log.debug "Light is in ${evt.value} state"
|
||||
|
||||
//Get the date and time
|
||||
def currentTime = new Date()
|
||||
|
||||
//Calculate the offset
|
||||
def timeToTurnOff = new Date(currentTime.time + (offsetHours * 60 * 60 * 1000) + (offsetMinutes * 60 * 1000) + (offsetSeconds * 1000))
|
||||
|
||||
log.debug "Scheduling for: $timeToTurnOff"
|
||||
|
||||
//Schedule this to run one time
|
||||
runOnce(timeToTurnOff, turnOff)
|
||||
}
|
||||
|
||||
def turnOff() {
|
||||
log.debug "turning off lights"
|
||||
lights.off()
|
||||
}
|
||||
Reference in New Issue
Block a user