Dev corner

Calling all engineers, tinkerers, hackers and geeks.

Pulsed sensor values using JSON

I'm using the JSON interface to read real-time values from the FLM for a pulsed watthour meter.

The meter generates 1600 pulses per kWh -- 1.6 pulses per Wh -- 0.625 Wh per pulse.

It's pulsing now at a rate of about once every three seconds. That's about 0.21 Wh per second, or 750 Wh per hour, or 750 W. The load is relatively constant. Not exactly, but no large variations. I am independently measuring the load with another meter that's reporting 705W -- fairly close.

The JSON API is returning 584 W for 13 seconds, then 1172 W for 3 seconds, then repeats. The last 2 to 5 fields in the returned JSON array are "nan". The nan timeslots appear to be regularly updated within a few seconds, all with the same value.

I can deal with the nan's. The bigger problem is the 2:1 variations in reported power.

Any idea why this is happening? How and when are those numbers calculated? I could understand if they were only updated when a new pulse arrives, but that should be once every three seconds, not 3 then 13. What's worse is that neither reported value is correct.

If I average the values over the 3+13 second range (694 W), that looks about right. I guess averaging is a workaround for now, but it also means the data won't be as "real-time" as I'd like it to be.

Real time gas usage

I wondering how the graphic on the website could be possible when you use little gas (heating water for ex.) because then, there is only one pulse (mine is 1 pulse/10 liter) and i think there can't be any calculation done to it.
Is the real time gas usage then ignored or is it stored in the FLM's memory ?
I like to know how the pulse and analogue calculations are done in the FLM's program.
Is there a file on Github where i can read that ?

API new year hangover?

I wonder if the flukso api has digested the switch to 2014 without problems.
My queries to the api don't work anymore with start and end query parameters.

I try this:
curl -v -X GET -H "Accept: application/json" -H "X-Version: 1.0" -H "X-Token: d8a8ab8893ea73f768b66b45234b5c3a" "https://www.flukso.net/api/sensor/c1411c6b4f9910bbbab09f145f8533b9?start=1356994800&end=1388375444&unit=watt"

And get:

* Adding handle: conn: 0x13fecc0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x13fecc0) send_pipe: 1, recv_pipe: 0
* About to connect() to www.flukso.net port 443 (#0)
* Trying 109.74.196.232...
* Connected to www.flukso.net (109.74.196.232) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
* subject: description=CAW9NEEP6FgUsBwL; C=BE; CN=www.flukso.net; emailAddress=postmaster@flukso.net
* start date: 2013-09-05 02:58:41 GMT
* expire date: 2014-09-06 02:38:44 GMT
* subjectAltName: www.flukso.net matched
* issuer: C=IL; O=StartCom Ltd.; OU=Secure Digital Certificate Signing; CN=StartCom Class 1 Primary Intermediate Server CA
* SSL certificate verify ok.
> GET /api/sensor/c1411c6b4f9910bbbab09f145f8533b9?start=1356994800&end=1388375444&unit=watt HTTP/1.1
> User-Agent: curl/7.32.0
> Host: www.flukso.net
> Accept: application/json
> X-Version: 1.0
> X-Token: d8a8ab8893ea73f768b66b45234b5c3a
>
< HTTP/1.1 400 Bad Request
* Server nginx/1.4.4 is not blacklisted
< Server: nginx/1.4.4
< Date: Wed, 01 Jan 2014 21:56:01 GMT
< Content-Length: 0
< Connection: keep-alive
<
* Connection #0 to host www.flukso.net left intact

However, with interval instead of start and end it works fine:
curl -v -X GET -H "Accept: application/json" -H "X-Version: 1.0" -H "X-Token: d8a8ab8893ea73f768b66b45234b5c3a" "https://www.flukso.net/api/sensor/c1411c6b4f9910bbbab09f145f8533b9?interval=hour&unit=watt"

Thanks,
roel

API return non existing data

Hi
I was trying to get data for 2012 for my electricity sensors. I specify period (from 1jan to 31 dec) , units watts and resolution month.
I installed my device around September 2012 but I still get data for Jan 2012 in API response. How is it possible?
thanks