mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-15 21:03:23 +00:00
Compare commits
3 Commits
netatmo-ap
...
MSA-930-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8caff0f0fd | ||
|
|
4af884ad50 | ||
|
|
b98d795193 |
35
devicetypes/-/-.src/-.groovy
Normal file
35
devicetypes/-/-.src/-.groovy
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 에너지미터
|
||||||
|
*
|
||||||
|
* Copyright 2016 임희진
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
metadata {
|
||||||
|
definition (name: "에너지미터", namespace: "에너지미터", author: "임희진") {
|
||||||
|
capability "Energy Meter"
|
||||||
|
}
|
||||||
|
|
||||||
|
simulator {
|
||||||
|
// TODO: define status and reply messages here
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles {
|
||||||
|
// TODO: define your main and details tiles here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse events into attributes
|
||||||
|
def parse(String description) {
|
||||||
|
log.debug "Parsing '${description}'"
|
||||||
|
// TODO: handle 'energy' attribute
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,129 +1,129 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* 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
|
* 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
|
* 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.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
* Alfred Workflow
|
* Alfred Workflow
|
||||||
*
|
*
|
||||||
* Author: SmartThings
|
* Author: SmartThings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
definition(
|
definition(
|
||||||
name: "Alfred Workflow",
|
name: "Alfred Workflow",
|
||||||
namespace: "vlaminck",
|
namespace: "vlaminck",
|
||||||
author: "SmartThings",
|
author: "SmartThings",
|
||||||
description: "This SmartApp allows you to interact with the things in your physical graph through Alfred.",
|
description: "This SmartApp allows you to interact with the things in your physical graph through Alfred.",
|
||||||
category: "Convenience",
|
category: "Convenience",
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app.png",
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app.png",
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app@2x.png",
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app@2x.png",
|
||||||
oauth: [displayName: "SmartThings Alfred Workflow", displayLink: ""]
|
oauth: [displayName: "SmartThings Alfred Workflow", displayLink: ""]
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
section("Allow Alfred to Control These Things...") {
|
section("Allow Alfred to Control These Things...") {
|
||||||
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
||||||
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
|
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mappings {
|
mappings {
|
||||||
path("/switches") {
|
path("/switches") {
|
||||||
action: [
|
action: [
|
||||||
GET: "listSwitches",
|
GET: "listSwitches",
|
||||||
PUT: "updateSwitches"
|
PUT: "updateSwitches"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/switches/:id") {
|
path("/switches/:id") {
|
||||||
action: [
|
action: [
|
||||||
GET: "showSwitch",
|
GET: "showSwitch",
|
||||||
PUT: "updateSwitch"
|
PUT: "updateSwitch"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/locks") {
|
path("/locks") {
|
||||||
action: [
|
action: [
|
||||||
GET: "listLocks",
|
GET: "listLocks",
|
||||||
PUT: "updateLocks"
|
PUT: "updateLocks"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/locks/:id") {
|
path("/locks/:id") {
|
||||||
action: [
|
action: [
|
||||||
GET: "showLock",
|
GET: "showLock",
|
||||||
PUT: "updateLock"
|
PUT: "updateLock"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {}
|
def installed() {}
|
||||||
|
|
||||||
def updated() {}
|
def updated() {}
|
||||||
|
|
||||||
def listSwitches() {
|
def listSwitches() {
|
||||||
switches.collect { device(it,"switch") }
|
switches.collect { device(it,"switch") }
|
||||||
}
|
}
|
||||||
void updateSwitches() {
|
void updateSwitches() {
|
||||||
updateAll(switches)
|
updateAll(switches)
|
||||||
}
|
}
|
||||||
def showSwitch() {
|
def showSwitch() {
|
||||||
show(switches, "switch")
|
show(switches, "switch")
|
||||||
}
|
}
|
||||||
void updateSwitch() {
|
void updateSwitch() {
|
||||||
update(switches)
|
update(switches)
|
||||||
}
|
}
|
||||||
|
|
||||||
def listLocks() {
|
def listLocks() {
|
||||||
locks.collect { device(it, "lock") }
|
locks.collect { device(it, "lock") }
|
||||||
}
|
}
|
||||||
void updateLocks() {
|
void updateLocks() {
|
||||||
updateAll(locks)
|
updateAll(locks)
|
||||||
}
|
}
|
||||||
def showLock() {
|
def showLock() {
|
||||||
show(locks, "lock")
|
show(locks, "lock")
|
||||||
}
|
}
|
||||||
void updateLock() {
|
void updateLock() {
|
||||||
update(locks)
|
update(locks)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAll(devices) {
|
private void updateAll(devices) {
|
||||||
def command = request.JSON?.command
|
def command = request.JSON?.command
|
||||||
if (command) {
|
if (command) {
|
||||||
devices."$command"()
|
devices."$command"()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(devices) {
|
private void update(devices) {
|
||||||
log.debug "update, request: ${request.JSON}, params: ${params}, devices: $devices.id"
|
log.debug "update, request: ${request.JSON}, params: ${params}, devices: $devices.id"
|
||||||
def command = request.JSON?.command
|
def command = request.JSON?.command
|
||||||
if (command) {
|
if (command) {
|
||||||
def device = devices.find { it.id == params.id }
|
def device = devices.find { it.id == params.id }
|
||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
device."$command"()
|
device."$command"()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private show(devices, name) {
|
private show(devices, name) {
|
||||||
def device = devices.find { it.id == params.id }
|
def device = devices.find { it.id == params.id }
|
||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
def s = device.currentState(name)
|
def s = device.currentState(name)
|
||||||
[id: device.id, label: device.displayName, name: device.displayName, state: s]
|
[id: device.id, label: device.displayName, name: device.displayName, state: s]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private device(it, name) {
|
private device(it, name) {
|
||||||
if (it) {
|
if (it) {
|
||||||
def s = it.currentState(name)
|
def s = it.currentState(name)
|
||||||
[id: it.id, label: it.displayName, name: it.displayName, state: s]
|
[id: it.id, label: it.displayName, name: it.displayName, state: s]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user