[bug] Lua scripts returns occasionally impossible high consumptions

I noticed that the API occasionally returns very high values.

For example, when I execute:

  1. curl  http://192.168.252.45/sensor/d281ff4e4f6a8a838897e02469d2315f?interval=minute&unit=watt

it can return:

  1. [[1283861258,2],[1283861259,1],[1283861260,1],[1283861261,2],[1283861262,1],[1283861263,2],[1283861264,1],[1283861265,1],[1283861266,2],[1283861267,2],[1283861268,2],[1283861269,2],[1283861270,4294967293],...]

Other values I've seen are:
2386093
2147483647
4294967293

I have found so far no way to reproduce it, it occurs apparently randomly.
Anybody else seen this problem?

icarus75's picture

Hello Mario,

I haven't been able to trigger the error condition myself. However, code analysis shows that an 'underflow' condition on the local API interface could be triggered when measuring loads lower than 7.2W given the right context. This should be the cause for the 4294967293 value. Commit fdc2e35 in the develop branch improves the accuracy of power measurement calculation and should prevent the underflow condition altogether by rounding down the multiplication constant iso rounding it up.

2386093 is 1/900th of 2147483647. Nowhere near the power calculations do we use a factor 900. Since 900secs equals 15mins, could it be that you got the 2386093 result after processing the data, e.g. converting to a 15min interval?

Note that this bug is related to the experimental real-time local API interface on the Fluksometer. It does not affect the api.flukso.net API in any way.

Thanks for posting!

Cheers,
Bart.