A Dashboard for My Apartment
Shawn M Moore (@sartak)
march 6th, 2015
I originally bought my iPad back when tablets were becoming a fad. I had expected to use it for everything from reading ebooks to playing elaborate new games. But no, it has been sitting idle, collecting dust, for years. Even the promise of a shared, coffee-table web browser has fallen flat. Whenever there’s a task to be done, I instead reach for my laptop or my phone. After all, as phones get larger and more capable, and laptops get lighter and extend their battery life, the sweet spot that tablets offer gets squeezed out from both above and below. So for the past year or so, my usage has been limited to ordering food online with friends, passing the iPad down the couch. But now I’ve finally figured out the perfect job for it. I’ve mounted it right next to my front door. My previously-unused iPad now serves as a dashboard and control panel for my apartment.
Hardware
The hardware for this project was surprisingly the easiest part. Really all I had to do was buy a mount that fit my old iPad 2. The only other requirement was ease of unmounting and remounting for those rare occasions of temporarily putting it to some other use. There are so many mounts on Amazon. Apparently a lot of people set one up in the kitchen as a fancy recipe book, or in the bathroom as a replacement for the ubiquitous back-of-the-toilet paper book.
My one remaining issue was power: should I leave it plugged in all the time with an unsightly power cable to the nearest outlet? No way. Or do I leave it unplugged and hope the battery lasts? Or, well, I could open up the wall and run power right to the tablet, maybe even embed the whole thing directly into the wall. But since I rent, it’s not worth those headaches. My landlord is amazing but I wouldn’t want to test her sympathy for my techy project. With my infrequent usage, the battery discharges only about 1% a day, so plugging it in overnight only once every few months is the ideal solution for me.
Software
It’s not enough to merely attach an iPad to a wall. More than be, it has to do. I want there to be as little friction as possible for controlling my apartment and for viewing important information. I don’t even want to bother with switching between apps. Each and every step between me and my goal is another place to get distracted, or another little annoyance to make me not want to bother with this stupid thing.
So I’ve been working on an app to meet my specific needs. The goal is turn on the iPad and have all the heterogeneous information I want on one screen, alongside single-tap buttons to control the growing internet of things that lives in my house.
Setup
Battery life is suddenly a large concern for this tablet, which is a new constraint from how I previously used it. So I wiped it clean and started fresh, installing no apps. I also turned off features I won’t need, like Bluetooth and Background App Refresh. Auto-lock now kicks in after two minutes. I configured as many of those sorts of things as I could find in order to maintain battery life as much as possible.
The slide to unlock gesture is great for phones. You never want to accidentally unlock your phone while it’s still in your pocket, because that’s how butt dialing happens. But that feature makes little sense for a tablet mounted to a wall. I wish I could disable it completely. If I left the Smart Cover on, then opening that unlocks the iPad as a handy side effect, which could be made to work but is still less than ideal. I don’t want that flapping around.
There’s another way though. iOS has a feature called Guided Access. It’s designed to keep the user locked within a specific application. The primary use case is letting retail store customers use iPads without being able to leave the store’s app. Apple decided that for that scenario there’s no reason to bother users with slide to unlock. So it’s perfect for my needs! Not only does it disable slide to unlock, but it also keeps me stuck in my own dashboard app. Push the power or home button and immediately my app is always right there. Perfect! (In case you’re wondering how you could ever escape Guided Access, you triple-tap the Home button and type in a passcode)
Well, almost perfect. Every single time I turn on the iPad during Guided Access, there’s a little notification that warns “Guided Access is enabled.” It looks like there’s no way to disable that yet. (Why??) In the meantime, I’ve worked around this annoyance by not putting any controls in the top 44 pixels where that notification appears. Getting rid of slide to unlock is worth this minor annoyance.
Lights
One of my favorite holy-shit-it’s-really-the-future gadgets is WiFi lightbulbs. They’re still more expensive than it feels like they really should be, but I gladly pay the early adopter tax for the coolness.
When I leave my apartment I turn off all the lights. Previously, that involved pulling out my phone, hitting the home button, finding the lightbulb app, getting distracted (oh has it already been thirty seconds since I last checked Twitter?), regaining focus, opening the lightbulb app, turning off each light one by one. As you can imagine I got fed up with this process every time.
And so the first component of the app I built was for controlling lights. There are four buttons across the top of the display: off, half, full, color. “Half” and “full” refer to white light at various dimness levels. “Color” sets the lights to be a particular set of colors I’ve chosen. I love the way the lights’ colors mix on my wall.
This is already a huge win over using my phone. For one, it’s down to only two taps: home button, then “off”. It’s also done using a dedicated device that has no distractions for me to explore. There are too many temptations on my phone. It now takes me much less time to physically exit my apartment!
It was very easy to implement this feature thanks to the Philips Hue API. When I tap a button, the app just sends an HTTP POST request with the light values I want to the gateway. Done!
Weather
The next component was weather. As with wifi lights, there’s a huge holy-shit-it’s-really-the-future app in Dark Sky (also available as forecast.io). Hyperlocal to-the-minute weather predictions is mindblowing. What’s more is the Dark Sky app is super slick and pretty, and that adds a lot to the experience.
If I could embed their app’s UI directly into mine, I’d definitely just do that. I can’t, but at least I still have the same data they do, because the forecast.io API that backs their applications is open to all developers. So the app issues an HTTP GET, parses the JSON, and displays the important information as text.
The current display tells me the current temperature and tqhe conditions for the next hour. These are human-friendly descriptions that the API response includes for you, which is just excellent. That is much better than forcing every app developer to figure out what’s important about the upcoming weather conditions. In the future I’ll tweak this to be quieter: for example, instead of always showing weather conditions, tell me only if it will rain today, and when I should expect it to start. After all, what I really care about is whether I should bring an umbrella, or if it’s oppressively frigid. Which, given that I live in Boston, I haven’t needed an app for this winter.
Dark Sky automatically figures out where in the world you are, but my iPad isn’t moving so I hardcoded my apartment’s latitude and longitude. Better to save the battery that geolocating would use. If I put this on the App Store, that would be a toggle switch in the settings.
The one hitch is this weather information needs to be reasonably up to date. My initial thought was to use Background Refresh to automatically pull the data while the iPad is asleep. But there are two problems with that. The obvious one is background refresh is going to burn battery pulling weather data all day and all night that I will never see. More subtle is that when I turn on the display on, the last refresh might well have been hours ago, so the data it is showing will be out of date.
The better way is old-fashioned but well-trodden: listen for
UIApplicationDidBecomeActiveNotification
, which is sent when the
iPad wakes from sleep back into my application. Only then do I refresh
the weather. The HTTP GET request has so far always come back
extremely quickly, so I haven’t even bothered putting in a loading
indicator yet. Now the data is always perfectly fresh, and I only pay
the battery cost of pulling weather data when I physically request
that information.
Drawing Canvas
The third component was silly. I had plenty of extra room on the iPad display. So I filled it with a scratchpad. To keep it simple there’s no UI: you can draw in any color you like, as long as it’s red. Long press the canvas to clear it.
It’s not elaborate or life-changing, but it’s a bit of fun, and what’s life without fun? :)
Future
Now that I’ve set up this iPad with the right hardware and software, it’s quickly become a part of my daily life. So I will continue to improve the app gradually for a long time. I already have a big list of things I want to add. First and foremost is integration with my phone’s pedometer. Since the iPad is the last thing I check before I head outside, I want it to tell me that I better walk the scenic route in order to hit my 10,000 steps for the day. I’ll have to write a companion iPhone app for that, since I don’t know of any pedometer apps with webhooks. I want a system for apartment-level notifications like packages arriving and the iPad’s battery being low. And finally I want to integrate my mail and calendar so that I don’t leave the apartment when I have an unseen URGENT!! email from the boss, or when I have a meeting in 30 minutes that I forgot about. Computers thankfully rule everything around me.
Maybe I’ll put it on the App Store, but this is more intended to be a tool custom-fit to me. I hope that such things will become increasingly common as more people pick up programming. They say it’s the new literacy. I’m not sure if I agree to that exent, but some basic software engineering would probably help most people in this increasingly digital world.