Know a door is not shut when mode changes to away?


(Brian Smith) #1

Looking for an app or option for the following scenario:

Immediate notification that a door is not closed (left open) when a mode changes, such as to away.

We use presence fobs and iPhone geofencing to track when everyone has left. I noticed today that we left, the door locked, but the door was not shut. I did not know that until I happened to look at the app for something else.

I already have options set to notify when a door opens or closes when I’m away, but this is different. This is an immediate notification during a shift between modes. I already use the door left open option to tell us if the door is left open for too long (again there is a timeout) since we have cats. It still seems that this is different?


(Chrisb) #2
/**
 *  Ubi Goodnight Check
 *
 *  Author: seateabee@gmail.com
 *  Date: 2014-03-25
 * 
 *  This app uses three virtual tiles and any number of open/close sensors as well as 
 *  lights.  One virtual tile will be turned on by UBI, which still trigger the program 
 *  to run.  The three things will happen: A.) If any doors are open, the second virtual 
 *  tile will be turned on.  This will cause UBI to warn that a door is open. B.) If any
 *  windows are open, the third virtual tile will be turned on.  This will cause UBI to 
 *  warn that a window is open. C.) after a five minute wait, all specified lights and 
 *  the three virtual devices will be turned off.
 *
 *  What you need to do on the UBI side:
 *		- Setup your SmartThings as a device in thr Ubi Portal (still in Beta as of 3/25/14).
 *		- Create a custom behavior when you say a phrase (such as: Goodnight) that Ubi
 *		  will turn the first Virtual Tile.  (I also have Ubi say to me: "Checking windows
 *		  and doors, turning off lights in 5 minutes" so I know Ubi heard me right.)
 *		- Create a custom behavior when virtual tile 2 turns on that Ubi will say:
 *		  "You have a door open."
 *		- Create a custom behavior when virtual tile 3 turns on that Ubi will say:
 *		  "You have a window open."
 */
 

// Automatically generated. Make future change here.
definition(
    name: "Ubi Goodnight Check",
    namespace: "",
    author: "seateabee@gmail.com",
    description: "This app uses three virtual tiles and any number of open/close sensors as well as lights.  One virtual tile will be turned on by UBI, which still trigger the program to run.  The three things will happen: A.) If any doors are open, the second virtual tile will be turned on.  This will cause UBI to warn that a door is open. B.) If any windows are open, the third virtual tile will be turned on.  This will cause UBI to warn that a window is open. C.) after a five minute wait, all specified lights and the three virtual devices will be 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%402x.png"
)

preferences {
	section("Which Virtual Switch is the Trigger?") {
		input "trigger", "capability.switch", title: "Which?"
	}
	section("Which Virtual Switch is the Door Check?") {
		input "doorCheck", "capability.switch", title: "Which?"
	}
	section("Which Virtual Switch is the Window Check?") {
		input "windowCheck", "capability.switch", title: "Which?"
	}
	section("Which light switches will I be turning off?") {
		input "theSwitches", "capability.switch", Title: "Which?", multiple: true, required: false
	}
	section("Which doors should I check?"){
		input "doors", "capability.contactSensor", title: "Which?", multiple: true, required: false
    }
    section("Which windows should I check?"){
		input "windows", "capability.contactSensor", title: "Which?", multiple: true, required: false
    }
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(trigger, "switch.on", switchOnHandler)
}

def switchOnHandler(evt) {
	checkDoors()
    checkWindows()
    runIn (300, lightsOut)
}

def checkDoors() {
	def open = doors.findAll { it?.latestValue("contact") == "open" }
    if(open) {
    	doorCheck.on()
    }
}

def checkWindows() {
	def open = windows.findAll { it?.latestValue("contact") == "open" }
    if(open) {
    	windowCheck.on()
    }
}

def lightsOut() {
	trigger.off()
    doorCheck.off()
    windowCheck.off()
    theSwitches.off()
}

'
This is an app I created for use with my Ubi. It performs a similar function: When I say ‘goodnight’ to Ubi, it check all included door and window sensors. The app is activated by UBI turning on a virtual switch. If a door or window is open, the app turns on another virtual switch. Ubi is set to watch for this switch turn on, and if it does, then it says: “Wait, a door (or window) is open!”

You should be able to adapt this relatively easily. Have a switch set so that as soon as mode is changed to away, it turn on the switch. Can instead of turn on other virtual switches, it sends a text message or whatever notification you want.


(Longhorn84) #3

Really cool Ubi integration. What else have you done with Ubi?


(Chrisb) #4

I have a couple of simple things: Turn on the Kitchen Lights, turn off the Kitchen lights. Also Dinning Room lights. I have it announce when my car or my wife’s car arrives home based on the presence sensors in the cars. When my wife comes home Ubi says: “Let it be known to all… the Queen’s chariot has arrived!”

Then I have it setup for openning and closing my garage doors as well. This is a more complex setup and uses virtual on/off tiles like the above example. I have separate doors for the two stalls in my garage and unfortunately Ubi seems to have a hard time with names so instead of naming the doors (ie: Open Chris’ Garage) I the utterances setup as Garage Door (my wife’s) and Car Door (mine).

So when I say: “Open the Garage Door” Ubi says: “Opening the Garage” and then trips a virtual tile. That, just the like above example, runs a program. The program checks to see if the door is already open:

  • If it is, it turns on a second tile that Ubi watches. If Ubi sees this tile turn on it says: “The Garage is already open.”
  • If it isn’t open, the App opens the door.

Then the app waits 2 minutes and shuts off all the virtual tiles involved.
Likewise, if I say “Close the Garage Door” Ubi trips a tile that runs that same program, but now it looks for a closed garage door and responds appropriately.

Then I’ve got this whole setup installed twice so that I can run it with “Open/Close the Car Door” as well.

As I said this is a much more complex setup. You could make it much simpler by just saying having a custom behavior that when you say: “Toggle the Garage Door” it flips the relay that you have attached to your garage. But I’m trying to make Ubi as ‘natural language’ as possible so I didn’t want to have to check my garage doors before asking Ubi to toggle it open or closed. I wanted to be able to say: Open or Close and only have the system perform that action is needed.


(Chrisb) #5

Also wanted to add that I’m hope we will soon be able to send text strings right to Ubi. It’ll say a lot of this extra Virtual On/Off work and slim down the number of Custom Behaviors needed in Ubi. When we can do this I’ll also probably look at reworking the ‘Goodnight’ app so that instead of just say: “A door is open” or “A window is open” it will actually say: “The side door is open” or the “Living room window is open.”


(Brian Smith) #6

Unfortunately, I’m not a coder (yet). So it would probably be difficult to adapt. I’ll keep an eye out and hopefully someone has something. However, I am interested in an Ubi-like interface (aka voice). Years ago I researched using a PC-based app, whose name escapes me, and someone made microphone/speaker combos that could fit in a single gang box.


(Longhorn84) #7

I think all voice activated systems right now will require some coding. The Ubi works but it’s $300 and it has it’s quirks no doubt. I think another was called CastleOS, you could look at that. Or wait until Siri and ST get married up.


(Chrisb) #8

Yeah, Ubi definitely has it’s quirks… I was sorely tempted to back them originally, but then didn’t. I ended up getting one off eBay later because of the ST integration. My primary use, right now, it to be able to do some SmartThings stuff. Because my wife doesn’t carry a phone and I don’t have my phone with me regularly at home, I wanted a way to be able to do some basic stuff simply… and Ubi does that well enough. It also provides a way for my SmartHome to talk to me, which is cool.

But there are still limitations. Voice recognition just isn’t to the JARVIS or Star Trek level… yet. This is why I didn’t originally back Ubi.

For one, Ubi is optimized for a 5-10 foot distance. It’ll work beyond that, but the further you get, the less likely it is to hear you clearly. There are also issues with background noise, though not as bad as I expected. If you speak loudly Ubi can usually pick up your voice and ignore the background noise (other talking, TV).

And of course there’s the delay. I liken it to iPhone commercials, especially those old “There’s an App for that” ones. They always show the phone instantly opening the app, then going right to where the user needs. Then if you read the fine print it said: “Screen sequences shortened.” In other words, there’s a number of steps involved between turning on your phone and opening the app and scrolling to the area and loading that page and scrolling to the right spot on the page and clicking the button…

Ubi is the same way. In my head I see this idea of issuing the command: “Turn on the kitchen lights!” and bam… lights go on. Instead, it goes like this: Say: “Ok Ubi”. Ubi beeps to let you know it heard you Wait a 1/2 second after the beep for Ubi to turn green. Then says “Turn on the Kitchen lights.” Ubi turns off green light Wait a half second, then the Kitchen light goes on. It’s still pretty quick… assuming Ubi understands you the first time, but it isn’t instantaneous.


(Brian Smith) #9

Somehow my thread got hijacked! :smiley:

That’s ok. Good stuff. Still looking for a simple solve, though, to the original issue.

As for the hijack… What I would love to see is Apple add “voice boxes” for rooms to the appletv. Imagine “Hey Siri” anywhere in the house without an iDevice in hand + HomeKit + SmartThings!


(Jim) #10

also interested in this - surprised it’s not built in already. I just really don’t have the time to make the app myself.


(Chrisb) #11

Probably the reason it isn’t built in is that most of the canned functions are based on a trigger from the device itself. For example: “When the door opens, sound the alarm” or “When the door closed turn off this light.” In this case the trigger is a mode change, not a device state change and instead of performing a specific task (turn on light, shut off outlet, etc) you need to poll a device and THEN perform an action based on that devices status. It’s just more complex… certainly not impossible, but more complex.

The next two-three weeks are going to be VERY busy for me, but if I find some time I might try to take a look at this and see what I can do. If I haven’t added anything to this thread by Sept. 15, bump it for me as a reminder. (Assuming of course someone else doesn’t tackle it first.)


(Greg B) #12

Looks like no one ever solved your problem. I actually wrote an app to do this. It will tell me if I left my garage door open when I left or at a specific time (like 9PM).

Look for the “Is It Closed?” app in this thread or from the shared code library.


(Jim) #13

Nice - thank you!

One suggestion - it would be cool if you could just setup the app once and select all the door/windows you want to monitor. I tried changing the multiple value to true for contact preference but it didn’t work.

No biggie though - it works like a charm!

Thanks again!


(Alex) #14

There’s an app for that! It lets you pick a set of contact and presence sensors to monitor. When last person leaves and a door is left open, it will notify who that person was and which door is open.

I made it especially for my wife who kept going out without closing doors.


(jeff) #15

Added a routine to check for doors open when changing mode to Night. Havent programmed for years, so cant guarantee this is great.

definition(
name: “Night/Away without closing door/window”,
namespace: “JeffGould1234”,
author: “Jeff Gould”,
description: “Notifies when mode changes to night/away 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)
subscribe(location, “mode”, modeChangeHandler)
}

def modeChangeHandler(evt) {
log.debug "!!! ${evt.value} and ${isDoorsOpen()}"
if (isDoorsOpen() && evt.value == “Night”) {
log.debug "NIGHT & Door is Open"
def message = "The ${isDoorsOpen()} is open!"
if (sendPush) {
sendPush(message)
}
if (phone) {
sendSms(phone, message)
}
}
}

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(”, ")}"
sendPush “${device.displayName} left ${location.name} without closing ${isDoorsOpen().join(”, “)}”
}
}
}

def isSomeonePresent() {
log.debug "presence: $people.currentPresence"
people.findAll{it.currentPresence == “present”}
}

def isDoorsOpen() {
log.debug "doorss: $doors.currentContact"
doors.findAll{it.currentContact == “open”}
}