Pachube and the wifi thermostat

A few months ago, I installed a wifi-enabled thermostat. It connects to a service in the cloud ( my.radiothermostat.com ) and from there you can connect to it from its Android and iOS apps, or directly from the Web. And I was pretty excited (maybe inordinately so) to find out it has an open REST API with some pretty decent documentation. This thermostat speaks JSON.

Literally within an hour of finding the API docs, I had a Python script grabbing temperature readings from the thermostat and pumping them intro a Pachube feed. It took longer to get the thing attached to the A/C and reliably connected to wifi.

Code

I used the requests module for retrieving the JSON. Here’s the short version (config variables have been hardcoded and error checking removed for brevity ;).

response = requests.get( 'http://192.168.1.123/temp' )
indoor_temp = json.loads( response.content )['temp']

It helped speed things along significantly having the Pachube part mostly taken care of by the eeml module. Adding that temperature as a new datapoint to my feed goes something like this.

import eeml
pachube = eeml.Pachube( PACHUBE_API_URL, PACHUBE_API_KEY )
# This particular feed has named datastreams -- if you're posting to one with a numerical ID instead, enter that here.
datastream = 'temp'
pachube.update( [ eeml.Data(datastream, indoor_temp) ] )
pachube.put()

Excuses

I was about to wrap this up with a list of reasons I haven’t posted the entire chunk of code on github yet. But like many unpublished personal software projects, it really comes down to some combination of perfectionism and (perceived) lack of free time. “The perfect is the enemy of the good enough” and all that. The right way would be to just post it already – having code out there publicly means other people can spend their free time to help me make it perfect. 😉

Maybe next weekend.

Flickr screensaver for Linux

The TV in the kitchen is wired up to the MythTV box (which sits in a closet in another room).  If the TV is left on after a recorded show ends, the MythTV menus are not so pretty to look at.   The standard “Pictures folder” screensaver is nice, but I got tired of manually copying and managing pictures on the Myth box.  Why not use Flickr as the automated source of the pictures?

I poked around for “flickr screensaver linux” on Google and was a bit disappointed. Most of the results a) discuss Mac- or Windows-only solutions, b) link to programs that no longer exist, or c) are more complicated than what I need.

Well, it is Linux … time to roll my own. Maybe this solution is so obvious that no one bothered to document it, but this is what I came up with.  Maybe it will save time for someone else.  Besides, I need a new post to break in the new theme on this blog. 😉

The basic formula: RSS feed from Flickr + podcast downloader + cron +  “Pictures folder” screensaver.
Read on for the details …

Continue reading “Flickr screensaver for Linux”

Dorkbot Austin!

Natalie and I went out dorking tonight 🙂 The dorkbot made it’s second appearance in Austin tonight at Cafe Mundi. There was some great geeking going on .. I think we missed the first presentation though (got there around 8:30).

First one we saw was Joel Greenberg showing off his nifty homemade mic zeppelin. According to my del.icio.us links, I read about this back in April, but didn’t realize he was from Austin. (Note to self: checkout his podcast )

Next up was Rich LeGrand and his Lego-bot with a Gameboy brain. Basically, he put an FPGA and some flash memory on a card that fits in the Gameboy Advance cartridge slot, which lets the GBA brain talk to sensors and motor controllers and cameras and all kinds of roboty goodness. For a demo, the bot spotted a loose lego piece, wheeled itself over, grabbed the piece, and moved it to the other side of the table. It was also able to learn and repeat and little dance — you push the thing around the table, and it senses the movement through the motors, records it, and plays it back. ( video! )

The Austin Robot Group had the last two presentations: Eric Lundquist explained the Babbling Head and had it sing a few songs, and Vern Graner demoed the controller board/prototype of a funky spin-art game-type-thing they’re making for the next First Night Austin.

All kinds of Neat Stuff[tm] .. we’ll have to go back next month. (I heard they had a homemade Tesla coil last month!) I managed to catch part of the evening with the voice recorder on my iAudio. I’ll try to clean it up and stick it online sometime in the next few days.

[tags] austin, austintx, geek, dorkbot, dorkbotaustin, nerd, robots, robotics[/tags]

Network-enabled Garage Door

This has been in my “to-blog-about” queue for a while, and seeing this post on the Make blog tipped it into the “must-blog-now” category. Summary: combine a wifi adapter, some sensors, and some electronics and you can monitor your garage online.

A few months ago, I had a similar idea but took a different approach. I was a bit more speed-oriented (some might say lazy) and decided to use the X10 system I already have going in the house. Maybe not as elegant or robust as making a circuit from scratch and hooking it directly into the ethernet, but

Sensing

I used an X10 Powerflash module connected to a reed switch mounted on the overhead door. When the door changes state, it sends an X10 code of on or off, telling if the door was just opened or closed. The signal is received by an X10 CM11A attached to the house server, which triggers a short script that logs the time and status in a text file (again, “speed-oriented” .. as in speed of completion). Another script generates a (SSL and password protected) web page displaying the current state of the overhead door and time of last change: “Garage was opened at 8:00 am”.

Control

Now I have webpage that tells me I left the garage door wide open when I took off for work … if only I could close it remotely! Once more, with ease-of-installation in mind, I grabbed another X10 product from Fry’s, the Universal module and wired it to the same contacts that connect to the wall-mounted door-opener button. A small addition to that web script, and a click will use the heyu program to generate the proper X10 signal, causing the relay to fire and close the door.

Side note:

Our garage door has an “electric eye” to detect an object (or person) in the path of the closing door, and will reverse and refuse to close if something’s in the way. (I believe this is required by state law.) It’s still possible to close the door on your car if the bumper and the beam are at different levels, but at least it makes it harder 😉 There’s an LED on the sensor itself, but it’s hard to see from inside the car without adjusting the side-mirror to an odd angle. So there’s a possible enhancement to my version of the garage monitor: use the signal from the original obstruction sensor to drive a second better placed LED.

[tags] house,homeautomation,x10,nerd,geek,make,diy,garage,sensors,control,remotecontrol[/tags]

Nerd Hotrod

Since I got my new car in October, I’ve been planning and scheming and pondering how I would put a computer in it. Actually, a mobile car-mounted computer has been on my mental (Want)ToDo list for a while, initially just to play mp3’s. Then I got an iPod, and the need for bogomips speed became less pressing.

With the new car, I had no tape deck .. so hacking was required to add a line-in (by way of FM modulator) to connect my external digital audio device. In the course of this hacking, I discovered it’s fairly simple to take apart the interior of a Mazda 3 (see my del.icio.us links for some hints). So ideas and possibilities started popping into my brain .. “I could put the GPS under this panel here .. and the wires would go here”.

Also, there’s this nifty device called the “AuxMod”:http://www.sylfex.com/products/AuxMod/ .. which provides a much cleaner line-in than a modulator. And the Advanced version adds a serial port for some nifty interfacing to the OEM head-unit — the buttons on the steering wheel could control a PC, and the PC could send text to the in-dash display ..
more ideas 🙂

Anyway, I finally started this weekend. I pulled off a few plastic panels and put USB WiFi adapter and a GPS receiver under the dash, right behind the defroster vent. The actual computer (case+board+DC-DC power supply) is still on the way, but I’m planning on sticking it right under the driver’s seat. I already have the USB and audio cables under there, ready to plug in. I also stuck an open USB port where the ashtray used to be.

Once I get the PC in there, I’ll start playing with the software.
OS will be Linux of some flavor (probably “Debian”:http://debian.org or “Ubuntu”:http://ubuntu.com ) .
“MPD”:http://musicpd.org has worked great around the house as a headless music player, should work well in the car too.
Still looking for a GPS program that will work well with a text-only display (or no display). Some simple track logging should be pretty easy to set up though.

Other possible hardware:
bumper mounted digital camera(s) – you’d be surprised how hard it is to accurately remember the license plate number of a hit-and-run driver 😛
OBD-II interface – think /var/log/car_engine 😀

Case and PC should be arriving this week, I’ll post more after I have it installed .. *evilgrin*

Location, Location, Location

I am here … but where’s Waldo?

Earlier this week, I heard about this thing called Mologogo .. which is basically cellphone+gps+java app+internet = homemade lojack! So I bought myself a cheap-ish Motorola i285 on the Boost pay-as-you go plan. It has builtin Assisted GPS (somehow uses the cell towers to help with the GPS fix I think). The pay-as-you go lets you get on the “wireless web” for $0.20/day (cheap!). And the mologogo java app lets you upload your coordinates to the intarwebnets at regular intervals.

So, like I said .. I am here. The app on the phone also displays a small map of your location, and any friends’ locations who might be logging their own coordinates. Nifty ..

I’m thinking about plugging the phone into the lighter socket in the car and leaving it there .. out of site, but still able to catch the GPS signal. 🙂

old email

Wow .. I just found a bunch of old backup files with emails from 1996 ! That’s like .. *counting* .. about 6 computers and 10 email addresses ago. Now I just need some scripts that will convert messages from Eudora and Juno (juno.com! when all they did was free dialup email!) into some nice normal unix mail format.

I was a big dork in 1996. 😉

a sample:

Hey. howzit goin?
Would like to win a laptop? I found this contest on the web where you have to solve all these puzzles and when you finish, you get yourself entered into a drawing for a pentium 75 laptop with a 28.8 PCMCIA modem.. here’s the URL

A modem — how quaint! 28.8 kbps no less!

Also found backups of old webpages, but I’ll spare you the horror.

time

Well, this stinks … AT&T Wireless/Cingular has their clocks set wrong — my phone is autoupdating its clock (based on the cell network time) to about 3 minutes behind the government’s atomic clock. No wonder I’m always late. 😉

Wiki vs. ink-on-paper update

Still trying to use my private wiki for note taking at work .. I’m not, as I’d hoped, using it for everything I could possibly want to record — I can type faster and cleaner than I write , but I can pick up a notebook and pen faster than I can load the right webpage or open the right file in a text editor. And a spiral is so much lighter and easier to grab on the way to a meeting.

Haven’t completely abandoned the wiki though .. upgraded my version of Instiki today, in fact. And since there appears to be no “import” function, I rolled my own. I was impressed with how easy that turned out to be — curl is quite versatile with the HTTP POST action. I’d post the actual script to show you, but I left it at work .. maybe tomorrow

Expiring mp3’s

(No, this has nothing to do with DRM .. )
It’d be neat if the iPod would let you flag something as “never play this
again”. Sure, you can already do this with the rating system — I give
something a 1-star rating, and then once in a while go remove all the mp3’s
with 1 star. But unless you make a special smart playlist and always use that
playlist, you might hear it again before it’s deleted. With a separate flag, it would never pop up again in a random shuffle.

This flag would have another use .. say I use streamripper to save some NPR program or
download some news from someplace like this. I probably only want to hear
this mp3 once, and only within a few days of copying to my iPod. So I set an
expiration date and/or a playcount limit. So after I hear it once or the story
is a week old, it never comes up randomly again. It stays on the iPod until I
explicitly delete it or all the expired tracks, so I can still manually select
it if I really do want to hear it again.

Just a thought ..

Might be possible someday with this Linux firmware for the iPod