mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 13:21:53 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
746b9a6a38 | ||
|
|
98000fa57d | ||
|
|
587b3295ae | ||
|
|
9538df65e5 | ||
|
|
6854665f68 | ||
|
|
2534afbf81 | ||
|
|
eb3d0c2874 |
@@ -346,8 +346,8 @@ def getTemperature(value) {
|
||||
log.debug "Acceleration"
|
||||
def name = "acceleration"
|
||||
def value = numValue.endsWith("1") ? "active" : "inactive"
|
||||
//def linkText = getLinkText(device)
|
||||
def descriptionText = "was $value"
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = "$linkText was $value"
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
[
|
||||
name: name,
|
||||
|
||||
@@ -8,6 +8,7 @@ metadata {
|
||||
definition (name: "Zen Thermostat", namespace: "zenwithin", author: "ZenWithin") {
|
||||
capability "Actuator"
|
||||
capability "Thermostat"
|
||||
capability "Temperature Measurement"
|
||||
capability "Configuration"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* 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()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Author: LGKahn kahn-st@lgk.com
|
||||
* version 2 user defineable timeout before checking if door opened or closed correctly. Raised default to 25 secs. can reduce to 15 if you have custom simulated door with < 6 sec wait.
|
||||
*/
|
||||
|
||||
definition(
|
||||
name: "LGK Virtual Garage Door",
|
||||
namespace: "lgkapps",
|
||||
author: "lgkahn kahn-st@lgk.com",
|
||||
description: "Sync the Simulated garage door device with 2 actual devices, either a tilt or contact sensor and a switch or relay. The simulated device will then control the actual garage door. In addition, the virtual device will sync when the garage door is opened manually, \n It also attempts to double check the door was actually closed in case the beam was crossed. ",
|
||||
category: "Convenience",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact@2x.png"
|
||||
)
|
||||
|
||||
preferences {
|
||||
section("Choose the switch/relay that opens closes the garage?"){
|
||||
input "opener", "capability.switch", title: "Physical Garage Opener?", required: true
|
||||
}
|
||||
section("Choose the sensor that senses if the garage is open closed? "){
|
||||
input "sensor", "capability.contactSensor", title: "Physical Garage Door Open/Closed?", required: true
|
||||
}
|
||||
|
||||
section("Choose the Virtual Garage Door Device? "){
|
||||
input "virtualgd", "capability.doorControl", title: "Virtual Garage Door?", required: true
|
||||
}
|
||||
|
||||
section("Choose the Virtual Garage Door Device sensor (same as above device)?"){
|
||||
input "virtualgdbutton", "capability.contactSensor", title: "Virtual Garage Door Open/Close Sensor?", required: true
|
||||
}
|
||||
|
||||
section("Timeout before checking if the door opened or closed correctly?"){
|
||||
input "checkTimeout", "number", title: "Door Operation Check Timeout?", required: true, defaultValue: 25
|
||||
}
|
||||
|
||||
section( "Notifications" ) {
|
||||
input("recipients", "contact", title: "Send notifications to") {
|
||||
input "sendPushMessage", "enum", title: "Send a push notification?", options: ["Yes", "No"], required: false
|
||||
input "phone1", "phone", title: "Send a Text Message?", required: false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def installed()
|
||||
{
|
||||
def realgdstate = sensor.currentContact
|
||||
def virtualgdstate = virtualgd.currentContact
|
||||
//log.debug "in installed ... current state= $realgdstate"
|
||||
//log.debug "gd state= $virtualgd.currentContact"
|
||||
|
||||
subscribe(sensor, "contact", contactHandler)
|
||||
subscribe(virtualgdbutton, "contact", virtualgdcontactHandler)
|
||||
|
||||
// sync them up if need be set virtual same as actual
|
||||
if (realgdstate != virtualgdstate)
|
||||
{
|
||||
if (realgdstate == "open")
|
||||
{
|
||||
virtualgd.open()
|
||||
}
|
||||
else virtualgd.close()
|
||||
}
|
||||
}
|
||||
|
||||
def updated()
|
||||
{
|
||||
def realgdstate = sensor.currentContact
|
||||
def virtualgdstate = virtualgd.currentContact
|
||||
//log.debug "in updated ... current state= $realgdstate"
|
||||
//log.debug "in updated ... gd state= $virtualgd.currentContact"
|
||||
|
||||
|
||||
unsubscribe()
|
||||
subscribe(sensor, "contact", contactHandler)
|
||||
subscribe(virtualgdbutton, "contact", virtualgdcontactHandler)
|
||||
|
||||
// sync them up if need be set virtual same as actual
|
||||
if (realgdstate != virtualgdstate)
|
||||
{
|
||||
if (realgdstate == "open")
|
||||
{
|
||||
log.debug "opening virtual door"
|
||||
mysend("Virtual Garage Door Opened!")
|
||||
virtualgd.open()
|
||||
}
|
||||
else {
|
||||
virtualgd.close()
|
||||
log.debug "closing virtual door"
|
||||
mysend("Virtual Garage Door Closed!")
|
||||
}
|
||||
}
|
||||
// for debugging and testing uncomment temperatureHandlerTest()
|
||||
}
|
||||
|
||||
def contactHandler(evt)
|
||||
{
|
||||
def virtualgdstate = virtualgd.currentContact
|
||||
// how to determine which contact
|
||||
//log.debug "in contact handler for actual door open/close event. event = $evt"
|
||||
|
||||
if("open" == evt.value)
|
||||
{
|
||||
// contact was opened, turn on a light maybe?
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
// reset virtual door if necessary
|
||||
if (virtualgdstate != "open")
|
||||
{
|
||||
mysend("Garage Door Opened Manually syncing with Virtual Garage Door!")
|
||||
virtualgd.open()
|
||||
}
|
||||
}
|
||||
if("closed" == evt.value)
|
||||
{
|
||||
// contact was closed, turn off the light?
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
//reset virtual door
|
||||
if (virtualgdstate != "closed")
|
||||
{
|
||||
mysend("Garage Door Closed Manually syncing with Virtual Garage Door!")
|
||||
virtualgd.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def virtualgdcontactHandler(evt) {
|
||||
// how to determine which contact
|
||||
def realgdstate = sensor.currentContact
|
||||
//log.debug "in virtual gd contact/button handler event = $evt"
|
||||
//log.debug "in virtualgd contact handler check timeout = $checkTimeout"
|
||||
|
||||
if("open" == evt.value)
|
||||
{
|
||||
// contact was opened, turn on a light maybe?
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
// check to see if door is not in open state if so open
|
||||
if (realgdstate != "open")
|
||||
{
|
||||
log.debug "opening real gd to correspond with button press"
|
||||
mysend("Virtual Garage Door Opened syncing with Actual Garage Door!")
|
||||
opener.on()
|
||||
runIn(checkTimeout, checkIfActuallyOpened)
|
||||
|
||||
}
|
||||
}
|
||||
if("closed" == evt.value)
|
||||
{
|
||||
// contact was closed, turn off the light?
|
||||
log.debug "Contact is in ${evt.value} state"
|
||||
if (realgdstate != "closed")
|
||||
{
|
||||
log.debug "closing real gd to correspond with button press"
|
||||
mysend("Virtual Garage Door Closed syncing with Actual Garage Door!")
|
||||
opener.on()
|
||||
runIn(checkTimeout, checkIfActuallyClosed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private mysend(msg) {
|
||||
if (location.contactBookEnabled) {
|
||||
log.debug("sending notifications to: ${recipients?.size()}")
|
||||
sendNotificationToContacts(msg, recipients)
|
||||
}
|
||||
else {
|
||||
if (sendPushMessage != "No") {
|
||||
log.debug("sending push message")
|
||||
sendPush(msg)
|
||||
}
|
||||
|
||||
if (phone1) {
|
||||
log.debug("sending text message")
|
||||
sendSms(phone1, msg)
|
||||
}
|
||||
}
|
||||
|
||||
log.debug msg
|
||||
}
|
||||
|
||||
|
||||
def checkIfActuallyClosed()
|
||||
{
|
||||
def realgdstate = sensor.currentContact
|
||||
def virtualgdstate = virtualgd.currentContact
|
||||
//log.debug "in checkifopen ... current state= $realgdstate"
|
||||
//log.debug "in checkifopen ... gd state= $virtualgd.currentContact"
|
||||
|
||||
|
||||
// sync them up if need be set virtual same as actual
|
||||
if (realgdstate == "open" && virtualgdstate == "closed")
|
||||
{
|
||||
log.debug "opening virtual door as it didnt close.. beam probably crossed"
|
||||
mysend("Resetting Virtual Garage Door to Open as real door didn't close (beam probably crossed)!")
|
||||
virtualgd.open()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
def checkIfActuallyOpened()
|
||||
{
|
||||
def realgdstate = sensor.currentContact
|
||||
def virtualgdstate = virtualgd.currentContact
|
||||
//log.debug "in checkifopen ... current state= $realgdstate"
|
||||
//log.debug "in checkifopen ... gd state= $virtualgd.currentContact"
|
||||
|
||||
|
||||
// sync them up if need be set virtual same as actual
|
||||
if (realgdstate == "closed" && virtualgdstate == "open")
|
||||
{
|
||||
log.debug "opening virtual door as it didnt open.. track blocked?"
|
||||
mysend("Resetting Virtual Garage Door to Closed as real door didn't open! (track blocked?)")
|
||||
virtualgd.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user