Compare commits

...

3 Commits

Author SHA1 Message Date
Nick Mahon
1a29df7693 Modifying 'Reminder to Close Windows after leaving house (via presence sensor)' 2017-02-13 07:21:28 -08:00
Nick Mahon
2c4a177630 MSA-1779: app to remind residents, via a presence sensor, to return to the house and close windows. 2017-02-13 07:19:31 -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

View File

@@ -0,0 +1,73 @@
definition(
name: "Shut the windows!",
namespace: "nick257",
author: "Nick Mahon",
description: "Notifies when last person leaves without closing doors or windows.",
category: "Safety & Security",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/bon-voyage.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/bon-voyage%402x.png"
)
preferences
{
section("As the last of these persons leaves") {
input "people", "capability.presenceSensor", multiple: true
}
section("Check that these are closed") {
input "doors", "capability.contactSensor", multiple: true
}
section("Send Push Notification?") {
input "sendPush", "bool", required: false,
title: "Send Push Notification when Opened?"
}
section("Send a text message to this number (optional)") {
input "phone", "phone", required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(people, "presence", presence)
}
def presence(evt)
{
log.debug "evt.name: $evt.value, $evt.deviceId"
if (evt.value == "not present") {
log.debug "isSomeonePresent()? ${isSomeonePresent()}"
log.debug "isDoorsOpen()? ${isDoorsOpen()}"
if (!isSomeonePresent() && isDoorsOpen()) {
def device = people.find { it.id == evt.deviceId }
log.debug "${device.displayName} left ${location.name} without closing ${isDoorsOpen().join(", ")}"
def message = "${device.displayName} left ${location.name} without closing ${isDoorsOpen().join(", ")}"
if (sendPush) {
sendPush(message)
}
if (phone) {
sendSms(phone, message)
}
}
}
}
def isSomeonePresent() {
log.debug "presence: $people.currentPresence"
people.findAll{it.currentPresence == "present"}
}
def isDoorsOpen() {
log.debug "doorss: $doors.currentContact"
doors.findAll{it.currentContact == "open"}
}