Flukso announces the immediate availability of its JSON/REST API at the 2010 CeBit exhibition in Hannover. Fluksonians are now able to retrieve time series data of their electricity sensors through the Flukso API. Let's start with a working example:
curl -k -v -X GET -H "Accept: application/json" -H "X-Version: 1.0"
-H "X-Token: d8a8ab8893ea73f768b66b45234b5c3a"
"https://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?interval=hour&unit=watt"
Where:
- X-Version: Denotes the desired API version. Should be set to 1.0.
- X-Token: A token associated with the specific sensor id. Different tokens per sensor will allow for varying access permissions, e.g. only allow data in 'month' resolution. This feature will become available in the near future. We now provision a single token per sensor. The token can be found next to its respective sensor id (see below).
- Sensor: Your sensor id's are displayed under the 'my account' -> 'sensor' tab. Just substitute the above sensor id and token with your own and you're ready to go.
- Interval: Should be one of {hour, day, month, year, night}
- Unit: Should be one of {watt, kwhperyear, eurperyear, audperyear}
Data is returned as an array of [unix timestamp, value] tuples, where value will be reported as a "nan" string when no data is available for the interval.
[[1267802160,69], [1267802220,69], [1267802280,73], ... , [1267805760,"nan"]]
The unix timestamp denotes the end of the interval for which the value is reported. So in the above example [1267802220,69] means that in the one-minute interval [1267802160, 1267802220] 69 watts of electricity has been consumed.
Thanks to Geert and Mathias for their valuable feedback during alpha testing.
Have fun!
Update 15/03/10: Added info on where to retrieve token information.
Comments
Hi Bart,
great work! The Ruby Flukso library I've written is here:
Documentation is currently an issue. You can install the library using rubygems:
Have a look at the various flukso_* commands. If you have any questions, just ask.
Cheers,
-Mathias
PS: Cebit was indeed fun, and profit!
It would be nice if the JSON thingy comes available in the device itself as well!
Hi Flok,
A local Fluksometer JSON/REST interface is in the works. The initial commit adapting the daemon code to publish the sensor measurements of the most recent minute with a one-second resolution can be found here. The basic functionality is up and running in a test setup. We're able to call the local API from a Javascript-based graph which refreshes every second. The code currently doesn't accept any query parameters in the HTTP GET call. So there's still some work to do. We're planning to roll this functionality in a new Fluksometer release based on OpenWRT Backfire.
Cheers,
Bart.
Hi Bart,
Great to be able to access the data from the flukso site. Accessing it from java took a bit more effort because the default java environment does not have your (root) certificate. Installing that would be an option, but that must be done in each JVM on each computer i want to run my code on. Not what i wanted.
Or... bypass the security :-)
So i have written a small program which installs an "all accepting" trust manager to make the https call. Further more i am using the google simple json library to parse the result.
Hopefully for anyone easy to extend into their own java program.
Have fun,
Bram