Tag Archives: hacking

Monitoring and Controlling your Proliphix thermostat with Ruby

It’s been 2 years since I got my Proliphix thermostat, and while I did some early hacking on it, largely the whole effort just sat around for the last 2 years.  However, with the fun of connecting up my weather sensors, I went back in this weekend and beat the code into a much more sane interface.

Thermostat.rb 1.1.1 was released yesterday.  It provides a concise interface to the Proliphix web services API.  An example of the usage is something like:

  thermostat = Thermostat.new("hostname", "admin", "password")

  # get the current temperature
  current_temp = thermostat.temp

  # get the current setback heat value
  current_target_temp = thermostat.heat_to

  # set the thermostat to 69F (units are set in the thermostat)
  thermostat.heat_to = 69

I’ve got support under the covers for everything in the Proliphix API. I’ve only mapped about 1/2 of it to the user visible interface, starting with all the functions I’ve tended to need or use.  I was a good little agile developer and built unit tests for everything here.  Using the new module, I added the thermostat to my homegraph code, with some pretty reasonable results:

All this is released under the MIT license.

Building ruby projects with newgem

Over the weekend I was working on revamping a whole set of older ruby projects, some having to do with my Proliphix Thermostat.  I had this crufty Rakefile from the icalendar project that I’d been copying and modifying for new projects, and it was slowly degrading.  I thought that there had to be a better way.  There is, it’s called newgem.

Newgem is like h2xs in the Perl world, something to stub out a new module with all the right files and structures.  But, as the Ruby folks tend to do, it ups the ante in the process.  In addition to the basic build, packaging, testing, and coverage results you’d expect, you also get a targets for: creating you rubyforge website, publishing your gems to rubyforge and gemcutter, posting release announcements on rubyforge, and even posting blog posts about your release (though I haven’t configured that one yet).

The release cycle is now:

rake release
rake website
rake post_news

The Rakefile created is loading these features from base modules, so it’s only ~ 30 lines, a heck of a lot easier to maintain than the 300 line Rakefiles I had which provided about 1/2 these features inline.

If you are doing Ruby development, you should really check out newgem.

The new Poughkeepsie Farm Project site is live!

About 14 months ago I raised my hand to help with a more interactive web presence for the Poughkeepsie Farm Project.  This kicked off a large discussion over the course of the year, a web committee, and a great pro bono new graphic design.  Many many people were involved to get this project to completion, I just consider myself a catalyst.

Today, after a year of work, we launched the new farmproject.org:

Go check it out.  Now that we’re on a drupal platform, we’ll be rolling in smaller features over time.  I’ve got a few ideas queued up that I’ll try to get out there for the first member pickup at the end of May.

Temperature.rb released

As I’ve been working on my weather station at home at nights, I realized the code would be a lot cleaner if I wasn’t constantly keeping track of temperature units.  So I created the Temperature module for Ruby which adds methods to numbers to make them implicitly temperatures, as well as a parsing method on strings.  To get a flavor of it, here are some examples:

freezing_in_F = 32
freezing_in_C = freezing_in_F.to_C

boiling_in_C = 100
boiling_in_C.units = "C"
boiling_in_F = boiling_in_C.to_F

absolute_zero = "0K".to_degrees
absolute_zero_in_C = absolute_zero.to_C
absolute_zero_in_F = absolute_zero.to_F

The full documentation for the project is on rubyforge.  Gems, tar, and zip format have all been published, and it should be propagating out to the main gem servers tonight.  It’s not exceptionally complicated, however it is convenient, and it’s even got 236 unit tests to ensure it’s doing things right.  The code is released under the MIT license, so you are pretty much able to do anything you want with it.

Catching bad links with jquery

We’re 1 step closer to the launch of the new Poughkeepsie Farm Project website, so it’s down to some final edits before it gets flipped live.  While I was looking over the test site the other day, I realized we still had some links, and images that referred to the existing site, which would break once we did the final domain switcheroo.

I came up with the following snippet of jquery to highlight bad links and images client side so that editors would realize they needed to do something about them:

function highlight_bad() {
    $("div[id='content'] img[src^='http://farmproject.org']").css("border","9px solid red");
    $("div[id='content'] img[src^='http://www.farmproject.org']").css("border","9px solid red");
    $("div[id='content'] img[src^='http://test.farmproject.org']").css("border","9px solid red");
    $("div[id='content'] img[src^='http://pfp.dague.org']").css("border","9px solid red");
    $("div[id='content'] img[src^='http://farm.dague.org']").css("border","9px solid red");
    $("div[id='content'] a[href^='http://farmproject.org']").css("border","9px solid red");
    $("div[id='content'] a[href^='http://www.farmproject.org']").css("border","9px solid red");
    $("div[id='content'] a[href^='http://test.farmproject.org']").css("border","9px solid red");
    $("div[id='content'] a[href^='http://pfp.dague.org']").css("border","9px solid red");
    $("div[id='content'] a[href^='http://farm.dague.org']").css("border","9px solid red");
}

So every time we find a link or image that starts with an absolute url to one of the addresses the site has had inside the content block, we highlight it. This has been incredibly effective so far in catching some things I didn’t even realize was an issue.  This with the combo of drupal’s broken link detector internally is helping us ensure the content is consistent prior to launch.

Adding stock scripts to OpenSim

Mo Hax and I have started a weekly effort to gather up some of the IBM internally created OpenSim / Second Life content and contribute it to OpenSim as stock content. As OpenSim approaches the 0.6 release, it would be good to have some more reasonable stock content included for those people that aren’t Second Life Heads, and have huge inventories of their own stuff sitting on their disks. The results of week one was a single handshake animation, and a lot of understanding on how our stock content system works, and how it should be changed to make it easier to contribute to it.

Yesterday, in between builds and meetings, I decided to refactor a few LSL scripts I had that used unique OSL functions that let you dynamically create textures on objects, both from text drawing commands, and from images of the internet. Those are all now in the OpenSim Library, and accessible for anyone in world. They are under the same license as OpenSim, so do what you will with them. 🙂 (Note: I’ve found the client caches the inventory trees, so you’ll need to clear cache before they show up.)

The scripts contributed yesterday are as follows:

  • osTextBoard – a text board I wrote to do agendas or note taking in world. Modify the script, hit save, and you get the content in your text board texture. Multiple font sizes, colors, and names are used.
  • osWeatherMap – a 3 panel cycling weather map for US weather. This is inspired by the work nebadon did on osgrid.
  • GrafittiBoard – Justin Casey’s GrafittiBoard (as seen on osgrid), which is similar to text board, but has an llListen hook so that if you talk on channel 43 it displays it on the board.

Consider all of these as launch points to more complex things. But, they’ll at least give people a flavor of what is possible. And you’ll get it with every opensim build.