How do I read out the "local JSON" data - I would like to read these values to enter into my own DB.
Is there a URL that shows the data in some json format?
thanks
right, RTFM :-)
Another Q about this:
The manual sais that 60 datapoints (1 minute) are available real-time. Will this stay the same if the communications to the Fluksoserver is halted (haven't tried - just asking).
Related Q: How long does the fluksometer can hold measurements without internet access? And as a result, are these measurements somehow made available through the local API then?
An ultimate goal would e.g. be to have 1 datapoint every minute for 1 hour - I would then have to read the data only every hour to store it a local DB.
Is this possible? If not, can this be made available in a next firmware release - as an option?
icarus75 |
Hi Johan,
The local API on the Fluksometer ia a real-time API. This is complementary to the server API, which allows you to fetch historical data.
When the Fluksometer is not able to report its readings to the Flukso server, it will buffer these readings in RAM. The daemon will apply aging to the data, so the older the data gets, the lower the granularity. Once it can connect to the server again, it will send out the buffered readings in a single burst.
For reading the minute values, just use the server api once every hour. See section 3.4 of the manual. Try out this curl command:
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"
Then change the sensor and token values.
HTH,
Bart.
johan |
How long are the minute-values kept in the DB on the server?
This would ideally return 1440 minute-values for Oct,1st:
Now, this doens't work...
Is there any way I can do this, or is the only way to get all the minute-values to poll every hour?
icarus75 |
Hi Johan,
This is what we store for each sensor in the rrd:
resolution -> #datapoints
1min -> 1440 (= 1day)
15min -> 672 (= 7days)
day -> 365 (= 1year)
week -> 520 (= 5years)
So yes, Flukso can give you a day's worth of data in minute resolution. However, if the start parameter falls just outside of the day interval, this can cause an error. What did your API call return?
Instead of start/stop, you could query the API by setting interval=day and resolution=minute, e.g.:
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=day&resolution=minute&unit=watt"
Cheers,
Bart.
johan |
cool - OK, I'll cron a curl every few hours - this way, I can have all data into my own mysql.
Goal is to incorporate this data into my solar-panel-website: hofmans.be/pv - feel free to take a look and comment.
Nice work! Did you put your code in a repository somewhere?
johan |
Thanks!
Nope, never worked with repositories before - I'll check and see where I can put it - tbc.
dijka007 |
just so I could put my code somewhere:
This script retrieves some values from flukso.net and inserts them in a mysql table. No temporary files, all done in memory.
I have some difficulty translating the timestamp to my local timezone, so in this example I just substracted 5 hours to get the right date, the 5 hours just to be sure.
Retrieved the value for one day, in kwh/year, so to get the value for that day just divide by 365 or 366.
#!/usr/bin/php -q
<?php
/*
#
# retreive from flukso.net the records of one sensor
# and insert them in a mysql table
#
# table contains two columns
# ts - datetime not null (primary key)
# value - smallint not null
#
# Using PHP FLukso API class from Geert Van Bommel
#
*/
# your Flukso settings
$sensorid='sensor-id-here';
$token='token-here';
$interval='month';# Should be one of {hour, day, month, year, night}
$unit='kwhperyear';# Should be one of {watt, kwhperyear, eurperyear, audperyear, lpermin, lperday, m3peryear}
$resolution='day';# Should be one of {minute, 15min, hour, day, week, month, year, decade, night}
or die ("Error ".date('Y-m-d H:i:s')."Failed to connect to MySQL.\n<b>A fatal MySQL error occured</b>.\nQuery:" . $query . "\nError:(" . mysql_errno($link) . ")" . mysql_error($link). " Affected rows is ".mysql_affected_rows($link));
mysql_select_db ($db_name)
or die ("Error ".date('Y-m-d H:i:s')."Failed to connect to the database ".$db_name.".\n<b>A fatal MySQL error occured</b>.\nQuery:" . $query . "\nError:(" . mysql_errno($link) . ")" . mysql_error($link). " Affected rows is ".mysql_affected_rows($link));
#
# Process all values
#
foreach($fluksodata as $value){
#
# If the value is "nan", skip this row
#
if ( "$value[1]" != "nan" )
{
# subtract 5 hours, to make sure we get the right date
Have a look at section 3.6 of the Fluksometer Manual [1]. You can access the local API through either the ethernet or wifi interface on port 8080.
[1]: http://www.flukso.net/files/flm02/manual.pdf
right, RTFM :-)
Another Q about this:
The manual sais that 60 datapoints (1 minute) are available real-time. Will this stay the same if the communications to the Fluksoserver is halted (haven't tried - just asking).
Related Q: How long does the fluksometer can hold measurements without internet access? And as a result, are these measurements somehow made available through the local API then?
An ultimate goal would e.g. be to have 1 datapoint every minute for 1 hour - I would then have to read the data only every hour to store it a local DB.
Is this possible? If not, can this be made available in a next firmware release - as an option?
Hi Johan,
The local API on the Fluksometer ia a real-time API. This is complementary to the server API, which allows you to fetch historical data.
When the Fluksometer is not able to report its readings to the Flukso server, it will buffer these readings in RAM. The daemon will apply aging to the data, so the older the data gets, the lower the granularity. Once it can connect to the server again, it will send out the buffered readings in a single burst.
For reading the minute values, just use the server api once every hour. See section 3.4 of the manual. Try out this curl command:
Then change the sensor and token values.
HTH,
Bart.
How long are the minute-values kept in the DB on the server?
This would ideally return 1440 minute-values for Oct,1st:
Now, this doens't work...
Is there any way I can do this, or is the only way to get all the minute-values to poll every hour?
Hi Johan,
This is what we store for each sensor in the rrd:
resolution -> #datapoints
1min -> 1440 (= 1day)
15min -> 672 (= 7days)
day -> 365 (= 1year)
week -> 520 (= 5years)
So yes, Flukso can give you a day's worth of data in minute resolution. However, if the start parameter falls just outside of the day interval, this can cause an error. What did your API call return?
Instead of start/stop, you could query the API by setting interval=day and resolution=minute, e.g.:
Cheers,
Bart.
cool - OK, I'll cron a curl every few hours - this way, I can have all data into my own mysql.
Goal is to incorporate this data into my solar-panel-website: hofmans.be/pv - feel free to take a look and comment.
beta version ready: http://hofmans.be/pv/start.php?action=flukso&fpw=D13pw
comments are appreciated!
Nice work! Did you put your code in a repository somewhere?
Thanks!
Nope, never worked with repositories before - I'll check and see where I can put it - tbc.
just so I could put my code somewhere:
This script retrieves some values from flukso.net and inserts them in a mysql table. No temporary files, all done in memory.
I have some difficulty translating the timestamp to my local timezone, so in this example I just substracted 5 hours to get the right date, the 5 hours just to be sure.
Retrieved the value for one day, in kwh/year, so to get the value for that day just divide by 365 or 366.
Nice work, i wondering how this is showing in the database.
Do you have a example of it ?
In the comment I made a mistake, the table-column named value is a float.
I only have the device three weeks, so I'm still tinkering.
In the database I get:
ts value
2014-04-13 16.526
2014-04-14 16.1151
2014-04-15 11.8137
2014-04-16 13.2411
2014-04-17 16.1507
2014-04-18 18.2082
2014-04-19 12.4767
2014-04-20 12.5973
and these I use to calculate a value per month, by just adding them.
Ref to https://duckduckgo.com/?q=site%3Aflukso.net+log+to+database - kindly share code through a (github) repository as those are linkable and retrievable...