Summary

I've published a new module that allows KRL rulesets to easily update a Cosm datafeed. This blogpost describes how to use it.

Cosm Logo

I just wrote a simple module for updating a Cosm feed. Cosm is the old Pachube (much better name, I think). Scott and I interviewed Cosm's founder Usman Haque on IT Conversations a while back. Cosm provides a way to organize, log, graph, and publish data feeds for almost anything.

My Cosm module for KRL provides a single function, update() that takes two parameters, the datastream ID and the new value. For example, here's a simple rule that is selected when there's a new temperature value from a thermostat. The rule updates the Temperature datastream with the value of the temperature event atttribute:

rule process_temperature {
  select when thermostat new_temperature
  cosm:update("Temperature", event:attr("temperature"));
}

As you can see the module hides the details of the Cosm API.

The module is easy to set up. Assuming you've stored your API key in the meta section of the ruleset, you can use the module as shown here:

use module a16x150 version "dev" alias cosm with
     api_key = keys:cosm("api_key") and
     feed_id = "46667"

Of course, you'd have to have the right feed identifier—the one shown is fake.

Here's a screenshot of a feed I set up with data being posted using this module from a KRL ruleset.

Screen Shot 2012-07-05 at 4.16.41 PM

At present, the only thing supported by the module is updating a datastream with a new data value. Of course, other actions could be added to support the rest of Cosm's API. If you'd like to help flesh it out, let me know and I'd be happy to share the module with you so you can modify it.


Please leave comments using the Hypothes.is sidebar.

Last modified: Wed Feb 12 18:25:14 2020.