If I ever open a coffeeshop, I think I’ll call it DCMLO … or maybe ”Deesy Emloh.”
Category: thingaday
Ruffled
watching the ducks
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.
I made a thing
Making a lamp out of a bottle is pretty straightforward, but for fun I thought I’d document how this one was thrown together.
Ingredients
- a bottle (save the cap) – empty (depending on how you empty it, best not to do this all at once)
- filler – I used green sand. The hobby store had sand in many colors, $2 for a 1.5 pound plastic jar. It only took half the jar to fill this 750 mL liquor bottle. So, roughly 1 pound of sand per liter of volume you’re filling.
- a lamp kit – includes the fixture, wire, harp, etc
- a lamp shade – It seems not many places sell green ones. Finally stumbled on this one at Ikea. SKIMRA. It was sold as a shade for pendant light.
- a light bulb
- a house, apartment, or other building – this should have some sort of power outlet, where you’ll plug in your lamp
Assembly Notes
The basic process is this: make an extra hole in the bottle; string the bottle onto the lamp wire; close the extra hole (hot glue!); fill the bottle with sand; assemble the bottle cap (with a new hole in it) and all the lamp parts and screw it into the top of the bottle; plug it in.
Some tips:
- When drilling the hole in the glass, remember that glass would rather be sand again, and will try to break to accomplish this. Drill slowly.
- After feeding the wire through the bottle, the plug end should be dangling out the back of the bottle. If the plug end is coming out the mouth of the bottle, you did something wrong.
- If the wire and plug are inside the bottle, you may be using a Klein bottle. Re-orient yourself and the bottle and start again.
- Don’t forget to clean up your mess!