mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-20 13:20:53 +00:00
Compare commits
23 Commits
MSA-1267-1
...
PROD_2016.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02d9963fab | ||
|
|
f131fb71cf | ||
|
|
9c27ed6cb7 | ||
|
|
35edaa19c7 | ||
|
|
dc09201866 | ||
|
|
6afcbf8f70 | ||
|
|
d73f4c2ded | ||
|
|
13a056ec8d | ||
|
|
bd0ccd0c21 | ||
|
|
d34508c19d | ||
|
|
a8e118fe83 | ||
|
|
072cc066b6 | ||
|
|
17562c96ae | ||
|
|
3b56fb4a2f | ||
|
|
cca1eccce6 | ||
|
|
f1e54c8a5c | ||
|
|
a4a48fddd2 | ||
|
|
2bd18859b9 | ||
|
|
566425c531 | ||
|
|
e7448e7908 | ||
|
|
973c16f088 | ||
|
|
e278a3b57d | ||
|
|
b05d956d95 |
@@ -94,11 +94,11 @@ def parse(String description) {
|
|||||||
def cmd = zwave.parse(description, [0x31: 1, 0x32: 1, 0x60: 3])
|
def cmd = zwave.parse(description, [0x31: 1, 0x32: 1, 0x60: 3])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = createEvent(zwaveEvent(cmd))
|
result = createEvent(zwaveEvent(cmd))
|
||||||
log.debug "Parse returned ${result?.descriptionText}"
|
|
||||||
storeGraphData(result.name, result.value)
|
|
||||||
} else {
|
|
||||||
log.debug "zwave.parse returned null command. Cannot create event"
|
|
||||||
}
|
}
|
||||||
|
log.debug "Parse returned ${result?.descriptionText}"
|
||||||
|
|
||||||
|
storeGraphData(result.name, result.value)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@Deprecated: Moved to ZLL Dimmer Bulb
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Cree Bulb", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "Cree Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
|
|
||||||
//fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,1000", outClusters: "0000,0019"
|
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,1000", outClusters: "0000,0019"
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulator metadata
|
// simulator metadata
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
|
|||||||
log.debug "productTypeId: ${cmd.productTypeId}"
|
log.debug "productTypeId: ${cmd.productTypeId}"
|
||||||
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
|
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
|
||||||
updateDataValue("MSR", msr)
|
updateDataValue("MSR", msr)
|
||||||
|
updateDataValue("manufacturer", cmd.manufacturerName)
|
||||||
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ metadata {
|
|||||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
}
|
}
|
||||||
|
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
||||||
|
attributeState "level", label: 'Level ${currentValue}%'
|
||||||
|
}
|
||||||
tileAttribute ("device.color", key: "COLOR_CONTROL") {
|
tileAttribute ("device.color", key: "COLOR_CONTROL") {
|
||||||
attributeState "color", action:"setAdjustedColor"
|
attributeState "color", action:"setAdjustedColor"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ metadata {
|
|||||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
}
|
}
|
||||||
|
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
||||||
|
attributeState "level", label: 'Level ${currentValue}%'
|
||||||
|
}
|
||||||
tileAttribute ("device.color", key: "COLOR_CONTROL") {
|
tileAttribute ("device.color", key: "COLOR_CONTROL") {
|
||||||
attributeState "color", action:"setAdjustedColor"
|
attributeState "color", action:"setAdjustedColor"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ metadata {
|
|||||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
}
|
}
|
||||||
|
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
||||||
|
attributeState "level", label: 'Level ${currentValue}%'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
|
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
|
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019"
|
//fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019", manufacturer: "CREE", model: "Connected A-19 60W Equivalent", deviceJoinName: "Cree Connected Bulb"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0019"
|
||||||
|
//fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019", manufacturer: "CREE", model: "Connected A-19 60W Equivalent", deviceJoinName: "Cree Connected Bulb"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 W clear", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 W clear", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 W clear - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 W clear - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0019", manufacturer: "Philips", model: "LWB006", deviceJoinName: "Philips Hue White"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0019", manufacturer: "Philips", model: "LWB006", deviceJoinName: "Philips Hue White"
|
||||||
|
|||||||
@@ -95,11 +95,17 @@ def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
|
||||||
if (state.manufacturer != cmd.manufacturerName) {
|
log.debug "manufacturerId: ${cmd.manufacturerId}"
|
||||||
updateDataValue("manufacturer", cmd.manufacturerName)
|
log.debug "manufacturerName: ${cmd.manufacturerName}"
|
||||||
}
|
log.debug "productId: ${cmd.productId}"
|
||||||
|
log.debug "productTypeId: ${cmd.productTypeId}"
|
||||||
|
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
|
||||||
|
updateDataValue("MSR", msr)
|
||||||
|
updateDataValue("manufacturer", cmd.manufacturerName)
|
||||||
|
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
[:]
|
[:]
|
||||||
|
|||||||
@@ -1,198 +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.
|
|
||||||
*
|
|
||||||
* Good Night
|
|
||||||
*
|
|
||||||
* Author: SmartThings
|
|
||||||
* Date: 2013-03-07
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "이현주",
|
|
||||||
namespace: "smartthings",
|
|
||||||
author: "SmartThings",
|
|
||||||
description: "Changes mode when motion ceases after a specific time of night.",
|
|
||||||
category: "Mode Magic",
|
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/good-night.png",
|
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/good-night@2x.png"
|
|
||||||
)
|
|
||||||
|
|
||||||
preferences {
|
|
||||||
section("When there is no motion on any of these sensors") {
|
|
||||||
input "motionSensors", "capability.motionSensor", title: "Where?", multiple: true
|
|
||||||
}
|
|
||||||
section("For this amount of time") {
|
|
||||||
input "minutes", "number", title: "Minutes?"
|
|
||||||
}
|
|
||||||
section("After this time of day") {
|
|
||||||
input "timeOfDay", "time", title: "Time?"
|
|
||||||
}
|
|
||||||
section("And (optionally) these switches are all off") {
|
|
||||||
input "switches", "capability.switch", multiple: true, required: false
|
|
||||||
}
|
|
||||||
section("Change to this mode") {
|
|
||||||
input "newMode", "mode", title: "Mode?"
|
|
||||||
}
|
|
||||||
section( "Notifications" ) {
|
|
||||||
input("recipients", "contact", title: "Send notifications to") {
|
|
||||||
input "sendPushMessage", "enum", title: "Send a push notification?", options: ["Yes", "No"], required: false
|
|
||||||
input "phoneNumber", "phone", title: "Send a Text Message?", required: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {
|
|
||||||
log.debug "Current mode = ${location.mode}"
|
|
||||||
createSubscriptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated() {
|
|
||||||
log.debug "Current mode = ${location.mode}"
|
|
||||||
unsubscribe()
|
|
||||||
createSubscriptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
def createSubscriptions()
|
|
||||||
{
|
|
||||||
subscribe(motionSensors, "motion.active", motionActiveHandler)
|
|
||||||
subscribe(motionSensors, "motion.inactive", motionInactiveHandler)
|
|
||||||
subscribe(switches, "switch.off", switchOffHandler)
|
|
||||||
subscribe(location, modeChangeHandler)
|
|
||||||
|
|
||||||
if (state.modeStartTime == null) {
|
|
||||||
state.modeStartTime = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def modeChangeHandler(evt) {
|
|
||||||
state.modeStartTime = now()
|
|
||||||
}
|
|
||||||
|
|
||||||
def switchOffHandler(evt) {
|
|
||||||
if (correctMode() && correctTime()) {
|
|
||||||
if (allQuiet() && switchesOk()) {
|
|
||||||
takeActions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def motionActiveHandler(evt)
|
|
||||||
{
|
|
||||||
log.debug "Motion active"
|
|
||||||
}
|
|
||||||
|
|
||||||
def motionInactiveHandler(evt)
|
|
||||||
{
|
|
||||||
// for backward compatibility
|
|
||||||
if (state.modeStartTime == null) {
|
|
||||||
subscribe(location, modeChangeHandler)
|
|
||||||
state.modeStartTime = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (correctMode() && correctTime()) {
|
|
||||||
runIn(minutes * 60, scheduleCheck, [overwrite: false])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def scheduleCheck()
|
|
||||||
{
|
|
||||||
log.debug "scheduleCheck, currentMode = ${location.mode}, newMode = $newMode"
|
|
||||||
|
|
||||||
if (correctMode() && correctTime()) {
|
|
||||||
if (allQuiet() && switchesOk()) {
|
|
||||||
takeActions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private takeActions() {
|
|
||||||
def message = "Goodnight! SmartThings changed the mode to '$newMode'"
|
|
||||||
send(message)
|
|
||||||
setLocationMode(newMode)
|
|
||||||
log.debug message
|
|
||||||
}
|
|
||||||
|
|
||||||
private correctMode() {
|
|
||||||
if (location.mode != newMode) {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
log.debug "Location is already in the desired mode: doing nothing"
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private correctTime() {
|
|
||||||
def t0 = now()
|
|
||||||
def modeStartTime = new Date(state.modeStartTime)
|
|
||||||
def startTime = timeTodayAfter(modeStartTime, timeOfDay, location.timeZone)
|
|
||||||
if (t0 >= startTime.time) {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
log.debug "The current time of day (${new Date(t0)}), is not in the correct time window ($startTime): doing nothing"
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private switchesOk() {
|
|
||||||
def result = true
|
|
||||||
for (it in (switches ?: [])) {
|
|
||||||
if (it.currentSwitch == "on") {
|
|
||||||
result = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.debug "Switches are all off: $result"
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
private allQuiet() {
|
|
||||||
def threshold = 1000 * 60 * minutes - 1000
|
|
||||||
def states = motionSensors.collect { it.currentState("motion") ?: [:] }.sort { a, b -> b.dateCreated <=> a.dateCreated }
|
|
||||||
if (states) {
|
|
||||||
if (states.find { it.value == "active" }) {
|
|
||||||
log.debug "Found active state"
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
def sensor = states.first()
|
|
||||||
def elapsed = now() - sensor.rawDateCreated.time
|
|
||||||
if (elapsed >= threshold) {
|
|
||||||
log.debug "No active states, and enough time has passed"
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
log.debug "No active states, but not enough time has passed"
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.debug "No states to check for activity"
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private send(msg) {
|
|
||||||
if (location.contactBookEnabled) {
|
|
||||||
sendNotificationToContacts(msg, recipients)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (sendPushMessage != "No") {
|
|
||||||
log.debug("sending push message")
|
|
||||||
sendPush(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (phoneNumber) {
|
|
||||||
log.debug("sending text message")
|
|
||||||
sendSms(phoneNumber, msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug msg
|
|
||||||
}
|
|
||||||
@@ -273,7 +273,7 @@ def scheduleCheck(evt) {
|
|||||||
else {
|
else {
|
||||||
if(people){
|
if(people){
|
||||||
//don't turn off lights if anyone is home
|
//don't turn off lights if anyone is home
|
||||||
if(someoneIsHome()){
|
if(someoneIsHome){
|
||||||
log.debug("Stopping Check for Light")
|
log.debug("Stopping Check for Light")
|
||||||
unschedule()
|
unschedule()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user