brad's life - Android Garage Door Opener, part 2 [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Android Garage Door Opener, part 2 [Oct. 26th, 2008|12:06 pm]
Previous Entry Share Next Entry
[Tags|, , , ]

This is a follow-up to my previous post to say:

SO. FUCKING. AWESOME.

I got it all working. I now have an Android Activity (GarageDoorActivity) which interacts with an Android Service I wrote (InRangeService), letting me start and stop the service's wifi scanning task. The service gets the system WifiManager, holds a WifiLock to keep the radio active, and then does a Wifi scan every couple seconds, looking for my house.

When my house is in range, it does the magic HTTP request to my garage door opener's webserver (HMAC-signed timestamped URL, for non-replayability/forgeability if sniffed) and my garage door opens. Complete with a bunch of fun Toast notifications (like Growl) and Android Notifications (both persistent ongoing notifications for background scanning, and one-time notifications for things like the garage door actually opening).

I just threw on some shoes and hopped on my motorcycle to do a test lap around the neighborhood. When I got to the corner, I pulled up the activity and press "Start" (aka "Going home now"). A lady on the corner saw me playing with my phone on my motorcycle and said, "The reception's not so good up here." I thanked her, not wanting to explain what I was actually doing.

I then finished the lap around the block and the garage door started opening a few houses away. By the time I pulled up, I could already back the bike into the garage. HELL YES.

Update 2008-11-16: The source code is now available.
LinkReply

Comments:
From: evan
2008-10-26 07:23 pm (UTC)

ours isn't nearly as fancy

(Link)

Yesterday when I walked home there was some kids sitting on my stoop. I stopped in front of them and fumbled with my bag to pull out my phone and they gave me a quizzical look. Then I hit the button to open my front door and they gave me an even more quizzical look as the door buzzer buzzed.
[User Picture]From: mart
2008-10-26 08:03 pm (UTC)

Re: ours isn't nearly as fancy

(Link)

I got a look much like that when I was staying at Brad's. I left the house in the morning through the garage and crossed over to the other side of the street where reception is better for some reason, then looked back at the house and fumbled with my phone a bit to close the door. A guy who was waiting by a car on the sidewalk looked like he was about to ask about it but then he got into his car and drove away.

The weird thing is that it seems that phone-controlled doors aren't that unusual. The apartment block I'm in right now has a phone-accessible door control that I can in theory call and press 9 to open the door, though they use caller-id as the access control and I've not told them my number so I've not tried it out. I think the intended way to use it is for the door to call you and you to let other people in, but according to the instructions it works both ways.

[User Picture]From: ciphergoth
2008-10-26 07:46 pm (UTC)

(Link)

Does stopping the bike, getting your phone out, finding the activity, pressing the button, putting your phone away, starting up the bike again and putting it in the garage actually save you any time over driving to your home, dismounting in front of the door, opening the garage door and wheeling your bike in?

Of course, that's not entirely the point, but still...
[User Picture]From: mart
2008-10-26 07:56 pm (UTC)

(Link)

Presumably in practice this would be activated before Brad heads home from somewhere else, so the extra stop wouldn't be necessary. I assume he did it this way for the test just because home was both the source and the destination.

Re: Purpose - (Anonymous) Expand
[User Picture]From: brad
2008-10-26 08:22 pm (UTC)

(Link)

No, like Mart said below, starting the service just means starting the search for my house, not opening the garage door immediately.

And now the next step (briefly alluded to in the previous LJ post) is to automatically start the background service based on conditions, such as my common case:

-- I come home sitting on the Google shuttle for 30-60 minutes, with the Google shuttle's Wi-Fi in range. this is between, say, 4pm and 8pm.
-- Suddenly the Google shuttle wifi disappears, so I must be off the shuttle now and walking a half block to where I park my motorcycle.
-- The service turns on now, at least for 10 minutes (it takes about 5 minutes to motorcycle home), assuming I'm heading home

So in that common case, I do nothing: my phone notices my common case (going home) and opens it when I approach.

In the lesser common case, like I just did now: I met a friend for brunch. When I was putting on my helmet, I pushed the "Start" button on my phone before I put on my gloves. When I got home in 10 minutes, the garage opened.

(no subject) - (Anonymous) Expand
What about more? - (Anonymous) Expand
From: (Anonymous)
2008-10-26 08:24 pm (UTC)

Posting source online?

(Link)

Brad,

Will you be posting the source online?
[User Picture]From: brad
2008-10-26 08:30 pm (UTC)

Re: Posting source online?

(Link)

If I do, it won't include the secret key for my garage door server. :)
[User Picture]From: muerte
2008-10-26 08:32 pm (UTC)

(Link)

$geek_points += 100;
From: mikalstill.blogspot.com
2008-10-26 08:49 pm (UTC)

Battery life?

(Link)

What does keeping the wifi manager open do to your overall battery life?
[User Picture]From: brad
2008-10-26 08:52 pm (UTC)

Re: Battery life?

(Link)

Don't know or really care: it's only for a few minutes, and once I'm home I'll just be charging it anyway. And since I only activate the scan once I'm heading home.... well, it all works out.

[User Picture]From: dan_lane
2008-10-26 09:12 pm (UTC)

(Link)

Gah, every time you post about developing for Android I want one even more. Love the idea of Growl-like notifications!

T-Mobile UK are taking their sweet time getting me a G1 review unit :(
[User Picture]From: jtrevino
2008-10-26 09:34 pm (UTC)

saaaweet!

(Link)

That's freak'n sweet, dude!
[User Picture]From: aca
2008-10-26 09:55 pm (UTC)

(Link)

Dude, you are such an epic geek. I fucking love this. :)
[User Picture]From: matthew
2008-10-26 10:17 pm (UTC)

(Link)

Personally I just put a garage door opener in the sleeve pocket of my riding suit. Of course, that won't stop me from using your system :D

So most importantly, how is your garage door opener wired into a web server?

Edited at 2008-10-26 10:18 pm (UTC)
[User Picture]From: brad
2008-10-26 10:37 pm (UTC)

(Link)

Custom webserver (little Perl script hanging off xinetd), heyu, and an X10 relay.
[User Picture]From: brad
2008-10-26 10:38 pm (UTC)

(Link)

And yes, arguably the x10 is the weakest link here. But I might argue a rock through a window is weaker.

I was considering putting two x10 modules in series to greatly expand the search space.
[User Picture]From: jojobear99
2008-10-27 05:19 am (UTC)

(Link)

sounds pretty cool :)
From: bennry73
2008-10-31 05:50 pm (UTC)

WifiManager

(Link)

(new here) I like this application a lot! I've been working on an Android app and some of my questions and concerns have clearly been overcome by your project. I was wondering if you could shed some light on some issues I'm having with development.
[User Picture]From: brad
2008-10-31 10:05 pm (UTC)

Re: WifiManager

(Link)

I don't know. Maybe. Depends what your issues are.
Re: WifiManager - (Anonymous) Expand
From: michaelchelen.net
2008-11-01 10:18 pm (UTC)

garage door opener's what??

(Link)

"my garage door opener's webserver"
ok that part made me laugh!
From: (Anonymous)
2008-11-17 04:59 pm (UTC)

As a fellow motorbiker I exalt thee

(Link)

When sun came up with the sunspot, i immediately thought "garage door opener"! haha love what you have done with the dream phone seriously, its a pretty damn awesome implementation of the radio wifi. Question is, "what kinda garage door opener had a webserver"?

./Brennon
b.1.alpha@gmail.com
[User Picture]From: brad
2008-11-17 06:55 pm (UTC)

Re: As a fellow motorbiker I exalt thee

(Link)

X10 Universal Module + custom webserver I also wrote.
From: (Anonymous)
2008-11-19 03:21 am (UTC)

(Link)

id be interested in the source to that garage door opener as well
From: simplyg1
2008-11-20 03:33 pm (UTC)

garage activity

(Link)

Oh man this is sweet! Brad: You think you may sell this applictaion? If you do let me know. Our site is about to have a store on it and any apps you have you wanna sell, let me know. i will make sure you are taking care of.
Devin.
From: (Anonymous)
2009-09-07 07:54 pm (UTC)

So damned awesome!

(Link)

I'm a geek and car buff and this really caught my eye. Too bad I ain't a programmer so won't be able to make any real use of it but hopefully you'll be able to market a nice little packaged product that all I have to do is plug into my garage and setup my Dream settings....