No Motion for a period of Time- Elderly Care


(Tim) #1

As a true Smart Things rookie, I bought the Smart things to monitor my elderly parent. I am looking to to set up a situation where if there is no movement, on a motion sensor, between 6am and noon that it notifies me,I just want to know she is up and getting around, and not in a medical emergency in the house. This would be when a presence sensor is in the home. There is one that is close in ELDERLY CARE in Smart Apps, but it is about be between the bathroom and the bedroom. I want it for one motion sensor, I could not get the one in the smart apps to do what I wanted reliability. Seems like a simple app, just have not been able to find it. Other than that, lovin the concept, I was testing it for this application, but might have to buy a second one for my own home use.


Logic to detect person not responding in bathroom
I have been given a project (medical wellness check)
#2

You can do this with a hello home action, the only trick is the first time you set it up you have to change the mode.

Putting in a mode change will then offer you two new scheduling options “when things start happening” or “when things quiet down”

The one you want is “when things quiet down” you can specify the amount of time a single motion sensor has been inactive, and you can limit that to specific time range.

You can have it send a text message, or do something else like turn light on or whatever.


(Ron) #3

@JDRoberts I have seen several posts about using “Hello Home” actions to do special tasks like this. The part that confuses me is this would work fine as long as this is the only thing you want ST to do. But once things start getting complicated adding “Modes” would make it hard to manage.

For example I currently have a rule to enable AC during the day when a temperature is reached. I have it set to only work during daytime modes (home and away) because at night it sometimes gets cool enough that we turn on heat, so I don’t want this rule detecting the heat and thinking it is too warm so AC is needed. So I don’t enable this rule when in “Goodnight” mode.

So adding modes means I have to return to this group and figure out what mode is daytime and what mode is night time. In this case “things start happening” and “think quiet down” could be happening in either day or night.

This makes me avoid using the modes most of the time since they can easily start conflict.

Or am I completely missing the point :smile:


#4

Yeah, I agree, it’s a weird requirement. It’s just the way ST wrote the setup wizard.


(Bruce) #5

I’d be happy to write a small app for you that does this.

I didn’t quite follow about the presence sensor, so please explain what you have in mind. Is it that the notification is only supposed to happen if a certain presence sensor is there?

Otherwise, any motion between 6am and noon would cancel a notification that would happen at noon, if there has been no motion since 6am. Correct?


(Bruce) #6

Here is a small app that sends a notification if there has been no motion during a period of time:

/**
 *  Notify if no motion
 *
 *  Copyright 2015 Bruce Ravenel
 *
 *  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: "Notify if no motion",
    namespace: "bravenel",
    author: "Bruce Ravenel",
    description: "Notify if no motion during some time period",
    category: "Family",
    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")


preferences {
	section("Which motion sensors?") {
		input "motions", "capability.motionSensor", title: "Motion(s):", required: true, multiple: true
	}
    
	section("Text me at (optional, sends a push notification if not specified)...") {
		input "phone", "phone", title: "Phone number?", required: false
	}
    section("Unless this presence sensor is not present...") {
	    input "presence1", "capability.presenceSensor", title: "Which presence?", required: false, multiple: false
    }

        section("If no motion between these times...") {
		input "starting", "time", title: "Starting", required: false
		input "ending", "time", title: "Ending", required: false
    }
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(motions, "motion.active", motionHandler)
        schedule(starting, startingTime)
        schedule(ending, endingTime)
}

def motionHandler(evt) {
	state.noMotion = false
}

def startingTime() {
	state.noMotion = true
}

def endingTime() {
    if(presence1) if(presence1.currentPresence == "not present") return
	if(state.noMotion) {
    	    def msg = "There has been no motion since $starting"
	    if (phone) sendSms(phone, msg)
            else sendNotification(msg)
	}
}

(Tim) #7

OK, there is an area that I could place a motion sensor ( in a hallway) that would notice movement, mom will have to go to the bathroom at least once ever X hours, so if there is not movement in that hallway in X hours that it would send me a notice seeing she always uses the same bathroom. I would want it not to send me a notice if the car keys are gone from the home. She will have no way to set AWAY options. The other elderly apps seem close, but not exact. I would think this would be a good thing to have for ANY home alone person, even myself. I think of people with diabetes, or other illness, not just old age that this would be beneficial to. I think all of us fear that situation where someone living alone might not be noticed missing for days when they don’t have regular routine like say going to work. I have been browsing through the community and blog section, seeing I am new, some of the stuff there seem a little over my head, as I am not real familiar with how it all works. Still wading through it… I noticed you just sent something in another email, can you explain how I get that loaded into my smartthings app? Do I need to sign up as a developer or something?

Thanks for the offer

Tim


(Bruce) #8

SmartThings is cool because it allows us to write our own apps. Some are really simple, like this one. Others are quite sophisticated (check out SmartTiles.click).

Go here: https://graph.api.smartthings.com

There you can get into the IDE. Once in the IDE click on My SmartApps. Then click on New SmartApp. Using copy and paste, copy the code I posted above. In the New SmartApp window, select the From Code tab. Then paste the code in, and click Create. Then click on Publish, and For Me.

At that point the app will be on your phone. Click on the + button on your dashboard. Then slide all the way to the right to My Apps, then click on “Notify if no motion”. From there you will go through the setup of the app with the motion sensor(s) you want, the time period, and how to notify you if there was no motion during that time period.


(Bruce) #9

Oh, I’ll think about the bit about not sending you a notification if the keys are gone (presence sensor). But, presumably, if she’s up and about and going somewhere, there will be motion. If there’s any motion, no notification is sent.

You can use multiple motion sensors if you want.


(Tim) #10

The issue is if she leaves the house (with the Prescience sensor) there will not be any movement, so that is why I wanted to include that IF THE SENSOR IS NOT HOME exception. Example, she goes shopping, it would notify me of no movement, but if I know she is not home, I will not be as concerned, I don’t need to be notified. I got your app on my phone, that part worked, still struggling with writing/editing an app, I assume there isn’t a WYSIWYG type app, it is all coding, I am new to that arena in general. How nice would it be to be able to just drag icons into a recipe and the coding was done in the back round… similar to a web site and HTML. Thanks for your help!


(Bruce) #11

Won’t there be movement before she leaves but after 6:00? The way this thing works is that once it’s seen any motion during the timeframe, it won’t notify you (whether she’s left or not).

I will add the selection of a presence sensor, the absence of which cancels any notification.

You can install multiple instances of the app to cover multiple time periods; just give each instance a different name.


(Bruce) #12

I modified the code above in the thread to include the presence sensor test.


(Linda Miller) #13

Can your parent be persuaded to wear the presence sensor?


(Scott Windmiller) #14

Could you not just have the app work only in certain modes. Then trigger the mode changes based off the presence sensor?


#15

This. :arrow_up::blush:

@bravenel is a great coder, but for some reason hates to use modes.

For most of us, the described use case is exactly when we do use modes. “Home” versus “away” in its most basic form.


(Bruce) #16

I don’t hate to use modes. I use them all the time. All simple apps when they are installed give the user the option of restricting the app to only work in certain modes. The app in this thread does that (look at very bottom of preferences screen). So @swindmiller can just update the app and restrict it to certain modes. :smile:

Edited to add:
If you read the code you won’t see anything about modes. These mode restrictions are handled by ST generically, not directly by the app. If the app is mode restricted this way, ST won’t run it unless the location is in one of the selected modes.


(Scott Windmiller) #17

I didn’t actually read the code…just my observation and suggestion :smile:
I think this app could be used by many.


(Tim) #18

Thanks Bruce and everyone for your input, I have tried my own programming with little luck, may work on it a little, just hindering me from putting it in action. Just to be clear. I am looking for a app that will tell me when mom is not moving around. A couple weeks ago she had a situation where she had a reaction to a med, and become ill, luckily she was not at home when it happened and was cared for, if she would have been at home alone, not sure if things would have turned out as well, cause the family lives all over the country and she doesn’t have a routine that would signal a crisis to anyone outside the home for maybe for several days. My goal would be to have it sense motion, if there is a period of time (say 4 hours) without her moving around, the house it would send out a text, that would signal us to check in on her (either call or have someone nearby check on her). The exception to that would be when she left the house to go shopping, visiting or volunteering. I would like to prevent a false alarm. I would put a presence sensor on her car keys, her car or her purse, or around her neck, so if she left the house, that would over ride notifying anyone. (are the presence senors waterproof, if not, I could she her leaving it in the bathroom if she took it off to bath?) Imagine getting a signal there was a problem, only to find out she was out shopping or something. I suppose I could log into the system and see if the senors was there, but that seems like a feature that would be easy for the experienced person to program. So features, Notify me if no motion for X minutes, if she is home between the hours of T1 to T2. (I don’t need to be notified if no movement in the middle of the night, that is kind of expected). This might included activation of one of two or three sensors, for instance, if she was outside on the patio, the inside one would not go off. My thought is a motion sensor in the hall by the kitchen/bathroom area, I suspect she would be there the most often, the hunger/bladder factor will put her there most often. Just trying to allow mom to have her freedom to live on her own, but the comfort for us to know she is OK, without calling her ever four hours or even once a day, not that we don’t enjoy talking to my mom, just trying to find a happy medium. Having called her with NO ANSWER only to find out she was out shopping (not passed out somewhere), does give the heart a few extra beats, especially after the second or third call. Any help from experienced programmers would be appreciated. If we got this to work, I know a few people who would buy this for their elderly parents, we share the same concerns. . Bruce;s code above does work, just some added features I thought of since the last post. Just a little something for a little piece of mind, anyone else have these needs??? Thanks again!! Tim


(Bruce) #19

Tim,
I’d be happy to add features that you need to the app. Just tell me what it is you want it to do / or not do, under what circumstances.


(Tim) #20

The more I think about it, what you have is close, I just need the presence sensor option added, the only other thing would be a door sensor OR motion sensor I think my motion sensor would cover the area I want, but maybe not for others. I can use the program multiple times to set smalller windows such as 6-10, 10- 2 and 2-6 as opposed to using it once from 6-6… Thanks again Bruce…