I have a similar situation with my dad. First what I have implemented and then what I’d suggest. The big difference isn’t that I didn’t set this up to have him call me if there is trouble. He can do that already without all this other stuff. Instead I wanted a way to see if something is wrong when he can’t/won’t call for help so I have motion sensors to make sure he is up and moving around. If he doesn’t move for too long I can reach out to find out how he is feeling or if he need help.
Note, this is not an emergency type system. If he has a heart attack this won’t save him. That’s not what the system is intended to provide. It’s mainly just a way to see that all is generally normal. It is only as intrusive as he was comfortable with. And in point of fact, as a monitoring system it’s really pretty useless actually. For something like that I’d recommend a professionally designed and implemented system.
I’ve set up an RPi with a zwave dongle to deploy at my dad’s house. I’ve configured it to connect to my OpenVPN when it boots up so I can see the machine and administer it. It also makes it easier for the openHAB running there to talk to my openHAB instance.
I’ve openHAB running and I’ve set up some motion sensors.
Every time motion is detected I get a notification of that on my openHAB instance using the Remote openHAB binding. I’ve a rule that will send me an email and notification if there is an extended period of no motion, configurable. I wrote the rule so that if the timer will go off at night, it will forward it to the next morning.
triggers:
- id: "1"
configuration:
itemName: DadsSensors_LR_Motion
state: ON
type: core.ItemStateChangeTrigger
- id: "2"
configuration:
itemName: Dads_Motion_Timeout
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
type: application/javascript
script: >
var logger =
Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Dad
Motion");
this.ZonedDateTime = (this.ZonedDateTime === undefined) ? Java.type("java.time.ZonedDateTime") : this.ZonedDateTime
var OPENHAB_CONF = java.lang.System.getenv("OPENHAB_CONF");
load(OPENHAB_CONF+'/automation/lib/javascript/community/timerMgr.js');
load(OPENHAB_CONF+'/automation/lib/javascript/community/timeUtils.js');
load(OPENHAB_CONF+'/automation/lib/javascript/personal/alerting.js');
if(timers === undefined) {
logger.info("TimerMgr doesn't already exist");
}
var timers = (timers === undefined) ? new TimerMgr() : this.timers;
// Record the time of last motion
logger.info("event == " + event);
if(event.itemName == "DadsSensors_LR_Motion") {
events.postUpdate("DadsSensors_LR_Motion_Lastupdate", new DateTimeType().toString());
}
// If it's not set move the timout to 12 hours
var timerHours = 12;
logger.info("Timeout is " + items["Dads_Motion_Timeout"]);
if(items["Dads_Motion_Timeout"].class == UnDefType.class) {
events.postUpdate("Dads_Motion_Timeout", "12");
}
else {
timerHours = items["Dads_Motion_Timeout"];
}
// Calculate the alert time, move it to tomorrow if it'll go off at night
var timerTime = toDateTime(timerHours.toString()+"h");
logger.info("timerTime is " + timerTime.toString());
var nightStart = this.ZonedDateTime.now().withHour(22).withMinute(0).withSecond(0);
var nightEnd = this.ZonedDateTime.now().withHour(9).withMinute(0).withSecond(0).plusDays(1);
if(timerTime.isAfter(nightStart) && timerTime.isBefore(nightEnd)) {
timerTime = nightEnd;
}
logger.info("timerTime is now " + timerTime.toString() + " after adjusting for nightime");
logger.info("Motion detected at Dad's, setting reminder to expire at " + timerTime.toString());
var dadTimerExpiredGenerator = function(){
return function() {
if(items["vDad_Motion_Alert"] == ON) {
this.sendInfo("It has been awhile since dad has moved. Last movement detected at " + items["vDad_LR_Motion_LastUpdate"])
}
else {
logger.info("Dad's motion timer went off but alerting is OFF");
}
}
}
timers.check("alertTimer", timerTime, dadTimerExpiredGenerator(), true);
type: script.ScriptAction
timeMgr.js and timeUtils.js you can find at GitHub - rkoshak/openhab-rules-tools: Library functions, classes, and examples to reuse in the development of new Rules. and alerting.js is a personal library where I’ve centralized all my alerting into library functions.
There are some things I can change to further simplify the rule such as using the Timestamp Profile instead of setting the Lastupdate Item from the Rule. I could also use my Time of Day Items instead of hard coding in the times for night time.
Note that I could implement this on my dad’s openHAB instance but it was easier to implement on my local instance. And if the connection is lost to the other openHAB instance I can learn about that more directly than would happen if it were all just implemented on his instance.
Anyway, what I would recommend:
- don’t reinvent the wheel and don’t go cheap; find a professional service for acute emergency notifications like this
- find a button that can be worn; if she were to fall she is unlikely to be able to get to one of the three buttons
- implement some sort of monitoring of the remote openHAB instance so you get an alert when it goes offline; no news is not always good news in this case
- consider other types of sensors too and combine them for a fuller picture
As for the system report, that’s easy enough. Most battery powered devices will report their battery level and there is the systeminfo binding and snmp bindings. But if your openHAB instance can see the remote one, you can just use the Network binding to ping it and discover when it goes offline.