UPDATED! Connecting a Pachube sensor to Paraimpu with few clicks

NOTE: This tutorial has been UPDATED in order to reflect the recent changes in the Pachube Web site. Enjoy!
 
Goal: Register on Paraimpu a Sensor data stream from Pachube and then connect it to the 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 Web site select a feed, for instance:
http://www.pachube.com/feeds/18863

and annotate the chosen datastream number, for example, the "temperature" datastream index for the selected feed is "0", as in the following snapshot:

 


This particular datastream will produce JSON 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 to Paraimpu and create a new Pachube Sensor from palette. Configure it as in the following snapshot:





You’ll find your Pachube API key under Pachube Home, My Account section (on the right) -> My API Keys.
Copy and paste your personal key in the Paraimpu API Key form field.


Then click Register and the Sensor is added and ready. 
After some minutes data will flow. 
At the moment (release 0.4.5) the polling time is fixed in 120sec. In next releases this value will be fully configurable.



Fourth step:
Create a Twitter Actuator in the Paraimpu 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 just created foo Sensor



and select the existing Twitter Actuator in the pop-up list of available Actuators.




Sixth step:
Configure the just created new connection clicking on its manage wheel 

The connection details page will be showed, configure the connection as follows:

Filters and mappings are expressed by means of Javascript expressions. 
Given the JSON structure of Pachube datastreams, the condition foo.current_value>=14 ensures that only data with temperature greater or equal to 14 degrees are sent from Sensor to the connected Actuator.
Similarly, the mapping is defined by a condition and by a string containing a template (expression between <% and %>), which is a regular Javascript expression. 

Finally, don't forget to activate your connection clicking on the Activate button:



Then, go to check your Twitter timeline.

Leave a Reply

© 2014-2015 Paraimpu Srl . Powered by Blogger.