Compare commits

...

7 Commits

Author SHA1 Message Date
narges noori
9558191c49 MSA-1782: This is a convenience application: We have a TV in our lab which is always on and causes a lot of distraction for people who are working there. The purpose of this application is manage the time that the screen is on as follows: The application turns on the outlet if the entrace door opens (multipurpose sensor) and there is motion in front of the motion sensor for a user defined amount of time (say 5 minutes). If there is no activity in front of the motion sensor for a user defined amount of time (say 10 minutes) the outlet is turned off. 2017-02-13 12:58:50 -08:00
Vinay Rao
2d82b05f90 Merge pull request #1660 from SmartThingsCommunity/staging
Rolling down staging hotfixes to master
2017-02-09 17:54:06 -06:00
Vinay Rao
1611fd0144 Merge pull request #1640 from skt123/device_filtering_1
[CHANGE-840] Adding new capabilities to DTHs
2017-02-09 17:51:50 -06:00
Vinay Rao
c416c39ac4 Merge pull request #1639 from pchomal/devicefiltering1
[CHANGE-839] Adding New Capabilities (Light & Outlet)
2017-02-09 17:51:19 -06:00
Vinay Rao
bc0f849dad Merge pull request #1655 from SmartThingsCommunity/master
Rolling up master to staging
2017-02-07 14:24:23 -08:00
sushant.k1
f164b8832c [CHANGE-840]
Added new capabilities for following DTHs:
1. Dimmer Switch
2. Zigbee RGB Bulb
3. Zigbee Dimmer
2017-02-03 16:33:30 +05:30
piyush.c
2d3fa22e07 [CHANGE-839]
Adding New Capabilities (Light & Outlet) to the DTHs
2017-02-03 16:22:56 +05:30
8 changed files with 187 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ metadata {
capability "Switch"
capability "Switch Level"
capability "Health Check"
capability "Light"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,1000", outClusters: "0000,0019"
}

View File

@@ -21,6 +21,7 @@ metadata {
capability "Refresh"
capability "Sensor"
capability "Health Check"
capability "Light"
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "GE In-Wall Smart Dimmer "
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "GE In-Wall Smart Dimmer "

View File

@@ -23,6 +23,8 @@ metadata {
capability "Refresh"
capability "Sensor"
capability "Health Check"
capability "Light"
capability "Outlet"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B04,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3200", deviceJoinName: "Outlet"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B04,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3200-Sgb", deviceJoinName: "Outlet"

View File

@@ -20,6 +20,7 @@ metadata {
capability "Switch"
capability "Switch Level"
capability "Health Check"
capability "Light"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008"

View File

@@ -28,6 +28,7 @@ metadata {
capability "Switch"
capability "Switch Level"
capability "Health Check"
capability "Light"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"

View File

@@ -29,6 +29,7 @@ metadata {
capability "Switch"
capability "Switch Level"
capability "Health Check"
capability "Light"
attribute "colorName", "string"
command "setGenericName"

View File

@@ -26,6 +26,7 @@ metadata {
capability "Refresh"
capability "Switch"
capability "Switch Level"
capability "Light"
attribute "colorName", "string"
command "setGenericName"

View File

@@ -0,0 +1,179 @@
/**
* Switch control based on motion/door sensors
*
* Copyright 2017 narges noori
*
* 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: "Switch control based on motion/door sensors",
namespace: "nnoori0527",
author: "narges noori",
description: "This application turns on the outlet if the entrace door opens (multipurpose sensor) and there is motion in front of the motion sensor for a user defined amount of time (say 5 minutes). If there is no activity in front of the motion sensor for a user defined amount of time (say 10 minutes) the outlet is turned off.",
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",
oauth: [displayName: "Switch/outlet control", displayLink: ""])
preferences {
section ("Allow external service to control these things...") {
input "switches", "capability.switch", multiple: true, required: true
}
section("Turn on when motion detected after someone opens the door:") {
input "motionSensor", "capability.motionSensor", required: true, title: "Where?"
}
section("Turn on when there's movement for:") {
input "minutes", "number", required: true, title: "Minutes to turn on TV?"
}
section("Turn on when there's movement for:") {
input "minutesInactive", "number", required: true, title: "Minutes to wait before turning off TV?"
}
section("Turn on when door open:") {
input "doorOpenCloseDetector", "capability.contactSensor", required: true, title: "Where?"
}
section("Turn on this outlet") {
input "tvOutlet", "capability.switch", required: true
}
}
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
def initialize() {
subscribe(doorOpenCloseDetector, "contact.open", doorOpenedHandler)
subscribe(motionSensor, "motion.inactive", motionStoppedHandler)
}
def doorOpenedHandler(evt){
log.debug "doorOpenedHandler called: $evt"
runIn(60 * minutes, checkMotion)
//tvOutlet.on()
}
def checkMotion() {
log.debug "In checkMotion scheduled method"
def motionState = motionSensor.currentState("motion")
if (motionState.value == "active") {
// get the time elapsed between now and when the motion reported inactive
def elapsed = now() - motionState.date.time
// elapsed time is in milliseconds, so the threshold must be converted to milliseconds too
def threshold = 1000 * 60 * minutes
if (elapsed <= threshold) {
log.debug "Motion has stayed active long enough since last check ($elapsed ms): turning outlet on"
//myswitch.on()
tvOutlet.on()
} else {
log.debug "Motion has not stayed active long enough since last check ($elapsed ms): doing nothing"
}
} else {
// Motion active; just log it and do nothing
log.debug "Motion is inactive, do nothing and wait for active"
}
}
def motionStoppedHandler(evt) {
log.debug "motionStoppedHandler called: $evt"
runIn(60 * (minutesInactive+1), checkMotionTurnOff)
}
def checkMotionTurnOff() {
log.debug "In checkMotionTurnOff scheduled method"
def motionState = motionSensor.currentState("motion")
if (motionState.value == "inactive") {
// get the time elapsed between now and when the motion reported inactive
def elapsed = now() - motionState.date.time
// elapsed time is in milliseconds, so the threshold must be converted to milliseconds too
def threshold = 1000 * 60 * minutesInactive
if (elapsed >= threshold) {
log.debug "Motion has stayed inactive long enough since last check ($elapsed ms): turning switch off"
tvOutlet.off()
} else {
log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms): doing nothing"
}
} else {
// Motion active; just log it and do nothing
log.debug "Motion is active, do nothing and wait for inactive"
}
}
mappings {
path("/switches") {
action: [
GET: "listSwitches"
]
}
path("/switches/:command") {
action: [
PUT: "updateSwitches"
]
}
}
// returns a list like
// [[name: "kitchen lamp", value: "off"], [name: "bathroom", value: "on"]]
def listSwitches() {
def resp = []
switches.each {
resp << [name: it.displayName, value: it.currentValue("switch")]
}
return resp
}
void updateSwitches() {
// use the built-in request object to get the command parameter
def command = params.command
// all switches have the comand
// execute the command on all switches
// (note we can do this on the array - the command will be invoked on every element
switch(command) {
case "on":
switches.on()
break
case "off":
switches.off()
break
default:
httpError(400, "$command is not a valid command for all switches specified")
}
}