Connecting a Pachube sensor to Paraimpu with few clicks


IMPORTANT: This tutorial has been updated due to the recent Pachube Web site changes, please check the NEW VERSION.

Goal: register on Paraimpu a datastream from Pachube and then connect it to our twitter virtual actuator and configure the connection such as a tweet is posted only if a given condition is satisfied. Once the Pachube sensor is registered you can connect it to every Paraimpu actuator available in your dashboard.






First step: Please Log on Pachube and Paraimpu with the respective credentials. If you don’t have credential in one or both systems then create your profiles according to the respective procedures.



Second step:

On pachube select a feed, for instance
http://www.pachube.com/feeds/18863

For that feed select a datastream, then click on *embed,history,triggers,etc* and you’ll get a form where you can see the URL for that data stream. In the example is

http://api.pachube.com/v2/feeds/18863/datastreams/0

append a trailing “.json” to the URL to obtain

http://api.pachube.com/v2/feeds/18863/datastreams/0.json

This URL will produce data as follows:

{"max_value":"90.9620991254","at":"2011-04-18T12:40:08.026503Z","min_value":"0.0","tags":["Temperature"],"unit":{"type":"derivedSI","label":"temp","symbol":"C"},"current_value":"16.0926847423","version":"1.0.0","id":"0"}




Third step:
Go on paraimpu and create a new pachube sensor from palette. Configure it as in the following picture




You’ll find your pachube API key under pachube -> profile -> settings
Then click register and the sensor is ready. After some minutes data will flow. At the moment (release nuntereggaepiu) the polling time is fixed in 120sec. In next releases this value will be fully configurable.




Fourth step:
Create a twitter actuator in the workspace, unless you already have one.



Fifth step:
Create a connection between the pachube datastream and twitter. To do that click the follow button on the sensor





and select the existing twitter in the list of available actuators


Sixth step:
Configure the new connection clicking on the *manage* wheel
The connection details will be showed
Filters and mappings are expressed by means of Javascript expressions. Given the JSON structure of pachube records the condition foo.current_value>=14 that only records with temperature greater or equal to 14 degrees are sent from sensor to actuator.
Similarly, the mapping is defined by a condition and by a string containing a template (expression between <% and %>)
  

Leave a Reply

© 2014-2015 Paraimpu Srl . Powered by Blogger.