mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 13:20:53 +00:00
Compare commits
19 Commits
MSA-1306-2
...
MSA-1327-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce8a629cef | ||
|
|
031a15ec86 | ||
|
|
fc2db2575d | ||
|
|
fd549631e6 | ||
|
|
417c246d61 | ||
|
|
0f1781c02e | ||
|
|
4ce6ee0890 | ||
|
|
f8050a5cd5 | ||
|
|
d44dac448b | ||
|
|
67c20abcba | ||
|
|
d56e132896 | ||
|
|
009ec2539d | ||
|
|
ff0860cbe1 | ||
|
|
ecfb99974b | ||
|
|
c2f18a91be | ||
|
|
0c1208928f | ||
|
|
02d9963fab | ||
|
|
32f0385e30 | ||
|
|
d17cadc4c7 |
@@ -21,6 +21,7 @@ metadata {
|
|||||||
attribute "tamper", "enum", ["detected", "clear"]
|
attribute "tamper", "enum", ["detected", "clear"]
|
||||||
attribute "heatAlarm", "enum", ["overheat detected", "clear", "rapid temperature rise", "underheat detected"]
|
attribute "heatAlarm", "enum", ["overheat detected", "clear", "rapid temperature rise", "underheat detected"]
|
||||||
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x86, 0x72, 0x5A, 0x59, 0x85, 0x73, 0x84, 0x80, 0x71, 0x56, 0x70, 0x31, 0x8E, 0x22, 0x9C, 0x98, 0x7A", outClusters: "0x20, 0x8B"
|
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x86, 0x72, 0x5A, 0x59, 0x85, 0x73, 0x84, 0x80, 0x71, 0x56, 0x70, 0x31, 0x8E, 0x22, 0x9C, 0x98, 0x7A", outClusters: "0x20, 0x8B"
|
||||||
|
fingerprint mfr:"010F", prod:"0C02", model:"1002"
|
||||||
}
|
}
|
||||||
simulator {
|
simulator {
|
||||||
//battery
|
//battery
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* Hue White Ambiance Bulb
|
||||||
|
*
|
||||||
|
* Philips Hue Type "Color Temperature Light"
|
||||||
|
*
|
||||||
|
* Author: SmartThings
|
||||||
|
*/
|
||||||
|
|
||||||
|
// for the UI
|
||||||
|
metadata {
|
||||||
|
// Automatically generated. Make future change here.
|
||||||
|
definition (name: "Hue White Ambiance Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
capability "Switch Level"
|
||||||
|
capability "Actuator"
|
||||||
|
capability "Color Temperature"
|
||||||
|
capability "Switch"
|
||||||
|
capability "Refresh"
|
||||||
|
|
||||||
|
command "refresh"
|
||||||
|
}
|
||||||
|
|
||||||
|
simulator {
|
||||||
|
// TODO: define status and reply messages here
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles (scale: 2){
|
||||||
|
multiAttributeTile(name:"rich-control", type: "lighting", width: 6, height: 4, canChangeIcon: true){
|
||||||
|
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
|
||||||
|
attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
|
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
|
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
|
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
|
}
|
||||||
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", width: 4, height: 2, inactiveLabel: false, range:"(2000..6500)") {
|
||||||
|
state "colorTemperature", action:"color temperature.setColorTemperature"
|
||||||
|
}
|
||||||
|
|
||||||
|
valueTile("colorTemp", "device.colorTemperature", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||||
|
state "colorTemperature", label: '${currentValue} K'
|
||||||
|
}
|
||||||
|
|
||||||
|
standardTile("refresh", "device.refresh", height: 2, width: 2, inactiveLabel: false, decoration: "flat") {
|
||||||
|
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
|
}
|
||||||
|
|
||||||
|
main(["rich-control"])
|
||||||
|
details(["rich-control", "colorTempSliderControl", "colorTemp", "refresh"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse events into attributes
|
||||||
|
def parse(description) {
|
||||||
|
log.debug "parse() - $description"
|
||||||
|
def results = []
|
||||||
|
|
||||||
|
def map = description
|
||||||
|
if (description instanceof String) {
|
||||||
|
log.debug "Hue Ambience Bulb stringToMap - ${map}"
|
||||||
|
map = stringToMap(description)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map?.name && map?.value) {
|
||||||
|
results << createEvent(name: "${map?.name}", value: "${map?.value}")
|
||||||
|
}
|
||||||
|
results
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle commands
|
||||||
|
void on() {
|
||||||
|
log.trace parent.on(this)
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
}
|
||||||
|
|
||||||
|
void off() {
|
||||||
|
log.trace parent.off(this)
|
||||||
|
sendEvent(name: "switch", value: "off")
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLevel(percent) {
|
||||||
|
log.debug "Executing 'setLevel'"
|
||||||
|
if (percent != null && percent >= 0 && percent <= 100) {
|
||||||
|
parent.setLevel(this, percent)
|
||||||
|
sendEvent(name: "level", value: percent)
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
} else {
|
||||||
|
log.warn "$percent is not 0-100"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setColorTemperature(value) {
|
||||||
|
if (value) {
|
||||||
|
log.trace "setColorTemperature: ${value}k"
|
||||||
|
parent.setColorTemperature(this, value)
|
||||||
|
sendEvent(name: "colorTemperature", value: value)
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
} else {
|
||||||
|
log.warn "Invalid color temperature"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void refresh() {
|
||||||
|
log.debug "Executing 'refresh'"
|
||||||
|
parent.manualRefresh()
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Smartsense Motion Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Motion Sensor](https://shop.smartthings.com/#!/products/samsung-smartthings-motion-sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health]($health)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Motion Sensor** - can detect motion
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 motion sensor that has 120min check-in interval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -323,6 +323,8 @@ private getDeviceType(hueType) {
|
|||||||
return "Hue Bulb"
|
return "Hue Bulb"
|
||||||
else if (hueType?.equalsIgnoreCase("Color Light"))
|
else if (hueType?.equalsIgnoreCase("Color Light"))
|
||||||
return "Hue Bloom"
|
return "Hue Bloom"
|
||||||
|
else if (hueType?.equalsIgnoreCase("Color Temperature Light"))
|
||||||
|
return "Hue White Ambiance Bulb"
|
||||||
else
|
else
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ mappings {
|
|||||||
path("/locks") {
|
path("/locks") {
|
||||||
action: [
|
action: [
|
||||||
GET: "listLocks",
|
GET: "listLocks",
|
||||||
PUT: "updateLock",
|
PUT: "updateLocks",
|
||||||
POST: "updateLock"
|
POST: "updateLocks"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/locks/:id") {
|
path("/locks/:id") {
|
||||||
@@ -442,31 +442,87 @@ def executePhrase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAll(devices) {
|
private void updateAll(devices) {
|
||||||
|
def type = params.param1
|
||||||
def command = request.JSON?.command
|
def command = request.JSON?.command
|
||||||
if (command)
|
if (!devices) {
|
||||||
{
|
httpError(404, "Devices not found")
|
||||||
command = command.toLowerCase()
|
}
|
||||||
devices."$command"()
|
if (command){
|
||||||
|
devices.each { device ->
|
||||||
|
executeCommand(device, type, 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 type = params.param1
|
||||||
def command = params.command
|
def command = request.JSON?.command
|
||||||
if (command)
|
def device = devices?.find { it.id == params.id }
|
||||||
{
|
|
||||||
command = command.toLowerCase()
|
if (!device) {
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device)
|
|
||||||
{
|
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
device."$command"()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command) {
|
||||||
|
executeCommand(device, type, command)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validating the command passed by the user based on capability.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
def validateCommand(device, deviceType, command) {
|
||||||
|
def capabilityCommands = getDeviceCapabilityCommands(device.capabilities)
|
||||||
|
def currentDeviceCapability = getCapabilityName(deviceType)
|
||||||
|
if (capabilityCommands[currentDeviceCapability]) {
|
||||||
|
return command in capabilityCommands[currentDeviceCapability] ? true : false
|
||||||
|
} else {
|
||||||
|
// Handling other device types here, which don't accept commands
|
||||||
|
httpError(400, "Bad request.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Need to get the attribute name to do the lookup. Only
|
||||||
|
* doing it for the device types which accept commands
|
||||||
|
* @return attribute name of the device type
|
||||||
|
*/
|
||||||
|
def getCapabilityName(type) {
|
||||||
|
switch(type) {
|
||||||
|
case "switches":
|
||||||
|
return "Switch"
|
||||||
|
case "locks":
|
||||||
|
return "Lock"
|
||||||
|
default:
|
||||||
|
return type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructing the map over here of
|
||||||
|
* supported commands by device capability
|
||||||
|
* @return a map of device capability -> supported commands
|
||||||
|
*/
|
||||||
|
def getDeviceCapabilityCommands(deviceCapabilities) {
|
||||||
|
def map = [:]
|
||||||
|
deviceCapabilities.collect {
|
||||||
|
map[it.name] = it.commands.collect{ it.name.toString() }
|
||||||
|
}
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates and executes the command
|
||||||
|
* on the device or devices
|
||||||
|
*/
|
||||||
|
def executeCommand(device, type, command) {
|
||||||
|
if (validateCommand(device, type, command)) {
|
||||||
|
device."$command"()
|
||||||
|
} else {
|
||||||
|
httpError(403, "Access denied. This command is not supported by current capability.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private show(devices, type) {
|
private show(devices, type) {
|
||||||
|
|||||||
129
smartapps/vlaminck/-.src/-.groovy
Normal file
129
smartapps/vlaminck/-.src/-.groovy
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2015 SmartThings
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Alfred Workflow
|
||||||
|
*
|
||||||
|
* Author: SmartThings
|
||||||
|
*/
|
||||||
|
|
||||||
|
definition(
|
||||||
|
name: "김신동",
|
||||||
|
namespace: "vlaminck",
|
||||||
|
author: "SmartThings",
|
||||||
|
description: "This SmartApp allows you to interact with the things in your physical graph through Alfred.",
|
||||||
|
category: "Convenience",
|
||||||
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app.png",
|
||||||
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/alfred-app@2x.png",
|
||||||
|
oauth: [displayName: "SmartThings Alfred Workflow", displayLink: ""]
|
||||||
|
)
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
section("Allow Alfred to Control These Things...") {
|
||||||
|
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
||||||
|
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings {
|
||||||
|
path("/switches") {
|
||||||
|
action: [
|
||||||
|
GET: "listSwitches",
|
||||||
|
PUT: "updateSwitches"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/switches/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "showSwitch",
|
||||||
|
PUT: "updateSwitch"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/locks") {
|
||||||
|
action: [
|
||||||
|
GET: "listLocks",
|
||||||
|
PUT: "updateLocks"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/locks/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "showLock",
|
||||||
|
PUT: "updateLock"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def installed() {}
|
||||||
|
|
||||||
|
def updated() {}
|
||||||
|
|
||||||
|
def listSwitches() {
|
||||||
|
switches.collect { device(it,"switch") }
|
||||||
|
}
|
||||||
|
void updateSwitches() {
|
||||||
|
updateAll(switches)
|
||||||
|
}
|
||||||
|
def showSwitch() {
|
||||||
|
show(switches, "switch")
|
||||||
|
}
|
||||||
|
void updateSwitch() {
|
||||||
|
update(switches)
|
||||||
|
}
|
||||||
|
|
||||||
|
def listLocks() {
|
||||||
|
locks.collect { device(it, "lock") }
|
||||||
|
}
|
||||||
|
void updateLocks() {
|
||||||
|
updateAll(locks)
|
||||||
|
}
|
||||||
|
def showLock() {
|
||||||
|
show(locks, "lock")
|
||||||
|
}
|
||||||
|
void updateLock() {
|
||||||
|
update(locks)
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAll(devices) {
|
||||||
|
def command = request.JSON?.command
|
||||||
|
if (command) {
|
||||||
|
devices."$command"()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update(devices) {
|
||||||
|
log.debug "update, request: ${request.JSON}, params: ${params}, devices: $devices.id"
|
||||||
|
def command = request.JSON?.command
|
||||||
|
if (command) {
|
||||||
|
def device = devices.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
device."$command"()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private show(devices, name) {
|
||||||
|
def device = devices.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
def s = device.currentState(name)
|
||||||
|
[id: device.id, label: device.displayName, name: device.displayName, state: s]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private device(it, name) {
|
||||||
|
if (it) {
|
||||||
|
def s = it.currentState(name)
|
||||||
|
[id: it.id, label: it.displayName, name: it.displayName, state: s]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user