Greg Frank - June 26, 2017
Greg Frank is a VictorOps engineer on the plat-frastructure team. An iOT aficionado, Greg built a smart home system using SmartThings and VictorOps.
Over the years, I’ve had the misfortune of experiencing some small water leaks at my house. These were minor events: a leaky ice maker and a water valve for a sink. But among my friends and relatives, I have seen and assisted with cleanup for more severe water leaks that involved great expense and effort.
My instinct as a developer is to attempt to find patterns of problems and connect them with general, proactive solutions that address the broadest category possible. This thinking process sent me down the path of evaluating smart home solutions and using automation to reduce the problems and stress of owning a home.
Throughout this search for a solution, my instinct toward DIY was tempered by a need to have something useful and reliable without inventing my way into constant troubleshooting and upgrades.
Looking at the various commercial options available, I was cautious of any choice that would limit an ability to integrate with the already existing large selection of sensors and actuators sold for smart homes. Of course, I also wanted the option to build some devices myself. SmartThings won me over with their large and growing selection of integrated devices and especially their (now discontinued) Arduino ThingShield with a zigBee module able to attach to a standard Arduino microcontroller.
Looking beyond the physical devices to the cloud platform, SmartThings also offers an extensively documented API with a web-based IDE for developing both new device handlers and “SmartApps.” I could not find another off-the-shelf solution for smart home hubs catering to my software developer need to tinker with everything.
Over the next year, our home system grew to include water sensors under every reasonable potential leak source, a smoke/CO alarm on each floor, some controlled outlets, a few controlled wall switches, and an automated master water valve for the whole house.
Getting back to the original scenario of water leaks, these components all fit together very nicely. The SmartThings water sensor detects even a tiny amount of water and sends an event to the hub. From there, a SmartApp called “If Flood Turn Valve Off” receives the event and sends a “turn off” command to the main water valve and then sends me a text message. This configuration will help defend against scenarios where the source of the water is from the house plumbing, while still providing useful notification if the leak is originating from outside.
Our house already has the typical collection of required smoke/CO detectors, but there did not seem to be a convenient bridge to send data from that system into a smart home hub. So it seemed helpful to add one more alarm to each level of the home, giving the system some reasonable visibility into the state of the house.
When it comes to home security, there are so many systems and options, it would take a whole series of posts to cover that subject. Here is one specific use case to demonstrate the nuance of how a smart home can provide features above and beyond an ordinary alarm system.
Consider the scenario of driving away from your garage while the door is still on the way down and wondering if it hit some obstacle and proceeded to bounce back up. A tilt sensor on the door is commonly used to detect the up/down/currently moving state of a garage door. Couple that sensor with a SmartApp to detect “door is up,” followed by a bunch of motion ending with “door is up,” and it can send an alert for that specific situation. The added logic filters out alerts for everyday life and focuses alerts on truly noteworthy events.
We try to use the least amount of AC possible and depend on a whole-house fan to cool down the house on summer evenings. Unfortunately, it seems to bring a lot of pollen into the house if it runs past 2:00 am, causing allergies and sneezes for all family members. This started my hunt for a timer that could run something for three hours or turn off at 2:00 am, whichever comes first. Not long into that search, it became obvious that a Z-Wave wall switch coupled with a simple SmartApp would solve the problem quite easily. This gives the best combination of results with simple manual control from an ordinary switch on the wall and automatic shutoff timing from a background application keeping an eye on the switch.
As our smart home system exited the proof-of-concept phase and became a regular, vital tool for home convenience and security, there were some clear limitations of the notification system.
Most smart home products offer a variety of contact methods such as phone calls, SMS, and email. This is very helpful, but just one contact attempt is not enough for truly severe situations.
It was right about this time when I started working for VictorOps, and for the first time in my career, the product I developed at work was something truly useful to me in my own home. The features needed to dial-in a perfect smart home notification solution turned out to be exactly what an incident management system offers.
Much of my professional life has involved receiving automated pages and emails related to the health of software systems under my care. Sadly, I had never experienced the reduction of stress possible when this happens within the context of a feature-rich incident management system. VictorOps truly offers an array of configuration choices and convenience settings to make everyday life so much more tolerable, while still keeping me connected.
The first step is to create a team for the users who will manage the incidents within the house. Here we have the Opsalot family with neighbor and relative:
Next, the single most helpful concept applicable to our smart home is an escalation policy.
Using the original example of a water leak, the ideal response is to make a few attempts to contact a member of the household, and then try reaching a next door neighbor, before calling an out-of-state relative. If you are going to have a system with automatic notifications, it is only fair to share the burden of being the first point of contact with a rotation:
The first step was to write a SmartThings SmartApp to register for device events from a variety of devices (temperature sensors, battery states, water sensors) and forward them as alerts to VictorOps via our REST Integration API.
The unique name of each device within a SmartThings hub is a natural fit for translation into a VictorOps EntityId.
Next, a value from the SmartThings device event had to be translated into Critical/Warning/Recovery states. For something like a battery level, you might use thresholds such as:
<= 10% is Critical
<= 30% is Warning
30% is Recovery
These thresholds can be defined as user-adjustable configuration values in a SmartApp to allow customization via the SmartThings mobile app.
Other devices such as water sensors or smoke alarms have natural distinct states easily translated into alert levels without thresholds. “On fire” or “water detected” are definitely always critical.
Recovery events on a VictorOps timeline are only desired when an EntityId is transitioning away from a Critical or Warning state to a healthy state. So, I used the SmartThings state feature to store the current state of each device and only transmit Recovery events to VictorOps at appropriate times.
Let’s imagine the whole system working together in a realistic situation. We’ve all had a busy morning, and I start a load of laundry on the way out of the house before dropping the kids at school and heading to work. 45 minutes after we leave, the washer begins the spin cycle and the vibrations shake the 15-year-old water hose one last time, causing it to burst and spray a flood all over room. The water sensor on the floor detects water and sends a notification through the SmartThings App, indicating it is wet.
The “if-flood-turn-off-valve” SmartApp receives the water-detection event and sends a “close-valve” command to the LeakSmart valve installed on the main house water line. That action automatically stops the flood, but there is still a large amount of water on the floor. Meanwhile, the VictorOps SmartApp Integration has also received the water notification and forwarded it as a critical alert.
The critical alert is routed to the family team within the family VictorOps organization and generates an incident.
**Step One **Step One of the escalation policy is to send a push notification to me. Unfortunately, I’m in a long meeting with no technology and so I don’t receive the alert.
**Step Two **After a couple of minutes, the water on the laundry room floor starts to drip down to the basement and spills into a ceiling light which shorts out and begins to send sparks. Meanwhile, five minutes after the first notification, the VictorOps escalation policy advances to Step Two (fortunately!) and alerts another family member.
That person is also unavailable to respond. At this point, the electrical short has a real risk of starting a fire.
**Step Three **After two more minutes without an acknowledgement, Step Three of the VictorOps escalation policy kicks in, with the action of making a phone call to our next door neighbor. Fortunately, the neighbors are home, head over to see smoke, and call the fire department.
Without annoying the whole family to the point where they leave me forever, just how far can we go down this path?
Do we need to connect the “late homework assignment” email from my kids’ school district to VictorOps, triggering an incident with its own escalation path?
Late homework policy
1) Page the child in question.
2) After a day, shut off the power and network to the Xbox.
3) After two days, notify a parent to intervene (interrupting our otherwise blissful life of leisure).
Switching to sanitation engineering, does the kitchen garbage can need a laser and optical sensor to detect when it is full, and assign an alert (to anyone but a parent) to take out the garbage?
Regardless of how far and silly this smart home concept goes, it’s clear that there are some good, practical, and fun applications for this technology.