iPhone

Voice Controlled Garage Door

As seen previously (more), I’ve got our garage door hooked up to the internet. Now that we’ve both got Siri though, it seemed like I ought to be able to ask her to open the thing. Apple doesn’t yet provide any kind of API into or out of Siri, but you can get her to send texts.

Which brings us to Twilio, a fantastically easy to use SMS and voice menu API. It’s about as simple as I can imagine it being to set up a number on Twilio that, when texted, forwards the text along to a web URL of your choosing. So all I needed to write was a tiny web app to bridge SMS messages from Twilio to Indigo‘s web interface.

Since I’ve been working on Buzz, a tiny little web framework written in Lua, I decided to use that for my bridge.

So given all the various pieces were already in place, this is all the new code I had to write for this entire project. As a bonus, I can turn the lamp behind me in my office on and off too (mostly because it was a lot more comfortable sitting at my desk writing this than sitting on the garage floor!)

With this app running and Twilio set up to send texts to it, I made a contact on my phone named “House” with my new Twilio number, and can now tell Siri “Text house open the garage”, and the door will open. Technically it will open or close, it’s just a toggle, but you can see how to modify this code to do more stuff, or be smarter about it, pretty easily. Until Apple opens up the Siri API, this is a pretty good poor man’s substitute.

require('buzz')
local ffi=require('ffi')
ffi.cdef [[
	int	system(const char *command);
]]
 
function homecontrol(request)
  _,_,body=request.uri:find('[?&]Body=([a-zA-Z+]*)')
 
  request.headers['Content-Type'] = 'text/xml'
  body = body:lower()
 
  if body:find('lamp') then
	ffi.C.system('curl -X PUT -d toggle=1 http://sideshowbob.local:8176/devices/OfficeLamp')
	response='Turned the office lamp on or off'
  elseif body:find('garage') then
	ffi.C.system('curl -X PUT -d outputBinaryStates="1,0,0,0,0,0,0,0" http://sideshowbob.local:8176/devices/GarageDoor')
	response='Activated the garage door'
  end
 
  buzz.response(request, 
				'<?xml version="1.0" encoding="UTF-8"?>\n'..
				  '<Response><Sms>'..response..'</Sms></Response>\n')
end
 
buzz.get('^/homecontrol/\?.*$', homecontrol)
buzz.run(8080)

Some issues with the above code:

  • There’s no security at all, other than the phone number being a secret. Anyone could open the garage if they knew the right number to send a text to, or the right URL to send a Twilio-like request to. There are several really simple things that could be done to greatly increase security, if one were worried about it.
  • It should really be set up as a PUT or POST request, as something is OBVIOUSLY changing state as a result of the request! But Buzz only does GET requests right now. Luckily Twilio can deal with that.
  • It requires luajit, rather than working with plain old lua, since I’m using ffi to make a system() call to curl. There are better ways to do that, but ffi makes things like that really easy for experienced C programmers. Buzz itself requires luajit for the socket layer anyway, though I don’t think it will forever.

Tags: , , , , , , ,

Sunday, November 6th, 2011 Uncategorized No Comments

Thanks, Steve


Steve Jobs’ passing has caused me to reflect on just how much of my life is directly or indirectly influenced by his work. Although the first computer we had in the house growing up was an Imsai 8080 (you may not recognize the name, but you’ve seen one in War Games with Matthew Broderick), the first computer that was “mine” was an Apple ][. My dad bought a used one for me for Christmas when I was 11 or 12, meaning it was already a couple of years old. But at the the time, a computer could be two years old and still be state of the art. That computer stayed on my desk through high school, and it’s still in a box in my mom’s garage. I got online, on BBSes, for the first time on that computer, using a modem and an I/O card that I think cost my dad about $20, and which were so generic we had to write our own “drivers” (I’m not sure that’s what we called drivers back then, but that’s what they were) to get them to work at all.

At the time, Wozniak was more of an idol to me than Jobs, being the geeky hacker who made it all possible. I didn’t have anything against Jobs of course, but to a kid like me, the Woz was the awesome one. As an adult, I see how important Jobs really was in actually getting that computer onto my desk. I have no doubt that Woz would have made the same computer with or without jobs, and then sold a few dozen as kits to people around Silicon Valley.

I jumped ship to Amiga when that came out. I never had an early Mac. But when I got to college, there was a room full of NeXT computers, so once again I was using Jobs’ creations. Although we had Sun workstations too, the NeXTs were my favorite. I even used them remotely for homework when dialing in by modem from home during the hours the lab was closed (and occasionally when it was open, probably annoying whoever was sitting at the console, most likely wondering why things were so slow that day!), because no one said I couldn’t, and I got a whole machine to myself that way rather than sharing time on the Sun server we were “supposed” to use.

Out of college, my first professional game industry job involved writing the network layer for Close Combat, which ran on both Macs and PCs. That was the first time I really used a Mac, and I actually hated it, but that had a lot to do with how non-standard the network stack on pre-OS X Macs was, since that’s what I was mainly dealing with. Also, the machine I had was a prototype on “loan” from Apple, which I believe my boss eventually told Apple they lost because they didn’t want to spend money on a new one. It had a flaky video connector I had to prop up with a book, and I seem to remember I had the case off of it due to heat problems too. But I never held that against Apple, just my boss, it was not a production machine after all.

My next experience with Apple was inheriting the iBook my dad bought not long before he died. It was his first Apple product since he’d bought me that Apple ][, and I think his favorite computer he’d had in a long time. That was right after OS X had come out, and like me, he’d spent a lot of years on Unix systems. Although I didn’t use that computer as “intended” very much, I did use it as a little low power mail server for a few years, and the few times I did use it like a Mac made me realize Apple was definitely on to something. It was just a little underpowered for actually running OS X. But it was only a few more years before I had a PowerBook of my own. Plus an iPod a couple of years after those came out. I’ve had at least one Apple product in daily use ever since. Right now, there are four within arm’s reach (MacBook, iPhone, iPad, AppleTV remote!). There is almost never a moment I’m without my iPhone. Even if I was using Android phones, I’d still have a lot to thank Steve for.

So although there are significant gaps in there, I think it’s safe to say that I’ve used Jobs’ various products daily for the majority of time I’ve been using computers, and I’ve spent a lot of time on computers. There are other tech industry figures I might admire more than Jobs, but none that have had anywhere near the impact on my life that he did, nor will there ever be anyone else who can match his influence.

Here’s to the crazy ones.

Tags: , ,

Sunday, October 9th, 2011 Uncategorized 1 Comment

Is there an app for that?

I want an app that whenever I get an incoming call that’s not on my contact list, looks up the number on 800notes.com, and displays the number of posts related to that number, or any other relevant data it can scrape quickly, in time for me to see it before it goes to voice mail.  Better yet, if there are more than X posts (say 100 to start with), it would just block the call for me.

This would require a jailbroken phone, since Apple and AT&T don’t like apps messing with phone calls, but I’d jailbreak mine this instant if there was an app like that.

Tags:

Tuesday, August 24th, 2010 Uncategorized No Comments

Movie encoder “daemon”

I sometimes have incoming high-def video in formats that are not directly compatible with AppleTV.  I had been using iFlicks and an El Gato Turbo.264 HD encoder (a USB dongle with H.264 hardware innit), but lately that started producing bad output – I think the hardware was going bad as even the official software had the same results.  It was great while it lasted, it allowed the poor overworked Mac Mini that was doing the encoding to do 720p transcodes faster than real-time.  I should note that iFlicks’ author has actually recommended not using the El Gato thing, he mentions audio sync problems, but I never saw that, just frequent badly encoded video after mine started to go bad.

I’ve now switched back to software encoding using Handbrake.  To that end, I wrote a tiny little daemon that watches for files in one directory, encodes them, then moves them to the folder that iFlicks is watching and trashes the original.  iFlicks will then add meta-data (it searches thetvdb.com based on the file name), and finally send the file off to iTunes (which will then sync it to AppleTV.  WHEW that’s a lot of steps, you see why I need to write myself things to help?)

iFlicks can do software encoding itself, but it just uses Quicktime, which is a whole hell of a lot slower than Handbrake. Handbrake still doesn’t do 720p at real-time on a Mac Mini, but it’s only about half real-time, as opposed to Quicktime, which was taking 4-8 hours to encode an hour of video.

The script also gives me Growl notifications, and I have the Prowl app on my phone, so I get push notifications when encodings start and finish too.

Code after the jump.
› Continue reading

Tags: , , , , ,

Sunday, February 28th, 2010 Uncategorized No Comments

Too bad

That there aren’t more pretty things to look at in BC.

And the best for last.

Tags: , , , ,

Sunday, November 30th, 2008 Uncategorized No Comments

Binary Star

I didn’t check my itinerary very carefully, and thus was unaware that travelling to Tucson would place me in a distant solar system featuring a binary star. Live and learn.

Tags: , , ,

Wednesday, November 19th, 2008 Uncategorized No Comments

Worse things to wake up to

Tags: , ,

Wednesday, November 19th, 2008 Uncategorized No Comments

The Pumpkin King, Bitches

The red haired speck on the left.

photo.jpg

Tags: ,

Saturday, October 18th, 2008 Uncategorized No Comments

Why so serious?

photo.jpg

Tags:

Saturday, August 9th, 2008 Uncategorized 1 Comment

Morning People

I have never thought of myself as a morning person. But lately, compared to Lnor and Egg, I am Betty Fracking Crocker.
Next on rumsey.org: Artichoke pancakes the whole family will love!

Tags: ,

Wednesday, August 6th, 2008 Uncategorized No Comments