Work in Progress: Tweetable Office Door Sign

A sizable amount of my work week is spent outside of my office, and is difficult to schedule ahead of time:

  • Material testing jobs show up with little notice.
  • Students or faculty need help fixing a coding, instrumentation, or other problem, and it’s easiest to fix those on-site rather than in my office.
  • etc.

I’ve got a spot on my door for a 3×5 index card where I can post my known schedule (classes, regular meetings, that sort of thing), but I’ve always had to keep a stack of Post-It notes on hand for the other places I often go. The problem with the Post-It method is that I’ll often get called off to another location before I can get back to my office, and the notes quickly become inaccurate. And the notes can easily get misplaced or out of order, making them less useful.

And I liked the concept of the Panic Status Board, too.

So what I’m working on instead is a door sign I can update over the network from my smartphone, my home or office PC, someone else’s computer, etc. My office door already has a 12 inch square window in it, so any display I mount there can be protected, at least when the door is closed. There are several ways I could do this with varying tradeoffs:

  • YBox2 plus LCD TV and Twitter feed. Pros: would work out of the box for $150 in hardware costs and a bit of assembly and soldering. Cons: without modifying the Twitter widget code, I’d have to worry about the risk of someone else switching my door sign to another Twitter user, or else put the YBox2 on an isolated and firewalled network segment. And I’d have to either learn soldering or beg someone else to put it together for me.
  • Two XBee modules, one USB adapter, one compatible character LCD screen, and an always-on computer (probably my Mac Mini, since my main office PC is an often-mobile laptop). Pros: all the customization I’d ever want. Cons: all the customization I’d never want to implement. And more soldering.
  • Arduino, Ethernet shield, and firmware to parse an RSS or Twitter feed. Pros: probably easier to customize the firmware than the YBox2. Cons: $100 or more in hardware.
  • #twatch as an LCD Smartie display. Pros: super-cheap at $40 assembled. Cons: needing LCD Smartie to run on OS X, plus needing an extra network interface for the Mini.
  • Chumby or other Internet-connected display device. Pros: cheap, especially the $50 Insignia-branded one at Best Buy. Wifi built in. Cons: customization limited to whatever widgets people have already posted, or to my ability to code my own Flash widgets.


I ended up buying an Insignia Chumby because for $50, even if I just made it into a smarter alarm clock with MP3 and FM radio playback, it’d be an improvement over my current home clock. But I think it’ll end up working out well for my door sign. The setup details follow after the jump:

  1. Dedicated Twitter account for the door sign. I have an unused personal Twitter account, too, but I want to keep the door sign content separated from anything irrelevant I might post on my personal feed.
  2. Whatever Twitter application I want. For this particular application, I’ll keep a browser logged in to my door sign Twitter account, and point it to a simple page that can fill out a default status on the Twitter website. That way, all I have to do is click one link, optionally edit the status, and hit the Tweet button on the site.
  3. 12-Hour Flip Clock (Black) app with a 15-second play time.
  4. Chumby RSS Reader app with a 45-second play time. By default, this will let you tap forward and back through a given RSS feed. I could have used the Twitter app, but I really want to keep my sign’s Twitter ID as private as possible. I don’t want to worry about followers, protecting the tweets, etc. If I can get an RSS feed of the tweets, I stand a chance of sanitizing the content so it shows only what I want, in whatever format I want, and nothing more.
  5. Short Python script and cron job that filters my door sign feed, and saves the output somewhere accessible to the RSS Reader app.
  6. Modifying the web server hosting the RSS feed to ensure that the feed doesn’t get cached for more than 1 minute.

Page of Twitter Status Bookmarks

The basic page looks like this on WebOS:

The contents of my page are nothing more than a series of links to twitter.com:

<p>Clement Hall:
    <a href="http://twitter.com/?status=In Clement 101">101</a> |
    <a href="http://twitter.com/?status=In Clement 113">113</a> |
    ...
</p>

Clicking a link (for example, Clement Hall 113) takes me to the Twitter site and has the status text ready to edit or post as-is:

Python script

#!/usr/bin/python

# Grabs most recent tweet from RSS and reformats it for Chumby RSS
# Reader app

# Final Chumby display format:
#
# - feed_title
# - item_title
# - item_description (with Twitter ID removed, and appending timestamp
#   in local time)

# Credits:
# http://stackoverflow.com/questions/1766823/how-can-i-generate-rss-with-arbitrary-tags-and-enclosures

import feedparser, PyRSS2Gen, string
from datetime import datetime, timedelta
from pytz import timezone
import pytz

twitter_id = "REPLACEME"
feed_title = "Mike Renfro <renfro@tntech.edu>"
item_title = "Where's Mike?"
tz = timezone('US/Central')
timestamp_format = ' (%A, %B %-d, %-I:%M %p)'

try:
    parsed_feed = feedparser.parse("http://twitter.com/statuses/user_timeline/%s.rss" % (twitter_id))
    items = [
        PyRSS2Gen.RSSItem(
        title = item_title,
        link = x.link,
        description = string.replace(x.summary,"%s: " % (twitter_id),"")+\
        datetime(x.modified_parsed[0],
                 x.modified_parsed[1],
                 x.modified_parsed[2],
                 x.modified_parsed[3],
                 x.modified_parsed[4],
                 x.modified_parsed[5],
                 tzinfo=pytz.utc).astimezone(tz).strftime(timestamp_format),
        guid = x.link)
        for x in parsed_feed.entries[:1] ]

except:
    # Occasionally, the feed will fail, and be fine the next time I
    # check it. Since this isn't critical information, I'll just not
    # write any output at all.
    pass

else:

    try:
        rss = PyRSS2Gen.RSS2(
            title = feed_title,
            link = parsed_feed.feed.link,
            description = parsed_feed.feed.description,
            items = items[:1]
            )

    except:
        # Occasionally, the feed will fail, and be fine the next time
        # I check it. Since this isn't critical information, I'll just
        # not write any output at all.
        pass

    else:
        f = open('OUTFILE.rss','w')
        f.write(rss.to_xml())
        f.close()

And the cron job that runs every minute to update the sign is just

(cd /FOLDER && ./SCRIPT.py )

Web Server Modifications

I needed to enable and configure the Apache module mod_expires. Since my web server is Debian, all that required was running a2enmod expires, adding ExpiresActive On and ExpiresByType application/rss+xml "modification plus 1 minute" to the Apache virtual host entry, and finally reloading the Apache process.

Results

Here’s a resulting image from a virtual Chumby. The script removed my Twitter ID, and also added the date and time I posted the update. The original Twitter feed is untouched, and I can even make another page with the virtual Chumby Flash object embedded if someone wanted to see my status from somewhere else.

That’s it. All that’s left is to get the Chumby on the campus Wireless network, physically mount it in my office door window, and run power to it.

Join the Conversation

2 Comments

Leave a comment

Your email address will not be published. Required fields are marked *