Therefore, I would at least need to start a process
that would understand my intent to leave
How did you solve the "intent" issue? It looks like your solution simply detects when your phone stops responding to pings, and then unlocks the doors when it resumes.
This doesn't seem like it would distinguish between "going for a run", "going on a car trip", "turning the phone off for 10 minutes and then back on again, but never leaving the house," etc.
I suppose one (fun, overkill, probably) solution would be if the phone's sensors could be queried. Once the phone "returns", your home network could query the phone and ask it if you've been exercising or not, based on your heartrate/motion since the phone was last seen by the network.
> I wrapped everything up in a small Flask app to serve a simple HTML form on a Raspberry Pi. Clicking Submit launches the start_process function as a background process:
Clicking submit is establishing intent. Once intent is established, then it uses the timeout to detect when they've gone, and, later, their return.
Would be cool to train an ML model to pick up the running shoes and orientation and put a camera by the garage. Spoofing concerns/false positives aside, maybe putting a tracking device in/on the shoe and listening for both those devices might be a better solution?
This is awesome! I love reading about projects like this. Always gets me thinking about how I can do little things like this for my life workflows.
> installing MyQ W-Fi connected garage doors
Haha you were already light-years ahead of me before you even started. I typically slide my key into a little pocket and pray it doesn't fall out. I think using events from your router is a great idea. I have recently been playing around with events you can send from routers and it has really opened up my mind to whole new avenues of creativity.
If anyone has FortiNet FortiGate routers, they have something called "automation stitches"[0] which are a way to action on nearly any event, and they can be created in the routers config file. They can even run scripts and chain together. When the criteria is met they can send to a Slack channel, email, Lambda Function, or any webhook URL. Pretty fun to play with.
Home Assistant has home zones. You can trigger events based on being home, away, or the trigger between both states.
My current favorite automation is to turn off my lights when I go to sleep by plugging my phone in to charge. The basic logic is:
* IF it's 1AM
OR
I transition from Away to Home
OR
My mobile starts charging
CONDITIONAL
My location is AWAY
OR
the time is between 21:00 and 03:00
THEN
Turn my office, kitchen and bedroom lights off *
It's a bit complex to get your head around, but the basic idea is, my lights turn off at 1 AM, or I leave the house, or my phone starts charging after 9 PM. This allows me to go to bed early (I'm a night owl) by just charging my phone. It wont trigger in the day based on the conditional.
I like this approach. This kind of house-wide reaction to putting my phone on a wireless charger would make me more trusting of the damn things. I only used one briefly, twice in a month where my phone didn't charge, then died, and having no alarm to wake me in the morning all because my phone wasn't perfectly positioned on the pad soured me on the idea.
Automating such a narrow edge-case seems totally pointless. A much more likely scenario is that your battery dies while you're out, in which case you're still screwed.
A better tried-and-tested real world solution that covers all scenarios is a simple key safe.
I suggest this tiny thing named "key" is an appropriate solution. Hard to break through dropping, no battery, the home doesn't need electricity and so on.
While I understand the tinkering here for fun, the author did ignored the actual problem of the drained battery completely?
I shared this elsewhere but I could have expressed the initial problem a little clearer, which actually was "enter my home without unlocking my phone which causes my phone to die in the cold."
Unlocking the screen caused the battery to drop immediately - it still had network connectivity prior to that.
I think the initial problem was clearly-enough stated, and the GP's point is valid - why bother accounting for the case where your phone is so close to dying that you can't unlock the screen, when just a bit less battery life would mean that your phone dies regardless (and you're stuck outside anyways)?
The battery level isn't actually close to dying, in my case it just rapidly depletes from up to 40% when it's very cold. But that 40% remains intact seemingly with the screen off. Could be my phone also, but it has happened often enough that I wanted to solve it and thought this was an interesting approach.
For me, this was just a matter of convenience and not optimizing for most resilient or reliable solution. I do have backup plans for home entry.
Batteries are generally less able to source current when very cold. At low temperatures, the battery was sufficient to power your phone in a low-draw state (minimal network activity, no screen, low power CPU state), but the voltage dropped when current draw increased.
I experienced this. I ran to work at -10F. When I arrived, I took out my phone to take a photo of my ice beard and although it almost immediately died.
It is more common than you think. Turing on the screen in cold weather is usually the thing to make the phone shut off. The solution still saves you the trouble of having to take off your gloves to access your phone.
I setup something similar years ago for my garage. Instead of looking for my phone though, I wanted a way to open the garage quickly without using the keypad. My kids were small and my hands were normally full. However, I did have an RFID ID card from $work in my back pocket. So, I placed an RFID reader at butt height. If it detected my ID (or my wife's, or keyfobs, etc...) it would trigger a relay to simulate pushing the button inside my garage to open the door. It was all controlled by an Arduino.
That was quite possibly one of the most satisfying projects I've done.
I've now since moved and don't have an attached garage anymore, so this is now sitting in a box in my basement. :(
Some people just really enjoy solving problems in a convoluted way for the learning experience. I don't have that kind of drive personally--I feel like I learn enough programming during work hours.
I just did this with great fun. Was suspicious that my house CO2 was getting too high in my bedroom at night -- one Raspberry Pi connected CO2 sensor streaming metrics over WireGuard to a cloud server running Prometheus, Grafana, and sending alerts with Alertmanager and Pushover I now have a very reliable system to tell me to open a window.
Next thing will be auto-provisioning the Pi so I can just flash my image to the SD card and plug it in.
The SD card contains everything for the RPi, right? I set up a home media server for my parents with RaspBMC and an IR receiver about five years ago. They live in a poor power region so the SD cards can go wrong easily on power failure. I just `dd`'d a bunch of identical SD cards and left it to them to swap.
Ideally, keeping the SD cards read-only would have been better but I was visiting only a few days and I needed to support subtitle download so I settled for this.
Outside of work, the only project ideas I have are weird convoluted ones just like this, where I spend 40 hours getting a proof of concept working, then never touch it again.
This is fixing that one precise incident he had, nothing else. He said that he came back from the run, turned on screen and the phone shutdown. With this solution the phone would open doors automatically. Cool project but it solves such narrow issue. It's like centering text in editor by adding spaces.
I think that although his approach works, the smarter thing would be to fix a hi-definition camera pointing at his driveway entrance, and use OpenCV/ML/AI[1] to detect that it's him approaching the house and automatically open the garage door.
For bonus points he could then rig up a speaker to sing 'welcome home' as well...
For even more bonus points, anyone coming up the driveway that isn't him could be greeted by Barking-Dogs.mp3
---
[1] Or whatever that magic thing is that NCIS use every week.
OP, FWIW I think there's a trigger available in iOS Shortcuts that kicks off if you join a particular network. You could probably use that trigger + a web request and achieve your 'event driven' desire just FYI :)
Love this writeup, though I have to admit I'm slightly disappointed. From the headline I had expected to read how the author rigged his home security system to keep the doors locked. And to only unlock after his phone/fitbit logs him as completing his distance goal for the day.
My solution was just stopping my keys from jingling and poking me while running, I put my keys in a rigid key holder/organizer thing like a Swiss knife for keys
We had our ancient garage door opener replaced last year and I opted to add the outdoor keypad thing. It turns out those just sync to the opener and run off a battery, you can just go buy one and screw it to your house. No wires, no fancy opener required. Best of all I can go for a walk with no key or phone.
This is a fun project, nice job putting it together! I tried to do a similar thing with an app and my home made security system, but I didn't refine it enough to be reliable.
But I don't think it solves the problem that prompted it :P if your phone dies on your run, it won't connect to your network and the Flask app won't capture the packets needed. Still, making this hands off is a great step from needing to open an app.
My feelings about these kinds of projects are a bit mixed. I certainly understand why, writing code that controls something in the real world is so much fun. However I actively avoid any kind of smart device in my home, beyond my vacuum cleaner. Having a computer control lighting, heating or access to my home is out of the question, I simply don't want to deal with it. I trust keys, switches and knobs.
Less dumb solution: Getting a key custody safe [1] and mounting it to the exterior of your house so you can lock up the key while you're out running. Ideally it would be mounted somewhere discreet (perhaps inside a fake utility enclosure, which would also help protect it from the weather) but in plain view of the street so if someone does attempt to break in they're forced to draw attention to themselves.
You also have to be careful to get one that suits your threat model, a key custody safe designed to be installed in a semi-secure part of a building may not be resistant enough when mounted on the exterior with street access - many are only designed to resist covert tampering and are not that strong against a determined attacker with an angle grinder or similar overt attack.
Smart home stuff can't overcome the fundamental issue of complexity creep and the brittleness and unreliability inherent to it.
I've had a network connected soundbar bring down my home internet. My lights were set to re-enter the state they were in when they were last on, no way to turn those on without factory resetting them all and pairing all my devices again. My smart assistants were on a hair trigger, if anything tripped their wake word they would start a cacophony of complaints about not being able to connect to wifi and demands to be reset.
I'll give my smarthome crap one thing though, it's genuinely educational,
You might deprive yourself from an interesting experience i had:
My IoT light switches made the mental model of 'lightswitch on the door' to 'lightswitch were i need it'.
It also allows you to actually have a light atmosphere which enhances how you use light. This is a stark contrast to a friend of mine who sits in a very bright and uncomfortable room.
Using Alexa or Google for lights, timer and reminder also gave me insight on how much different/more natural a voice interface is and were we might be with this technology in a few years.
That would certainly be a plus. I have at least one missing lightswitch in my kitchen, and adding it would be rather complicated. Still it seems like overkill to invest in IoT to solve the issue of my lightswitch being 1,5m from where I'd want it to be.
The whole "light atmosphere" is something I already have, I just have to go around and turn on the lamps manually. As for the Alexa, Google Assistent or even Siri integration... I trust none of the company behind those technologies enough that I'd allow them to have a microphone in my home, constantly listening. It is beyond creepy.
I'm a software engineer. Who else to play around with those type of things than us?
I 'setup' my lights and don't go around to switch them on. I just stop doing that. With hue i have always a specific scene active. For watching projector, eating, learning etc. I constantly play around with the lights. Its actually quite fun.
And yes of course i would love to have a local ML chip and some open language model. But i'm also running around with my smartphone. Friends work at mobile provider, they know were you are. The android os is 'trustworthy' but i still have a microphone in it and having it around me all day.
Knowing that those activation words can't just be deactivated, makes it, in my opinion, similiar if not more secure than my smartphone. So that wasn't a big deal for me either.
Regarding the lighting, you're definitely missing out on a lot of comfort by not using something like Hue or zigbee2mqtt. You could add a second layer of lighting which runs in parallel, like with floor lamps. Once it's set up you can completely forget about it and have movement sensors and dimmer switches make them useful to you.
Knowing I had left for a run was key to knowing when I had returned from a run, rather than a trip in the car for example.
Maybe I'm having a brain fart, but I don't see how his solution has accomplished this.
Frankly it'd be way easier for the phone to use its GPS and accelerometer to decide he's on a run and just open the door when it reconnects to the wifi.
I don't see the run specific part either. It seems to work whether he went for a run or drive to the store. But using a device on the WiFi to sniff that the phone has reconnected and therefor the garage should open was better than putting the logic on the phone. For one thing, it makes it so he can trivially add/remove devices with this functionality.
Frankly, if he wanted to do something with GPS on his phone, timing anything to the reconnection of WiFi is just worse than sending a signal to a public facing web server when he crosses a geofence.
I wonder if this will continue to work, as some phones (I believe all iPhones by default now, for instance) cycle MAC addresses.
Very cool (not cold) solution! I would like to set up a similar system, which should be possible - I've recently bought a hubitat hub (highly recommended at $100) which uses groovy for scripting, and uses an installed app on my phone with geofencing to detect presence.
I'm a runner who has also gotten locked out, and my solution was to install a keypad deadbolt on my front door ($100 at Home Depot). Never had a problem since.
This, got one for $45, no wifi, no Bluetooth, no firmware updates, no app, just regular batteries with a keypad and was able to rekey with my existing key. Amazon basics has one for $50.
The Schlage one I bought took about 3 or 4 years before keys started showing signs of wear. We rotate the code every ~3 years now to wear out the other keys and now they are all pretty much equally worn 7 years later.
My current (Yale) keypad is too new to judge, but the digits seem to be printed underneath the plastic rather than on top of it. Should make it difficult to detect any wear.
I like this idea in principle and think it could be turned into a great alternative to a hide-a-key, or used to let a pet in though a small door. A typical garage door spring is rated to last 10k cycles, make of that what you will.
Highly entertaining. I totally understand the problem of the phone shutting down in extreme temperatures. I have to say I'm pretty impressed that you're running in those temps, though.
Also thanks for pymyq. Neat home automation library.
This is very clever and useful. I wonder if this could be done with a GPS watch rather than the phone. AFAIK, GPS watches typically send out Bluetooth signals but probably don't connect to Wi-Fi.
I tried to use Ping in home assistant for basic "is home" presence detection. It wasn't very reliable since the phones' wi-fi connections would drop in prolonged sleep states.
For extra fun, you could set up some speakers and have them start playing some appropriate piece of music as you approach. Some sort of triumphal march, perhaps?
I'm really disappointed by all the comments here. OP showed a clever way he gets his garage door to open when he gets home from a run. It's an interesting look into home automation from scratch and exactly the kind of content I come to HN for.
This isn't posted in NY Times. He's not advocating everyone should go out and do this because of how much better it's made his life. He's not even claiming that it's necessarily better than putting a keypad on his garage. He just hacked together something cool and we should applaud people trying these kinds of things.
Sadly this is the modus operandi for most HN comments these days; it's easier to nitpick details about something fun/interesting that a person did than it is to actually _do_ something fun/interesting & have the guts to (gasp!) post about it online for all to see.
You also might want to just give it a little time. When I viewed this post 3 hours after you, the four following comments began, "Super cool project...", "First: cool project...", "I setup something similar...", "This is awesome...". I assume your comment probably helped, but that also over time regular comment moderation did its part.
As for the original article, I'm a runner so it was of interest. My living situation is nothing like OPs tho, so probably not for me.
Second: I'm probably missing something, but:
How did you solve the "intent" issue? It looks like your solution simply detects when your phone stops responding to pings, and then unlocks the doors when it resumes.This doesn't seem like it would distinguish between "going for a run", "going on a car trip", "turning the phone off for 10 minutes and then back on again, but never leaving the house," etc.
I suppose one (fun, overkill, probably) solution would be if the phone's sensors could be queried. Once the phone "returns", your home network could query the phone and ask it if you've been exercising or not, based on your heartrate/motion since the phone was last seen by the network.