mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 13:21:53 +00:00
Compare commits
7 Commits
MSA-1306-2
...
lange-ecob
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6b98c2e7b | ||
|
|
d44dac448b | ||
|
|
67c20abcba | ||
|
|
ff0860cbe1 | ||
|
|
ecfb99974b | ||
|
|
0c1208928f | ||
|
|
d17cadc4c7 |
@@ -1,294 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "재부재 센서", namespace: "smartthings", author: "김성훈") {
|
||||
capability "Tone"
|
||||
capability "Actuator"
|
||||
capability "Signal Strength"
|
||||
capability "Presence Sensor"
|
||||
capability "Sensor"
|
||||
capability "Battery"
|
||||
|
||||
fingerprint profileId: "FC01", deviceId: "019A"
|
||||
fingerprint profileId: "FC01", deviceId: "0131", inClusters: "0000,0003", outClusters: "0003"
|
||||
fingerprint profileId: "FC01", deviceId: "0131", inClusters: "0000", outClusters: "0006"
|
||||
}
|
||||
|
||||
simulator {
|
||||
status "present": "presence: 1"
|
||||
status "not present": "presence: 0"
|
||||
status "battery": "battery: 27, batteryDivisor: 0A, rssi: 100, lqi: 64"
|
||||
}
|
||||
|
||||
preferences {
|
||||
section {
|
||||
image(name: 'educationalcontent', multiple: true, images: [
|
||||
"http://cdn.device-gse.smartthings.com/Arrival/Arrival1.jpg",
|
||||
"http://cdn.device-gse.smartthings.com/Arrival/Arrival2.jpg"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("presence", "device.presence", width: 2, height: 2, canChangeBackground: true) {
|
||||
state "present", labelIcon:"st.presence.tile.present", backgroundColor:"#53a7c0"
|
||||
state "not present", labelIcon:"st.presence.tile.not-present", backgroundColor:"#ebeef2"
|
||||
}
|
||||
standardTile("beep", "device.beep", decoration: "flat") {
|
||||
state "beep", label:'', action:"tone.beep", icon:"st.secondary.beep", backgroundColor:"#ffffff"
|
||||
}
|
||||
valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false) {
|
||||
state "battery", label:'${currentValue}% battery', unit:""/*, backgroundColors:[
|
||||
[value: 5, color: "#BC2323"],
|
||||
[value: 10, color: "#D04E00"],
|
||||
[value: 15, color: "#F1D801"],
|
||||
[value: 16, color: "#FFFFFF"]
|
||||
]*/
|
||||
}
|
||||
/*
|
||||
valueTile("lqi", "device.lqi", decoration: "flat", inactiveLabel: false) {
|
||||
state "lqi", label:'${currentValue}% signal', unit:""
|
||||
}
|
||||
*/
|
||||
|
||||
main "presence"
|
||||
details(["presence", "beep", "battery"/*, "lqi"*/])
|
||||
}
|
||||
}
|
||||
|
||||
def beep() {
|
||||
/*
|
||||
You can make the speaker turn on for 0.5-second beeps by sending some CLI commands:
|
||||
|
||||
Command: send raw, wait 7, send raw, wait 7, send raw
|
||||
Future: new packet type "st.beep"
|
||||
|
||||
raw 0xFC05 {15 0A 11 00 00 15 01}
|
||||
send 0x2F7F 2 2
|
||||
|
||||
where "0xABCD" is the node ID of the Smart Tag, everything else above is a constant. Except
|
||||
the "15 01" at the end of the first raw command, that sets the speaker's period (reciprocal
|
||||
of frequency). You can play with this value up or down to experiment with loudness as the
|
||||
loudness will be strongly dependent upon frequency and the enclosure that it's in. Note that
|
||||
"15 01" represents the hex number 0x0115 so a lower frequency is "16 01" (longer period) and
|
||||
a higher frequency is "14 01" (shorter period). Note that since the tag only checks its parent
|
||||
for messages every 5 seconds (while at rest) or every 3 seconds (while in motion) it will take
|
||||
up to this long from the time you send the message to the time you hear a sound.
|
||||
*/
|
||||
|
||||
[
|
||||
"raw 0xFC05 {15 0A 11 00 00 15 01}",
|
||||
"delay 7000",
|
||||
"raw 0xFC05 {15 0A 11 00 00 15 01}",
|
||||
"delay 7000",
|
||||
"raw 0xFC05 {15 0A 11 00 00 15 01}",
|
||||
"delay 7000",
|
||||
"raw 0xFC05 {15 0A 11 00 00 15 01}",
|
||||
"delay 7000",
|
||||
"raw 0xFC05 {15 0A 11 00 00 15 01}"
|
||||
]
|
||||
}
|
||||
|
||||
def parse(String description) {
|
||||
def results
|
||||
if (isBatteryMessage(description)) {
|
||||
results = parseBatteryMessage(description)
|
||||
}
|
||||
else {
|
||||
results = parsePresenceMessage(description)
|
||||
}
|
||||
|
||||
log.debug "Parse returned $results.descriptionText"
|
||||
results
|
||||
}
|
||||
|
||||
private Map parsePresenceMessage(String description) {
|
||||
def name = parseName(description)
|
||||
def value = parseValue(description)
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = parseDescriptionText(linkText, value, description)
|
||||
def handlerName = getState(value)
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
|
||||
def results = [
|
||||
name: name,
|
||||
value: value,
|
||||
unit: null,
|
||||
linkText: linkText,
|
||||
descriptionText: descriptionText,
|
||||
handlerName: handlerName,
|
||||
isStateChange: isStateChange,
|
||||
displayed: displayed(description, isStateChange)
|
||||
]
|
||||
|
||||
results
|
||||
}
|
||||
|
||||
private String parseName(String description) {
|
||||
if (description?.startsWith("presence: ")) {
|
||||
return "presence"
|
||||
}
|
||||
null
|
||||
}
|
||||
|
||||
private String parseValue(String description) {
|
||||
if (description?.startsWith("presence: "))
|
||||
{
|
||||
if (description?.endsWith("1"))
|
||||
{
|
||||
return "present"
|
||||
}
|
||||
else if (description?.endsWith("0"))
|
||||
{
|
||||
return "not present"
|
||||
}
|
||||
}
|
||||
|
||||
description
|
||||
}
|
||||
|
||||
private parseDescriptionText(String linkText, String value, String description) {
|
||||
switch(value) {
|
||||
case "present": return "$linkText has arrived"
|
||||
case "not present": return "$linkText has left"
|
||||
default: return value
|
||||
}
|
||||
}
|
||||
|
||||
private getState(String value) {
|
||||
def state = value
|
||||
if (value == "present") {
|
||||
state = "arrived"
|
||||
}
|
||||
else if (value == "not present") {
|
||||
state = "left"
|
||||
}
|
||||
|
||||
state
|
||||
}
|
||||
|
||||
private Boolean isBatteryMessage(String description) {
|
||||
// "raw:36EF1C, dni:36EF, battery:1B, rssi:, lqi:"
|
||||
description ==~ /.*battery:.*rssi:.*lqi:.*/
|
||||
}
|
||||
|
||||
private List parseBatteryMessage(String description) {
|
||||
def results = []
|
||||
def parts = description.split(',')
|
||||
parts.each { part ->
|
||||
part = part.trim()
|
||||
if (part.startsWith('battery:')) {
|
||||
def batteryResult = getBatteryResult(part, description)
|
||||
if (batteryResult) {
|
||||
results << batteryResult
|
||||
}
|
||||
}
|
||||
else if (part.startsWith('rssi:')) {
|
||||
def rssiResult = getRssiResult(part, description)
|
||||
if (rssiResult) {
|
||||
results << rssiResult
|
||||
}
|
||||
}
|
||||
else if (part.startsWith('lqi:')) {
|
||||
def lqiResult = getLqiResult(part, description)
|
||||
if (lqiResult) {
|
||||
results << lqiResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results
|
||||
}
|
||||
|
||||
private getBatteryResult(part, description) {
|
||||
def batteryDivisor = description.split(",").find {it.split(":")[0].trim() == "batteryDivisor"} ? description.split(",").find {it.split(":")[0].trim() == "batteryDivisor"}.split(":")[1].trim() : null
|
||||
def name = "battery"
|
||||
def value = zigbee.parseSmartThingsBatteryValue(part, batteryDivisor)
|
||||
def unit = "%"
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = "$linkText battery was ${value}${unit}"
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
|
||||
[
|
||||
name: name,
|
||||
value: value,
|
||||
unit: unit,
|
||||
linkText: linkText,
|
||||
descriptionText: descriptionText,
|
||||
handlerName: name,
|
||||
isStateChange: isStateChange,
|
||||
//displayed: displayed(description, isStateChange)
|
||||
displayed: false
|
||||
]
|
||||
}
|
||||
|
||||
private getRssiResult(part, description) {
|
||||
def name = "rssi"
|
||||
def parts = part.split(":")
|
||||
if (parts.size() != 2) return null
|
||||
|
||||
def valueString = parts[1].trim()
|
||||
def valueInt = Integer.parseInt(valueString, 16)
|
||||
def value = (valueInt - 128).toString()
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = "$linkText was $value dBm"
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
|
||||
[
|
||||
name: name,
|
||||
value: value,
|
||||
unit: "dBm",
|
||||
linkText: linkText,
|
||||
descriptionText: descriptionText,
|
||||
handlerName: null,
|
||||
isStateChange: isStateChange,
|
||||
//displayed: displayed(description, isStateChange)
|
||||
displayed: false
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Use LQI (Link Quality Indicator) as a measure of signal strength. The values
|
||||
* are 0 to 255 (0x00 to 0xFF) and higher values represent higher signal
|
||||
* strength. Return as a percentage of 255.
|
||||
*
|
||||
* Note: To make the signal strength indicator more accurate, we could combine
|
||||
* LQI with RSSI.
|
||||
*/
|
||||
private getLqiResult(part, description) {
|
||||
def name = "lqi"
|
||||
def parts = part.split(":")
|
||||
if (parts.size() != 2) return null
|
||||
|
||||
def valueString = parts[1].trim()
|
||||
def valueInt = Integer.parseInt(valueString, 16)
|
||||
def percentageOf = 255
|
||||
def value = Math.round((valueInt / percentageOf * 100)).toString()
|
||||
def unit = "%"
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = "$linkText Signal (LQI) was ${value}${unit}"
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
|
||||
[
|
||||
name: name,
|
||||
value: value,
|
||||
unit: unit,
|
||||
linkText: linkText,
|
||||
descriptionText: descriptionText,
|
||||
handlerName: null,
|
||||
isStateChange: isStateChange,
|
||||
//displayed: displayed(description, isStateChange)
|
||||
displayed: false
|
||||
]
|
||||
}
|
||||
@@ -18,7 +18,6 @@ metadata {
|
||||
definition (name: "Ecobee Sensor", namespace: "smartthings", author: "SmartThings") {
|
||||
capability "Sensor"
|
||||
capability "Temperature Measurement"
|
||||
capability "Motion Sensor"
|
||||
capability "Refresh"
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,17 +45,28 @@ metadata {
|
||||
}
|
||||
|
||||
preferences {
|
||||
input title: "Temperature Offset", description: "This feature allows you to correct any temperature variations by selecting an offset. Ex: If your sensor consistently reports a temp that's 5 degrees too warm, you'd enter \"-5\". If 3 degrees too cold, enter \"+3\".", displayDuringSetup: false, type: "paragraph", element: "paragraph"
|
||||
input "tempOffset", "number", title: "Degrees", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
|
||||
section {
|
||||
input description: "This feature allows you to correct any temperature variations by selecting an offset. Ex: If your sensor consistently reports a temp that's 5 degrees too warm, you'd enter \"-5\". If 3 degrees too cold, enter \"+3\".", displayDuringSetup: false, type: "paragraph", element: "paragraph"
|
||||
input "tempOffset", "number", title: "Temperature Offset", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
|
||||
}
|
||||
section {
|
||||
input("garageSensor", "enum", title: "Do you want to use this sensor on a garage door?", options: ["Yes", "No"], defaultValue: "No", required: false, displayDuringSetup: false)
|
||||
}
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
multiAttributeTile(name:"contact", type: "generic", width: 6, height: 4){
|
||||
tileAttribute ("device.contact", key: "PRIMARY_CONTROL") {
|
||||
attributeState "open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
|
||||
multiAttributeTile(name:"status", type: "generic", width: 6, height: 4){
|
||||
tileAttribute ("device.status", key: "PRIMARY_CONTROL") {
|
||||
attributeState "closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821"
|
||||
attributeState "open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
|
||||
attributeState "garage-closed", label:'Closed', icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821"
|
||||
attributeState "garage-open", label:'Open', icon:"st.doors.garage.garage-open", backgroundColor:"#ffa81e"
|
||||
}
|
||||
}
|
||||
standardTile("contact", "device.contact", width: 2, height: 2) {
|
||||
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
|
||||
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
|
||||
}
|
||||
|
||||
standardTile("acceleration", "device.acceleration", width: 2, height: 2) {
|
||||
state("active", label:'${name}', icon:"st.motion.acceleration.active", backgroundColor:"#53a7c0")
|
||||
@@ -78,8 +89,8 @@ metadata {
|
||||
state "battery", label:'${currentValue}% battery', unit:""
|
||||
}
|
||||
|
||||
main(["contact", "acceleration", "temperature"])
|
||||
details(["contact", "acceleration", "temperature", "battery"])
|
||||
main(["status", "acceleration", "temperature"])
|
||||
details(["status", "acceleration", "temperature", "battery"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +98,9 @@ def parse(String description) {
|
||||
def results
|
||||
|
||||
if (!isSupportedDescription(description) || zigbee.isZoneType19(description)) {
|
||||
results = parseSingleMessage(description)
|
||||
if (garageSensor != "Yes") {
|
||||
results = parseSingleMessage(description)
|
||||
}
|
||||
}
|
||||
else if (description == 'updated') {
|
||||
//TODO is there a better way to handle this like the other device types?
|
||||
@@ -203,7 +216,9 @@ private List parseContactMessage(String description) {
|
||||
parts.each { part ->
|
||||
part = part.trim()
|
||||
if (part.startsWith('contactState:')) {
|
||||
results.addAll(getContactResult(part, description))
|
||||
if (garageSensor != "Yes") {
|
||||
results.addAll(getContactResult(part, description))
|
||||
}
|
||||
}
|
||||
else if (part.startsWith('accelerationState:')) {
|
||||
results << getAccelerationResult(part, description)
|
||||
@@ -225,6 +240,29 @@ private List parseContactMessage(String description) {
|
||||
results
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "updated called"
|
||||
log.info "garage value : $garageSensor"
|
||||
if (garageSensor == "Yes") {
|
||||
def descriptionText = "Updating device to garage sensor"
|
||||
if (device.latestValue("status") == "open") {
|
||||
sendEvent(name: 'status', value: 'garage-open', descriptionText: descriptionText)
|
||||
}
|
||||
else if (device.latestValue("status") == "closed") {
|
||||
sendEvent(name: 'status', value: 'garage-closed', descriptionText: descriptionText)
|
||||
}
|
||||
}
|
||||
else {
|
||||
def descriptionText = "Updating device to open/close sensor"
|
||||
if (device.latestValue("status") == "garage-open") {
|
||||
sendEvent(name: 'status', value: 'open', descriptionText: descriptionText)
|
||||
}
|
||||
else if (device.latestValue("status") == "garage-closed") {
|
||||
sendEvent(name: 'status', value: 'closed', descriptionText: descriptionText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List parseOrientationMessage(String description) {
|
||||
def results = []
|
||||
def xyzResults = [x: 0, y: 0, z: 0]
|
||||
@@ -254,7 +292,34 @@ private List parseOrientationMessage(String description) {
|
||||
}
|
||||
}
|
||||
|
||||
results << getXyzResult(xyzResults, description)
|
||||
def xyz = getXyzResult(xyzResults, description)
|
||||
results << xyz
|
||||
|
||||
if (garageSensor == "Yes") {
|
||||
// Looks for Z-axis orientation as virtual contact state
|
||||
def a = xyz.value.split(',').collect{it.toInteger()}
|
||||
def absValueXY = Math.max(Math.abs(a[0]), Math.abs(a[1]))
|
||||
def absValueZ = Math.abs(a[2])
|
||||
log.debug "absValueXY: $absValueXY, absValueZ: $absValueZ"
|
||||
|
||||
def contactValue = null
|
||||
def garageValue = null
|
||||
|
||||
if (absValueZ > 825 && absValueXY < 175) {
|
||||
contactValue = 'open'
|
||||
garageValue = 'garage-open'
|
||||
log.debug "STATUS: open"
|
||||
}
|
||||
else if (absValueZ < 75 && absValueXY > 825) {
|
||||
contactValue = 'closed'
|
||||
garageValue = 'garage-closed'
|
||||
log.debug "STATUS: closed"
|
||||
}
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = "${linkText} was ${contactValue == 'open' ? 'opened' : 'closed'}"
|
||||
results << createEvent(name: "contact", value: contactValue, descriptionText: descriptionText, unit: "", displayed: false)
|
||||
results << createEvent(name: "status", value: garageValue, descriptionText: descriptionText, unit: "")
|
||||
}
|
||||
|
||||
results
|
||||
}
|
||||
|
||||
@@ -323,6 +323,8 @@ private getDeviceType(hueType) {
|
||||
return "Hue Bulb"
|
||||
else if (hueType?.equalsIgnoreCase("Color Light"))
|
||||
return "Hue Bloom"
|
||||
else if (hueType?.equalsIgnoreCase("Color Temperature Light"))
|
||||
return "Hue White Ambiance Bulb"
|
||||
else
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Turn It On For 5 Minutes
|
||||
* Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later.
|
||||
*
|
||||
* Author: SmartThings
|
||||
*/
|
||||
definition(
|
||||
name: "Turn It On For 1 Minutes",
|
||||
namespace: "smartthings",
|
||||
author: "mr.kim",
|
||||
description: "When a SmartSense Multi is opened, a switch will be turned on, and then turned off after 5 minutes.",
|
||||
category: "Safety & Security",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png"
|
||||
)
|
||||
|
||||
preferences {
|
||||
section("When it opens..."){
|
||||
input "contact1", "capability.contactSensor"
|
||||
}
|
||||
section("Turn on a switch for 5 minutes..."){
|
||||
input "switch1", "capability.switch"
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
subscribe(contact1, "contact.open", contactOpenHandler)
|
||||
}
|
||||
|
||||
def updated(settings) {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
unsubscribe()
|
||||
subscribe(contact1, "contact.open", contactOpenHandler)
|
||||
}
|
||||
|
||||
def contactOpenHandler(evt) {
|
||||
switch1.on()
|
||||
def fiveMinuteDelay = 60 * 1
|
||||
runIn(fiveMinuteDelay, turnOffSwitch)
|
||||
}
|
||||
|
||||
def turnOffSwitch() {
|
||||
switch1.off()
|
||||
}
|
||||
Reference in New Issue
Block a user