ioBroker / ioBroker.influxdb

Store history data in InfluxDB (not for Windows)
MIT License
36 stars 25 forks source link

Integral does not work as expected #393

Open GermanBluefox opened 6 months ago

GermanBluefox commented 6 months ago

By the following getHistory request:

var end = new Date();
var start = new Date("2024-05-16T00:00:00.000+02:00");
end.setMinutes(0);
end.setSeconds(0);
end.setMilliseconds(0);
end.setHours(end.getHours() + 1);

sendTo('influxdb.0', 'getHistory', {
        id: 'javascript.0.energyFeedIn',
        options: {
            start:      start.getTime(),
            end:        end.getTime(),
            // step: 3600000,
            aggregate: 'integral',
            integralUnit: 3600,
            integralInterpolation: 'none',
        }
    }, function (result) {
        console.log('Result: ' + result.result.length);
    });

We have following Influx query v1:

SELECT value from "javascript.0.energyFeedIn" WHERE time <= '2024-05-15T21:58:48.000Z' ORDER BY time DESC LIMIT 1;
SELECT integral(value, 3600s) as val from "javascript.0.energyFeedIn" WHERE  time > '2024-05-15T21:58:48.000Z' AND  time < '2024-05-16T08:01:12.000Z' GROUP BY time(72000ms) fill(previous) ORDER BY time ASC LIMIT 2002;
SELECT value from "javascript.0.energyFeedIn" WHERE time >= '2024-05-16T08:01:12.000Z' LIMIT 1

Result image

Expected are max 24 values.... but got 470