mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-12 21:03:11 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b040ba4f25 |
@@ -8,7 +8,6 @@ metadata {
|
||||
definition (name: "Zen Thermostat", namespace: "zenwithin", author: "ZenWithin") {
|
||||
capability "Actuator"
|
||||
capability "Thermostat"
|
||||
capability "Temperature Measurement"
|
||||
capability "Configuration"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
definition(
|
||||
name: "Check window is closed at night",
|
||||
namespace: "akbur",
|
||||
author: "Akbur Ghafoor",
|
||||
description: "Checks if your window is closed at night - if not, sends an SMS alert.",
|
||||
category: "Convenience",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png"
|
||||
)
|
||||
|
||||
preferences {
|
||||
section("When the window is open at night...") {
|
||||
input "contact1", "capability.contactSensor", title: "Where?"
|
||||
}
|
||||
section("Text me at...") {
|
||||
input("recipients", "contact", title: "Send notifications to") {
|
||||
input "phone1", "phone", title: "Phone number? (in interntional format, starting with +<country code>, e.g. +447739123456)"
|
||||
}
|
||||
}
|
||||
|
||||
section("Time to check at night") {
|
||||
input "time1", "time"
|
||||
}
|
||||
}
|
||||
|
||||
def installed()
|
||||
{
|
||||
subscribe(contact1, "contact", contactHandler)
|
||||
schedule(time1, checkWindowsHandler)
|
||||
}
|
||||
|
||||
def updated()
|
||||
{
|
||||
unsubscribe()
|
||||
subscribe(contact, "contact", contactHandler)
|
||||
schedule(time1, checkWindowsHandler)
|
||||
}
|
||||
|
||||
def checkWindowsHandler()
|
||||
{
|
||||
if (state.windowsopen)
|
||||
{
|
||||
sendSms(phone1, "WARNING: Your ${contact1.label ?: contact1.name} is OPEN.")
|
||||
}
|
||||
}
|
||||
|
||||
def contactHandler(evt) {
|
||||
|
||||
if("open" == evt.value)
|
||||
{
|
||||
// contact is open, log it for the night check
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
state.windowsopen = true;
|
||||
}
|
||||
if("closed" == evt.value)
|
||||
{
|
||||
// contact was closed, log it for the night check
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
state.windowsopen = false;
|
||||
}
|
||||
}
|
||||
86
smartapps/jls/bathroom-lights.src/bathroom-lights.groovy
Normal file
86
smartapps/jls/bathroom-lights.src/bathroom-lights.groovy
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Bathroom Lights
|
||||
*
|
||||
* Copyright 2015 Jesse Silverberg
|
||||
*
|
||||
* 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: "Bathroom Lights",
|
||||
namespace: "JLS",
|
||||
author: "Jesse Silverberg",
|
||||
description: "A specialized bathroom lighting automation. Turns lights on with motion, dims after a custom period of time to give the occupant a warning that lights will turn off soon, and then turns off the lights unless motion is detected again. Motion brightens the lights back up. Perfect for showering so you don't get left in the dark, and solves the problem of motion detection during lights-off dimming transitions.",
|
||||
category: "Convenience",
|
||||
iconUrl: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1",
|
||||
iconX2Url: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1",
|
||||
iconX3Url: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1")
|
||||
|
||||
|
||||
preferences {
|
||||
|
||||
section("Select devices") {
|
||||
input "lights", "capability.switchLevel", title:"Bathroom lights", multiple: true , required: true
|
||||
input "motionSensor", "capability.motionSensor", title: "Bathroom motion sensor(s)", multiple: true, required: true
|
||||
}
|
||||
section("Brightness and timing options") {
|
||||
input "dimLevelHi", "number", title: "Brighten lights to this level (0-100)...", required: true
|
||||
input "brightenTimeHi", "number", title: "Hold lights here for this long (minutes)...", required: true
|
||||
input "dimLevelLow", "number", title: "Then dim lights to this level (0-100)...", required: true
|
||||
input "brightenTimeLow", "number", title: "And turn off after this long (minutes)...", required: true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
subscribe(motionSensor, "motion.active", motionDetectedHandler)
|
||||
subscribe(motionSensor, "motion.inactive", motionStoppedHandler)
|
||||
}
|
||||
|
||||
def motionDetectedHandler(evt) {
|
||||
log.debug "motionDetectedHandler called: $evt"
|
||||
unschedule()
|
||||
lights.setLevel(dimLevelHi)
|
||||
}
|
||||
|
||||
def motionStoppedHandler(evt) {
|
||||
log.debug "motionStoppedHandler called: $evt"
|
||||
|
||||
def noMotion = motionSensor.find{it.currentMotion == "active"} == null
|
||||
if (noMotion) {
|
||||
log.debug "motionStoppedHandler found no motion on all sensors"
|
||||
log.debug "Scheduling lights to dim and turn off"
|
||||
runIn(60 * brightenTimeHi, dimLights)
|
||||
runIn(60 * (brightenTimeHi + brightenTimeLow), offLights)
|
||||
}
|
||||
}
|
||||
|
||||
def dimLights() {
|
||||
log.debug "Dimming lights $lights to $dimLeveLow"
|
||||
lights.setLevel(dimLevelLow)
|
||||
}
|
||||
|
||||
def offLights() {
|
||||
log.debug "Turning off lights $lights"
|
||||
lights.off()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user