ioBroker / ioBroker.influxdb

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

Using count 1 with removeBorderValues can return empty query even if we have datapoints in time range (assumption) #261

Open foxriver76 opened 2 years ago

foxriver76 commented 2 years ago

I use a script which fires several getHistory requests, if I do not use count: 1 I get multiple results, if I use count: 1 it seems like the single value is cut off and nothing is returned.

Here is a snippet of the getHistory request:

        const rainResult = await getHistoryAsync('influxdb.0', {
            id: RAIN_DB_ID,
            start: start,
            end: end,
            removeBorderValues: true,
            returnNewestEntries: true,
            aggregate: 'none',
            count: 1
        });

getHistoryAsync is just a promise wrapper around getHistory.

Here are the logs, for more information just contact me here.

2022-05-20 11:01:52.726 - debug: influxdb.0 (24528) Incoming message getHistory from system.adapter.javascript.0
--
2022-05-20 11:01:52.727 - debug: influxdb.0 (24528) Query to execute:
from(bucket: "iob")
\|> range(start: 2022-05-19T22:19:52.726Z, stop: 2022-05-20T09:01:52.726Z)
\|> filter(fn: (r) => r["_measurement"] == "rain_mm_today" and contains(value: r._value, set: [true, false]))
\|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
\|> group()
 
2022-05-20 11:01:52.726 - info: javascript.0 (23828) script.js.common.debug-ts: start 1652998792726
2022-05-20 11:01:52.726 - info: javascript.0 (23828) script.js.common.debug-ts: end 1653037312726
2022-05-20 11:01:52.749 - debug: influxdb.0 (24528) Query to execute: from(bucket: "iob") \|> range(start: 2022-05-19T22:19:52.726Z, stop: 2022-05-20T09:01:52.726Z) \|> filter(fn: (r) => r["_measurement"] == "rain_mm_today") \|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") \|> group() \|> sort(columns:["_time"], desc: true) \|> limit(n: 1)
2022-05-20 11:01:52.761 - debug: influxdb.0 (24528) Send: 1 of: 1 in: 34ms
2022-05-20 11:01:52.761 - debug: influxdb.0 (24528) sendTo "getHistory" to system.adapter.javascript.0 from system.adapter.influxdb.0
2022-05-20 11:01:52.763 - info: javascript.0 (23828) script.js.common.debug-ts: [{'_start':'2022-05-19T22:19:52.726Z','_stop':'2022-05-20T09:01:52.726Z','_time':'2022-05-20T07:24:53.307Z','ack':true,'from':'system.adapter.influxdb.0','q':0,'val':1.5,'ts':1653031493307}]
2022-05-20 11:01:52.763 - debug: influxdb.0 (24528) Incoming message getHistory from system.adapter.javascript.0
2022-05-20 11:01:52.764 - debug: influxdb.0 (24528) Query to execute:
from(bucket: "iob")
\|> range(start: 2022-05-18T22:19:52.763Z, stop: 2022-05-19T22:19:52.763Z)
\|> filter(fn: (r) => r["_measurement"] == "rain_mm_today" and contains(value: r._value, set: [true, false]))
\|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
\|> group()
 
2022-05-20 11:01:52.763 - info: javascript.0 (23828) script.js.common.debug-ts: [{'_start':'2022-05-19T22:19:52.726Z','_stop':'2022-05-20T09:01:52.726Z','_time':'2022-05-20T07:24:53.307Z','ack':true,'from':'system.adapter.influxdb.0','q':0,'val':1.5,'ts':1653031493307}]
2022-05-20 11:01:52.763 - info: javascript.0 (23828) script.js.common.debug-ts: maxRain 1.5
2022-05-20 11:01:52.763 - info: javascript.0 (23828) script.js.common.debug-ts: start 1652912392763
2022-05-20 11:01:52.763 - info: javascript.0 (23828) script.js.common.debug-ts: end 1652998792763
2022-05-20 11:01:52.777 - debug: influxdb.0 (24528) Query to execute: from(bucket: "iob") \|> range(start: 2022-05-18T22:19:52.763Z, stop: 2022-05-19T22:19:52.763Z) \|> filter(fn: (r) => r["_measurement"] == "rain_mm_today") \|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") \|> group() \|> sort(columns:["_time"], desc: true) \|> limit(n: 1)
2022-05-20 11:01:52.790 - debug: influxdb.0 (24528) Send: 1 of: 1 in: 27ms
2022-05-20 11:01:52.790 - debug: influxdb.0 (24528) sendTo "getHistory" to system.adapter.javascript.0 from system.adapter.influxdb.0
2022-05-20 11:01:52.791 - info: javascript.0 (23828) script.js.common.debug-ts: [{'_start':'2022-05-18T22:19:52.763Z','_stop':'2022-05-19T22:19:52.763Z','_time':'2022-05-19T22:01:03.503Z','ack':true,'from':'system.adapter.wiffi-wz.0','q':0,'val':0,'ts':1652997663503}]
2022-05-20 11:01:52.792 - debug: influxdb.0 (24528) Incoming message getHistory from system.adapter.javascript.0
2022-05-20 11:01:52.791 - info: javascript.0 (23828) script.js.common.debug-ts: [{'_start':'2022-05-18T22:19:52.763Z','_stop':'2022-05-19T22:19:52.763Z','_time':'2022-05-19T22:01:03.503Z','ack':true,'from':'system.adapter.wiffi-wz.0','q':0,'val':0,'ts':1652997663503}]
2022-05-20 11:01:52.792 - info: javascript.0 (23828) script.js.common.debug-ts: maxRain 0
2022-05-20 11:01:52.792 - info: javascript.0 (23828) script.js.common.debug-ts: start 1652825992792
2022-05-20 11:01:52.792 - info: javascript.0 (23828) script.js.common.debug-ts: end 1652912392792
2022-05-20 11:01:52.794 - debug: influxdb.0 (24528) Query to execute:
from(bucket: "iob")
\|> range(start: 2022-05-17T22:19:52.792Z, stop: 2022-05-18T22:19:52.792Z)
\|> filter(fn: (r) => r["_measurement"] == "rain_mm_today" and contains(value: r._value, set: [true, false]))
\|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
\|> group()
 
2022-05-20 11:01:52.805 - debug: influxdb.0 (24528) Query to execute: from(bucket: "iob") \|> range(start: 2022-05-17T22:19:52.792Z, stop: 2022-05-18T22:19:52.792Z) \|> filter(fn: (r) => r["_measurement"] == "rain_mm_today") \|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") \|> group() \|> sort(columns:["_time"], desc: true) \|> limit(n: 1)
2022-05-20 11:01:52.817 - info: influxdb.0 (24528) No Data
2022-05-20 11:01:52.818 - info: javascript.0 (23828) script.js.common.debug-ts: []
2022-05-20 11:01:52.818 - info: javascript.0 (23828) script.js.common.debug-ts: start 1652739592818
2022-05-20 11:01:52.818 - info: javascript.0 (23828) script.js.common.debug-ts: end 1652825992818
2022-05-20 11:01:52.817 - debug: influxdb.0 (24528) sendTo "getHistory" to system.adapter.javascript.0 from system.adapter.influxdb.0
2022-05-20 11:01:52.820 - debug: influxdb.0 (24528) Incoming message getHistory from system.adapter.javascript.0
2022-05-20 11:01:52.821 - debug: influxdb.0 (24528) Query to execute:
from(bucket: "iob")
\|> range(start: 2022-05-16T22:19:52.818Z, stop: 2022-05-17T22:19:52.818Z)
\|> filter(fn: (r) => r["_measurement"] == "rain_mm_today" and contains(value: r._value, set: [true, false]))
\|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
\|> group()
 
2022-05-20 11:01:52.831 - debug: influxdb.0 (24528) Query to execute: from(bucket: "iob") \|> range(start: 2022-05-16T22:19:52.818Z, stop: 2022-05-17T22:19:52.818Z) \|> filter(fn: (r) => r["_measurement"] == "rain_mm_today") \|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") \|> group() \|> sort(columns:["_time"], desc: true) \|> limit(n: 1)
2022-05-20 11:01:52.843 - info: influxdb.0 (24528) No Data
2022-05-20 11:01:52.844 - info: javascript.0 (23828) script.js.common.debug-ts: []
2022-05-20 11:01:52.844 - info: javascript.0 (23828) script.js.common.debug-ts: rainSum 1.5
2022-05-20 11:01:52.844 - info: javascript.0 (23828) script.js.common.debug-ts: Started irrigation, because only 1.5 mm rainfall in the last 4 days
2022-05-20 11:01:52.844 - debug: influxdb.0 (24528) sendTo "getHistory" to system.adapter.javascript.0 from system.adapter.influxdb.0
Apollon77 commented 2 years ago

Plesse enable the debug on the relevant datapoint and generate debug log again. I need more log

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.