iobroker.influxdb 3.2.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +117 -110
- package/admin/i18n/de/translations.json +1 -1
- package/admin/i18n/en/translations.json +2 -2
- package/admin/i18n/pl/translations.json +1 -1
- package/admin/jsonConfig.json +0 -2
- package/admin/words.js +87 -87
- package/io-package.json +40 -37
- package/lib/DatabaseInfluxDB2x.js +20 -1
- package/lib/aggregate.js +56 -24
- package/main.js +84 -12
- package/package.json +12 -9
package/io-package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"pl": "Logowanie stanów do InfluxDB",
|
|
14
14
|
"zh-cn": "将状态记录到InfluxDB中"
|
|
15
15
|
},
|
|
16
|
-
"version": "
|
|
16
|
+
"version": "4.0.2",
|
|
17
17
|
"title": "Logging data with InfluxDB",
|
|
18
18
|
"titleLang": {
|
|
19
19
|
"en": "Logging data with InfluxDB",
|
|
@@ -28,6 +28,45 @@
|
|
|
28
28
|
"zh-cn": "使用InfluxDB记录数据"
|
|
29
29
|
},
|
|
30
30
|
"news": {
|
|
31
|
+
"4.0.2": {
|
|
32
|
+
"en": "Corrected JSON config\nCorrected filter function in booleanTypeCheckQuery\nAllowed the self-signed certificates using \"test connection\" button\nThe deletion of data from DB was implemented for V2\nAdded support for `count` aggregate type on getHistory\nminimal supported node.js version is 16 now",
|
|
33
|
+
"de": "JSON config korrigiert\nKorrigierte Filterfunktion in booleanTypeCheckQuery\nErlaubt die selbstsignierten Zertifikate mit \"Test-Verbindung\" Taste\nDie Löschung von Daten aus DB wurde für V2 implementiert\nUnterstützung für Grafit-Aggregat-Typ auf getHistory\nminimal unterstützt node.js version ist jetzt 16",
|
|
34
|
+
"ru": "Правильный конфиг JSON\nИсправлена функция фильтра в booleanTypeCheckQuery\nРазрешены самоподписанные сертификаты с помощью кнопки \"test connection\"\nУдаление данных от DB было реализовано для V2\nДобавлена поддержка подсчета агрегатного типа на getHistory\nминимальная поддерживаемая версия node.js 16 сейчас",
|
|
35
|
+
"pt": "Configuração JSON corrigida\nFunção de filtro corrigida em booleanTypeCheckQuery\nPermitiram os certificados auto-assinados usando o botão \"conexão de teste\"\nA exclusão de dados da DB foi implementada para V2\nAdicionado suporte para contar o tipo agregado em getHistory\nversão node.js suportada mínima é 16 agora",
|
|
36
|
+
"nl": "Quality over Quantity (QoQ) Releases Vertaling:\nVertaling:\nDe zelf toegewezen certificaten met \"teest verbinding\" knop\nDe deletie van de gegevens van DB werd geïnformeerd voor V2\nVermeldde steun voor het tel aggregate type\nminimaal ondersteunde node",
|
|
37
|
+
"fr": "Correction de la configuration JSON\nFonction de filtre corrigée dans booleanTypeCheckQuery\nAutorisé les certificats autosignés à l'aide du bouton \"test connection\"\nLa suppression des données du DB a été mise en œuvre pour V2\nAjout du support pour compter le type agrégé sur getHistory\nla version node.js supportée est 16 maintenant",
|
|
38
|
+
"it": "Corretto JSON config\nFunzione di filtro corretto in booleanTypeCheckQuery\nConsentito i certificati autofirmati utilizzando il pulsante \"Connessione di prova\"\nLa cancellazione dei dati da DB è stata implementata per V2\nAggiunto supporto per conteggio tipo aggregato su getHistory\nversione minima supportato node.js è 16 ora",
|
|
39
|
+
"es": "Corregido JSON config\nFunción de filtro corregida en booleanTypeCheckQuery\nPermitió los certificados auto-firmados usando el botón \"prueba de conexión\"\nLa eliminación de los datos del DB se llevó a cabo para V2\nSoporte añadido para el tipo de cuenta agregado en getHistory\nversión mínima soportado node.js es 16 ahora",
|
|
40
|
+
"pl": "Zgoda JSON\nFunkcja filtrów w booleanTypeCheckQuery\nUzyskał on certyfikaty za pomocą przycisku \"test connection\"\nDetekcja danych z DB została zaimplementowana dla V2\nWsparcie dla liczby zbitych typów\nminimalna wersja węzła jest obecnie 16",
|
|
41
|
+
"uk": "Виправлено налаштування JSON\nВиправлена функція фільтра в booleanTypeCheckQuery\nДозволені сертифікати самопризначені за допомогою кнопки \"test Connection\"\nВидалення даних з DB реалізовано для V2\nДодано підтримку підрахунку агрегатного типу на getHistory\nмінімальний підтриманий вузол.js версія 16 тепер",
|
|
42
|
+
"zh-cn": "惩教所\n善良Type CheckQuery的过滤功能\n允许使用“试验联系”的自发证书\n第五2行删除数据\n增加对准礼品总值的支持\n最低支持无误的版本现在是16个。"
|
|
43
|
+
},
|
|
44
|
+
"4.0.1": {
|
|
45
|
+
"en": "Corrected JSON config",
|
|
46
|
+
"de": "JSON config korrigiert",
|
|
47
|
+
"ru": "Правильный конфиг JSON",
|
|
48
|
+
"pt": "Configuração JSON corrigida",
|
|
49
|
+
"nl": "Quality over Quantity (QoQ) Releases Vertaling:",
|
|
50
|
+
"fr": "Correction de la configuration JSON",
|
|
51
|
+
"it": "Corretto JSON config",
|
|
52
|
+
"es": "Corregido JSON config",
|
|
53
|
+
"pl": "Zgoda JSON",
|
|
54
|
+
"uk": "Виправлено налаштування JSON",
|
|
55
|
+
"zh-cn": "惩教所"
|
|
56
|
+
},
|
|
57
|
+
"4.0.0": {
|
|
58
|
+
"en": "Allowed the self-signed certificates using \"test connection\" button\nThe deletion of data from DB was implemented for V2\nAdded support for `count` aggregate type on getHistory\nminimal supported node.js version is 16 now",
|
|
59
|
+
"de": "Erlaubt die selbstsignierten Zertifikate mit \"Test-Verbindung\" Taste\nDie Löschung von Daten aus DB wurde für V2 implementiert\nUnterstützung für Grafit-Aggregat-Typ auf getHistory\nminimal unterstützt node.js version ist jetzt 16",
|
|
60
|
+
"ru": "Разрешены самоподписанные сертификаты с помощью кнопки \"test connection\"\nУдаление данных от DB было реализовано для V2\nДобавлена поддержка подсчета агрегатного типа на getHistory\nминимальная поддерживаемая версия node.js 16 сейчас",
|
|
61
|
+
"pt": "Permitiram os certificados auto-assinados usando o botão \"conexão de teste\"\nA exclusão de dados da DB foi implementada para V2\nAdicionado suporte para contar o tipo agregado em getHistory\nversão node.js suportada mínima é 16 agora",
|
|
62
|
+
"nl": "De zelf toegewezen certificaten met \"teest verbinding\" knop\nDe deletie van de gegevens van DB werd geïnformeerd voor V2\nVermeldde steun voor het tel aggregate type\nminimaal ondersteunde node",
|
|
63
|
+
"fr": "Autorisé les certificats autosignés à l'aide du bouton \"test connection\"\nLa suppression des données du DB a été mise en œuvre pour V2\nAjout du support pour compter le type agrégé sur getHistory\nla version node.js supportée est 16 maintenant",
|
|
64
|
+
"it": "Consentito i certificati autofirmati utilizzando il pulsante \"Connessione di prova\"\nLa cancellazione dei dati da DB è stata implementata per V2\nAggiunto supporto per conteggio tipo aggregato su getHistory\nversione minima supportato node.js è 16 ora",
|
|
65
|
+
"es": "Permitió los certificados auto-firmados usando el botón \"prueba de conexión\"\nLa eliminación de los datos del DB se llevó a cabo para V2\nSoporte añadido para el tipo de cuenta agregado en getHistory\nversión mínima soportado node.js es 16 ahora",
|
|
66
|
+
"pl": "Uzyskał on certyfikaty za pomocą przycisku \"test connection\"\nDetekcja danych z DB została zaimplementowana dla V2\nWsparcie dla liczby zbitych typów\nminimalna wersja węzła jest obecnie 16",
|
|
67
|
+
"uk": "Дозволені сертифікати самопризначені за допомогою кнопки \"test Connection\"\nВидалення даних з DB реалізовано для V2\nДодано підтримку підрахунку агрегатного типу на getHistory\nмінімальний підтриманий вузол.js версія 16 тепер",
|
|
68
|
+
"zh-cn": "允许使用“试验联系”的自发证书\n第五2行删除数据\n增加对准礼品总值的支持\n最低支持无误的版本现在是16个。"
|
|
69
|
+
},
|
|
31
70
|
"3.2.0": {
|
|
32
71
|
"en": "Adjust cache file to be different per instance when having multiple instances",
|
|
33
72
|
"de": "Bestimmen Sie die Cache-Datei, um unterschiedlich zu sein pro Instanz, wenn mehrere Instanzen haben",
|
|
@@ -75,42 +114,6 @@
|
|
|
75
114
|
"es": "Cuando no se cuenta se proporciona para agregado ninguno o cambio entonces el límite (por defecto 2000) se utiliza como cuenta para definir el número de datos para regresar.",
|
|
76
115
|
"pl": "Jeśli nieliczanie jest dostarczane dla agregacji ani zmian, to limit (default 2000) jest używany jako określenie liczby danych do powrotu.",
|
|
77
116
|
"zh-cn": "当没有计算总额时,或当时的汇率(2000年)用来确定返回的数据数量。."
|
|
78
|
-
},
|
|
79
|
-
"3.1.5": {
|
|
80
|
-
"en": "Make sure debug log is active according to the settings",
|
|
81
|
-
"de": "Stellen Sie sicher, dass das Debug-Log gemäß den Einstellungen aktiv ist",
|
|
82
|
-
"ru": "Убедитесь, что журнал debug активен в соответствии с настройками",
|
|
83
|
-
"pt": "Certifique-se de que o log de depuração está ativo de acordo com as configurações",
|
|
84
|
-
"nl": "Zorg ervoor dat het logboek actief is volgens de instellingen",
|
|
85
|
-
"fr": "Assurez-vous que le journal debug est actif selon les paramètres",
|
|
86
|
-
"it": "Assicurarsi che il registro di debug sia attivo in base alle impostazioni",
|
|
87
|
-
"es": "Asegúrese de que el registro de depuración está activo según la configuración",
|
|
88
|
-
"pl": "Umożliwia to, że log debug jest aktywny zgodnie z ustawieniami",
|
|
89
|
-
"zh-cn": "B. 根据环境,确保有色色逻辑积极。"
|
|
90
|
-
},
|
|
91
|
-
"3.1.4": {
|
|
92
|
-
"en": "Performance optimizations for GetHistory calls, especially for \"minmax\" aggregate method\nPrevent crash case reported by Sentry",
|
|
93
|
-
"de": "Leistungsoptimierungen für GetHistory-Anrufe, insbesondere für minmax-Aggregatmethode\nVerhindern Crashfall berichtet von Sentry",
|
|
94
|
-
"ru": "Оптимизация производительности для звонков GetHistory, особенно для метода minmax агрегата\nПредотвратить случай аварии, сообщается в Sentry",
|
|
95
|
-
"pt": "Otimizações de desempenho para chamadas GetHistory, especialmente para método agregado minmax\nImpedir caso de acidente relatado por Sentry",
|
|
96
|
-
"nl": "Performance optimisatie voor GetHistory calls, vooral voor minmax aggregate methode\nVertaling:",
|
|
97
|
-
"fr": "Optimisations de performance pour les appels GetHistory, en particulier pour la méthode globale minmax\nPrévenir l ' accident signalé par Sentry",
|
|
98
|
-
"it": "Ottimizzazione delle prestazioni per le chiamate GetHistory, in particolare per il metodo aggregato minmax\nPrevenire caso crash segnalato da Sentry",
|
|
99
|
-
"es": "Optimizaciones de rendimiento para llamadas GetHistory, especialmente para minmax método agregado\nCaso de emergencia reportado por Sentry",
|
|
100
|
-
"pl": "Optymalizacja wydajności dla wezwań GetHistory, zwłaszcza dla metody Minmax\nPrzygotowania do wypadku Sentry",
|
|
101
|
-
"zh-cn": "GetHistory呼呼声的表现,特别是总括法\nSentry所报告的预防事故"
|
|
102
|
-
},
|
|
103
|
-
"3.1.3": {
|
|
104
|
-
"en": "Corrected issue when testing connection to InfluxDBv1 with weird passwords",
|
|
105
|
-
"de": "Problem beim Testen der Verbindung zu InfluxDBv1 mit seltsamen Passwörtern behoben",
|
|
106
|
-
"ru": "Исправлена ошибка при тестировании подключения к InfluxDBv1 со странными паролями.",
|
|
107
|
-
"pt": "Corrigido o problema ao testar a conexão com o InfluxDBv1 com senhas estranhas",
|
|
108
|
-
"nl": "Probleem opgelost bij het testen van de verbinding met InfluxDBv1 met rare wachtwoorden",
|
|
109
|
-
"fr": "Correction d'un problème lors du test de connexion à InfluxDBv1 avec des mots de passe étranges",
|
|
110
|
-
"it": "Risolto problema durante il test della connessione a InfluxDBv1 con password strane",
|
|
111
|
-
"es": "Problema corregido al probar la conexión a InfluxDBv1 con contraseñas extrañas",
|
|
112
|
-
"pl": "Naprawiono problem podczas testowania połączenia z InfluxDBv1 za pomocą dziwnych haseł",
|
|
113
|
-
"zh-cn": "更正了使用奇怪密码测试与 InfluxDBv1 的连接时出现的问题"
|
|
114
117
|
}
|
|
115
118
|
},
|
|
116
119
|
"mode": "daemon",
|
|
@@ -69,6 +69,25 @@ class DatabaseInfluxDB2x extends Database {
|
|
|
69
69
|
this.request.activatePool();
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
async deleteData(start, stop, org, bucket, predicate, callback_error) {
|
|
73
|
+
try {
|
|
74
|
+
await this.deleteApi.postDelete({
|
|
75
|
+
org,
|
|
76
|
+
bucket,
|
|
77
|
+
body: {
|
|
78
|
+
start: new Date(start).toISOString(),
|
|
79
|
+
stop: new Date(stop).toISOString(),
|
|
80
|
+
predicate: predicate,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
callback_error(null);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
this.log.error(error);
|
|
87
|
+
callback_error(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
async getDatabaseNames(callback) {
|
|
73
92
|
this.log.debug(`Organization being checked: ${this.organization}`);
|
|
74
93
|
|
|
@@ -101,7 +120,7 @@ class DatabaseInfluxDB2x extends Database {
|
|
|
101
120
|
try {
|
|
102
121
|
const bucketData = await this.bucketsApi.getBucketsID({ bucketID: this.bucketIds[dbname] });
|
|
103
122
|
this.log.debug(`Found retention policy: ${bucketData.retentionRules[0].everySeconds} seconds`);
|
|
104
|
-
callback({time: bucketData.retentionRules[0].everySeconds
|
|
123
|
+
callback({time: bucketData.retentionRules[0].everySeconds});
|
|
105
124
|
} catch (error) {
|
|
106
125
|
this.log.error(error);
|
|
107
126
|
callback(null);
|
package/lib/aggregate.js
CHANGED
|
@@ -10,7 +10,7 @@ function initAggregate(options) {
|
|
|
10
10
|
log = options.log || console.log;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
//step; // 1 Step is 1 second
|
|
13
|
+
// step; // 1 Step is 1 second
|
|
14
14
|
if (options.step === null) {
|
|
15
15
|
options.step = (options.end - options.start) / options.count;
|
|
16
16
|
}
|
|
@@ -54,7 +54,7 @@ function initAggregate(options) {
|
|
|
54
54
|
err.message += `: ${options.maxIndex + 2}`;
|
|
55
55
|
throw err;
|
|
56
56
|
}
|
|
57
|
-
// We define the array length
|
|
57
|
+
// We define the array length but do not prefill values, we do that on runtime when needed
|
|
58
58
|
options.result[0] = {
|
|
59
59
|
val: {ts: null, val: null},
|
|
60
60
|
max: {ts: null, val: null},
|
|
@@ -108,7 +108,7 @@ function aggregation(options, data) {
|
|
|
108
108
|
// store all border values
|
|
109
109
|
if (preIndex < 0) {
|
|
110
110
|
index = 0;
|
|
111
|
-
// if the ts is even earlier than the "pre
|
|
111
|
+
// if the ts is even earlier than the "pre-interval" ignore it, else we collect all data there
|
|
112
112
|
if (preIndex < -1) {
|
|
113
113
|
collectedTooEarlyData.push(data[i]);
|
|
114
114
|
continue;
|
|
@@ -116,7 +116,7 @@ function aggregation(options, data) {
|
|
|
116
116
|
preIndexValueFound = true;
|
|
117
117
|
} else if (preIndex > options.maxIndex) {
|
|
118
118
|
index = options.maxIndex + 2;
|
|
119
|
-
// if the ts is even later than the "post
|
|
119
|
+
// if the ts is even later than the "post-interval" ignore it, else we collect all data there
|
|
120
120
|
if (preIndex > options.maxIndex + 1) {
|
|
121
121
|
collectedTooLateData.push(data[i]);
|
|
122
122
|
continue;
|
|
@@ -127,16 +127,16 @@ function aggregation(options, data) {
|
|
|
127
127
|
}
|
|
128
128
|
options.overallLength++;
|
|
129
129
|
|
|
130
|
-
if (options.result[index] === undefined) { // lazy initialization of
|
|
130
|
+
if (options.result[index] === undefined) { // lazy initialization of data structure
|
|
131
131
|
options.result[index] = {
|
|
132
132
|
val: {ts: null, val: null},
|
|
133
133
|
max: {ts: null, val: null},
|
|
134
134
|
min: {ts: null, val: null},
|
|
135
135
|
start: {ts: null, val: null},
|
|
136
|
-
end: {ts: null, val: null}
|
|
136
|
+
end: {ts: null, val: null},
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
if (options.aggregate === 'average') {
|
|
139
|
+
if (options.aggregate === 'average' || options.aggregate === 'count') {
|
|
140
140
|
options.averageCount[index] = 0;
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -151,20 +151,20 @@ function aggregation(options, data) {
|
|
|
151
151
|
aggregationLogic(data[i], index, options);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// If no data was found in the pre
|
|
154
|
+
// If no data was found in the pre-interval, but we have earlier data, we put the latest of them in the pre-interval
|
|
155
155
|
if (!preIndexValueFound && collectedTooEarlyData.length > 0) {
|
|
156
156
|
collectedTooEarlyData = collectedTooEarlyData.sort(sortByTs);
|
|
157
157
|
options.overallLength++;
|
|
158
158
|
aggregationLogic(collectedTooEarlyData[collectedTooEarlyData.length - 1], 0, options);
|
|
159
159
|
}
|
|
160
|
-
// If no data was found in the post
|
|
160
|
+
// If no data was found in the post-interval, but we have later data, we put the earliest of them in the post-interval
|
|
161
161
|
if (!postIndexValueFound && collectedTooLateData.length > 0) {
|
|
162
162
|
collectedTooLateData = collectedTooLateData.sort(sortByTs);
|
|
163
163
|
options.overallLength++;
|
|
164
164
|
aggregationLogic(collectedTooLateData[0], options.maxIndex + 2, options);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
return {result: options.result, step: options.step, sourceLength: data.length}
|
|
167
|
+
return { result: options.result, step: options.step, sourceLength: data.length };
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function aggregationLogic(data, index, options) {
|
|
@@ -193,6 +193,8 @@ function aggregationLogic(data, index, options) {
|
|
|
193
193
|
} else if (options.aggregate === 'average') {
|
|
194
194
|
options.result[index].val.val += parseFloat(data.val);
|
|
195
195
|
options.averageCount[index]++;
|
|
196
|
+
} else if (options.aggregate === 'count') {
|
|
197
|
+
options.averageCount[index]++;
|
|
196
198
|
} else if (options.aggregate === 'total') {
|
|
197
199
|
options.result[index].val.val += parseFloat(data.val);
|
|
198
200
|
} else if (options.aggregate === 'minmax') {
|
|
@@ -260,7 +262,7 @@ function finishAggregation(options) {
|
|
|
260
262
|
} else if (ii === originalResultLength - 1) {
|
|
261
263
|
postBorderValueRemoved = true;
|
|
262
264
|
}
|
|
263
|
-
//options.result.splice(ii, 1);
|
|
265
|
+
// options.result.splice(ii, 1);
|
|
264
266
|
continue;
|
|
265
267
|
}
|
|
266
268
|
// just one value in this period: max == min == start == end
|
|
@@ -427,8 +429,33 @@ function finishAggregation(options) {
|
|
|
427
429
|
});
|
|
428
430
|
} else {
|
|
429
431
|
// no one value in this interval
|
|
430
|
-
//options.result.splice(k, 1);
|
|
431
|
-
//options.averageCount.splice(k, 1); // not needed to clean up because not used anymore afterwards
|
|
432
|
+
// options.result.splice(k, 1);
|
|
433
|
+
// options.averageCount.splice(k, 1); // not needed to clean up because not used anymore afterwards
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
options.result = finalResult;
|
|
437
|
+
} else if (options.aggregate === 'count') {
|
|
438
|
+
let startIndex = 0;
|
|
439
|
+
let endIndex = options.result.length;
|
|
440
|
+
const finalResult = [];
|
|
441
|
+
if (options.removeBorderValues) { // we cut out the additional results
|
|
442
|
+
// options.result.splice(0, 1);
|
|
443
|
+
// options.averageCount.splice(0, 1);
|
|
444
|
+
// options.result.length--;
|
|
445
|
+
// options.averageCount.length--;
|
|
446
|
+
startIndex++;
|
|
447
|
+
endIndex--;
|
|
448
|
+
}
|
|
449
|
+
for (let k = startIndex; k < endIndex; k++) {
|
|
450
|
+
if (options.result[k] !== undefined && options.result[k].val.ts) {
|
|
451
|
+
finalResult.push({
|
|
452
|
+
ts: options.result[k].val.ts,
|
|
453
|
+
val: options.averageCount[k],
|
|
454
|
+
});
|
|
455
|
+
} else {
|
|
456
|
+
// no one value in this interval
|
|
457
|
+
// options.result.splice(k, 1);
|
|
458
|
+
// options.averageCount.splice(k, 1); // not needed to clean up because not used anymore afterward
|
|
432
459
|
}
|
|
433
460
|
}
|
|
434
461
|
options.result = finalResult;
|
|
@@ -442,7 +469,7 @@ function finishAggregation(options) {
|
|
|
442
469
|
let indexStartTs = options.start + ((k - 1) * options.step);
|
|
443
470
|
let indexEndTs = indexStartTs + options.step;
|
|
444
471
|
if (options.integralDatapoints[k] && options.integralDatapoints[k].length) {
|
|
445
|
-
// Sort
|
|
472
|
+
// Sort data points by ts first
|
|
446
473
|
options.integralDatapoints[k].sort(sortByTs);
|
|
447
474
|
}
|
|
448
475
|
// Make sure that we have entries that always start at the beginning of the interval
|
|
@@ -562,10 +589,12 @@ function finishAggregation(options) {
|
|
|
562
589
|
let endIndex = options.result.length;
|
|
563
590
|
const finalResult = [];
|
|
564
591
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
565
|
-
/*
|
|
592
|
+
/*
|
|
593
|
+
options.result.splice(0, 1);
|
|
566
594
|
options.quantileDatapoints.splice(0, 1);
|
|
567
595
|
options.result.length--
|
|
568
|
-
options.quantileDatapoints.length
|
|
596
|
+
options.quantileDatapoints.length--;
|
|
597
|
+
*/
|
|
569
598
|
startIndex++;
|
|
570
599
|
endIndex--;
|
|
571
600
|
}
|
|
@@ -579,8 +608,8 @@ function finishAggregation(options) {
|
|
|
579
608
|
finalResult.push(point);
|
|
580
609
|
} else {
|
|
581
610
|
// no one value in this interval
|
|
582
|
-
//options.result.splice(k, 1);
|
|
583
|
-
//options.quantileDatapoints.splice(k, 1); // not needed to clean up because not used anymore
|
|
611
|
+
// options.result.splice(k, 1);
|
|
612
|
+
// options.quantileDatapoints.splice(k, 1); // not needed to clean up because not used anymore afterward
|
|
584
613
|
}
|
|
585
614
|
}
|
|
586
615
|
options.result = finalResult;
|
|
@@ -714,7 +743,7 @@ function beautify(options) {
|
|
|
714
743
|
if (postLastValue) {
|
|
715
744
|
// if steps
|
|
716
745
|
if (options.aggregate === 'onchange' || !options.aggregate) {
|
|
717
|
-
// if more data following, draw line to the end of chart
|
|
746
|
+
// if more data following, draw line to the end of the chart
|
|
718
747
|
if (postLastValue.ts !== lastTS) {
|
|
719
748
|
options.result.push({ts: options.end, val: postLastValue.val});
|
|
720
749
|
} else {
|
|
@@ -939,8 +968,12 @@ function quantile(qOrPs, list, fn) {
|
|
|
939
968
|
a = Number.isNaN(a) ? Number.NEGATIVE_INFINITY : a;
|
|
940
969
|
b = Number.isNaN(b) ? Number.NEGATIVE_INFINITY : b;
|
|
941
970
|
|
|
942
|
-
if (a > b)
|
|
943
|
-
|
|
971
|
+
if (a > b) {
|
|
972
|
+
return 1;
|
|
973
|
+
}
|
|
974
|
+
if (a < b) {
|
|
975
|
+
return -1;
|
|
976
|
+
}
|
|
944
977
|
|
|
945
978
|
return 0;
|
|
946
979
|
});
|
|
@@ -955,9 +988,7 @@ function quantile(qOrPs, list, fn) {
|
|
|
955
988
|
}
|
|
956
989
|
|
|
957
990
|
function sortByTs(a, b) {
|
|
958
|
-
|
|
959
|
-
const bTs = b.ts;
|
|
960
|
-
return (aTs < bTs) ? -1 : ((aTs > bTs) ? 1 : 0);
|
|
991
|
+
return a.ts - b.ts;
|
|
961
992
|
}
|
|
962
993
|
|
|
963
994
|
module.exports.sendResponseCounter = sendResponseCounter;
|
|
@@ -966,3 +997,4 @@ module.exports.initAggregate = initAggregate;
|
|
|
966
997
|
module.exports.aggregation = aggregation;
|
|
967
998
|
module.exports.beautify = beautify;
|
|
968
999
|
module.exports.finishAggregation = finishAggregation;
|
|
1000
|
+
module.exports.sortByTs = sortByTs;
|
package/main.js
CHANGED
|
@@ -479,7 +479,8 @@ function testConnection(adapter, msg) {
|
|
|
479
479
|
msg.message.config.token,
|
|
480
480
|
msg.message.config.organization,
|
|
481
481
|
msg.message.config.dbname || appName,
|
|
482
|
-
msg.message.config.requestTimeout
|
|
482
|
+
msg.message.config.requestTimeout,
|
|
483
|
+
msg.message.config.validateSSL
|
|
483
484
|
)
|
|
484
485
|
break;
|
|
485
486
|
default:
|
|
@@ -553,8 +554,7 @@ function processMessage(adapter, msg) {
|
|
|
553
554
|
if (adapter.config.dbversion === '1.x') {
|
|
554
555
|
adapter.sendTo(msg.from, msg.command, {supportedFeatures: ['update', 'delete', 'deleteRange', 'deleteAll', 'storeState']}, msg.callback);
|
|
555
556
|
} else {
|
|
556
|
-
|
|
557
|
-
adapter.sendTo(msg.from, msg.command, {supportedFeatures: ['storeState']}, msg.callback);
|
|
557
|
+
adapter.sendTo(msg.from, msg.command, {supportedFeatures: ['update', 'delete', 'deleteRange', 'deleteAll', 'storeState']}, msg.callback);
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
else if (msg.command === 'update') {
|
|
@@ -1459,6 +1459,36 @@ function _delete(adapter, id, state, cb) {
|
|
|
1459
1459
|
}
|
|
1460
1460
|
cb && cb();
|
|
1461
1461
|
});
|
|
1462
|
+
} else if (adapter.config.dbversion === '2.x') {
|
|
1463
|
+
let start;
|
|
1464
|
+
let stop;
|
|
1465
|
+
if (state.ts) {
|
|
1466
|
+
start = state.ts;
|
|
1467
|
+
stop = state.ts;
|
|
1468
|
+
} else if (state.start) { // deletes from "state.start" until ...
|
|
1469
|
+
start = state.start;
|
|
1470
|
+
if (state.end) {
|
|
1471
|
+
stop = state.end; // ... "state.end"
|
|
1472
|
+
} else {
|
|
1473
|
+
stop = new Date(); // ... now
|
|
1474
|
+
}
|
|
1475
|
+
} else if (state.end) { // deletes from 01.01.1970 until "state.end"
|
|
1476
|
+
start = new Date(0);
|
|
1477
|
+
stop = state.end;
|
|
1478
|
+
} else { // deletes from 01.01.1970 until now
|
|
1479
|
+
start = new Date(0);
|
|
1480
|
+
stop = new Date();
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
adapter._client.deleteData(start, stop, adapter.config.organization, adapter.config.dbname, `_measurement="${id}"`, err => {
|
|
1484
|
+
if (err) {
|
|
1485
|
+
adapter.log.warn(`Error on delete("${err} / ${JSON.stringify(err.message)}"`);
|
|
1486
|
+
cb && cb(err);
|
|
1487
|
+
} else {
|
|
1488
|
+
setConnected(adapter, true);
|
|
1489
|
+
}
|
|
1490
|
+
cb && cb();
|
|
1491
|
+
});
|
|
1462
1492
|
} else {
|
|
1463
1493
|
cb && cb('not implemented');
|
|
1464
1494
|
}
|
|
@@ -1651,6 +1681,51 @@ function update(adapter, id, state, cb) {
|
|
|
1651
1681
|
}
|
|
1652
1682
|
}
|
|
1653
1683
|
});
|
|
1684
|
+
} else if (adapter.config.dbversion === '2.x') {
|
|
1685
|
+
let fluxQuery = `from(bucket: "${adapter.config.dbname}") `;
|
|
1686
|
+
//using identical start/stops values leads to a 'empty range' error, therefore we add a microsecond
|
|
1687
|
+
fluxQuery += ` |> range(start:time(v:${state.ts*1000000}), stop:time(v:${state.ts * 1000000 + 1000}))`;
|
|
1688
|
+
fluxQuery += ` |> filter(fn: (r) => r["_measurement"] == "${id}")`;
|
|
1689
|
+
fluxQuery += ` ${(!adapter.config.usetags) ? '|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")' : ''}`;
|
|
1690
|
+
|
|
1691
|
+
adapter._client.query(fluxQuery, (err, result) => {
|
|
1692
|
+
if (err) {
|
|
1693
|
+
adapter.log.warn(`Error on update("${query}): ${err} / ${JSON.stringify(err.message)}"`);
|
|
1694
|
+
cb && cb(err);
|
|
1695
|
+
} else {
|
|
1696
|
+
setConnected(adapter, true);
|
|
1697
|
+
if (result && result.length) {
|
|
1698
|
+
const stored = result[0];
|
|
1699
|
+
if (state.val !== undefined) {
|
|
1700
|
+
stored.val = state.val;
|
|
1701
|
+
}
|
|
1702
|
+
if (state.ack !== undefined) {
|
|
1703
|
+
stored.ack = state.ack;
|
|
1704
|
+
}
|
|
1705
|
+
if (state.q !== undefined) {
|
|
1706
|
+
stored.q = state.q;
|
|
1707
|
+
}
|
|
1708
|
+
if (state.from) {
|
|
1709
|
+
stored.from = state.from;
|
|
1710
|
+
}
|
|
1711
|
+
stored.ts = state.ts;
|
|
1712
|
+
delete stored.time;
|
|
1713
|
+
|
|
1714
|
+
_delete(adapter, id, {ts: stored.ts}, error => {
|
|
1715
|
+
if (error) {
|
|
1716
|
+
adapter.log.error(`Cannot delete value for ${id}: ${JSON.stringify(state)}`);
|
|
1717
|
+
cb && cb(err);
|
|
1718
|
+
} else {
|
|
1719
|
+
pushValueIntoDB(adapter, id, stored, true, cb);
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
} else {
|
|
1723
|
+
adapter.log.error(`Cannot find value to delete for ${id}: ${JSON.stringify(state)}`);
|
|
1724
|
+
cb && cb('not found');
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
|
|
1654
1729
|
} else {
|
|
1655
1730
|
cb && cb('not implemented');
|
|
1656
1731
|
}
|
|
@@ -2092,7 +2167,7 @@ function getHistory(adapter, msg) {
|
|
|
2092
2167
|
|
|
2093
2168
|
if (resultsFromInfluxDB) {
|
|
2094
2169
|
query += ` LIMIT ${options.limit}`;
|
|
2095
|
-
} else if (options.aggregate !== 'minmax' &&
|
|
2170
|
+
} else if (options.aggregate !== 'minmax' && options.aggregate !== 'integral') {
|
|
2096
2171
|
query += ` LIMIT ${options.count}`;
|
|
2097
2172
|
}
|
|
2098
2173
|
|
|
@@ -2295,6 +2370,7 @@ function getHistoryIflx2(adapter, msg) {
|
|
|
2295
2370
|
const booleanTypeCheckQuery = `
|
|
2296
2371
|
from(bucket: "${adapter.config.dbname}")
|
|
2297
2372
|
|> range(${(options.start) ? `start: ${new Date(options.start).toISOString()}, ` : `start: ${new Date(options.end - (adapter.config.retention || 31536000) * 1000).toISOString()}, `}stop: ${new Date(options.end).toISOString()})
|
|
2373
|
+
|> filter(fn: (r) => r["_field"] == "value")
|
|
2298
2374
|
|> filter(fn: (r) => r["_measurement"] == "${options.id}" and contains(value: r._value, set: [true, false]))
|
|
2299
2375
|
${adapter.config.usetags ? ' |> duplicate(column: "_value", as: "value")' : ' |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")'}
|
|
2300
2376
|
|> group()
|
|
@@ -2427,10 +2503,8 @@ function getHistoryIflx2(adapter, msg) {
|
|
|
2427
2503
|
addFluxQuery = `from(bucket: "${adapter.config.dbname}")
|
|
2428
2504
|
|> range(start: ${new Date(options.start - (adapter.config.retention || 31536000) * 1000).toISOString()}, stop: ${new Date(options.start - 1).toISOString()})
|
|
2429
2505
|
|> filter(fn: (r) => r["_measurement"] == "${options.id}")
|
|
2430
|
-
|
|
2431
|
-
|>
|
|
2432
|
-
|> sort(columns: ["_time"], desc: true)
|
|
2433
|
-
|> limit(n: 1)`;
|
|
2506
|
+
|> last()
|
|
2507
|
+
${(!adapter.config.usetags) ? '|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")' : ''}`;
|
|
2434
2508
|
|
|
2435
2509
|
fluxQueries.unshift(addFluxQuery);
|
|
2436
2510
|
}
|
|
@@ -2438,10 +2512,8 @@ function getHistoryIflx2(adapter, msg) {
|
|
|
2438
2512
|
addFluxQuery = `from(bucket: "${adapter.config.dbname}")
|
|
2439
2513
|
|> range(start: ${new Date(options.end + 1).toISOString()})
|
|
2440
2514
|
|> filter(fn: (r) => r["_measurement"] == "${options.id}")
|
|
2441
|
-
|
|
2442
|
-
|>
|
|
2443
|
-
|> sort(columns: ["_time"], desc: false)
|
|
2444
|
-
|> limit(n: 1)`;
|
|
2515
|
+
|> first()
|
|
2516
|
+
${(!adapter.config.usetags) ? '|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")' : ''}`;
|
|
2445
2517
|
fluxQueries.push(addFluxQuery);
|
|
2446
2518
|
}
|
|
2447
2519
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.influxdb",
|
|
3
3
|
"description": "Log states in InfluxDB",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"author": "bluefox <dogafox@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"bluefox <dogafox@gmail.com>",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/ioBroker/ioBroker.influxdb"
|
|
15
15
|
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
16
19
|
"keywords": [
|
|
17
20
|
"ioBroker",
|
|
18
21
|
"log data",
|
|
@@ -20,18 +23,18 @@
|
|
|
20
23
|
],
|
|
21
24
|
"optionalDependencies": {},
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@influxdata/influxdb-client": "^1.
|
|
24
|
-
"@influxdata/influxdb-client-apis": "^1.
|
|
25
|
-
"@iobroker/adapter-core": "^
|
|
26
|
+
"@influxdata/influxdb-client": "^1.33.2",
|
|
27
|
+
"@influxdata/influxdb-client-apis": "^1.33.2",
|
|
28
|
+
"@iobroker/adapter-core": "^3.0.4",
|
|
26
29
|
"influx": "^4.2.3"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@alcalzone/release-script": "^3.
|
|
30
|
-
"@alcalzone/release-script-plugin-iobroker": "^3.
|
|
32
|
+
"@alcalzone/release-script": "^3.6.0",
|
|
33
|
+
"@alcalzone/release-script-plugin-iobroker": "^3.6.0",
|
|
31
34
|
"@alcalzone/release-script-plugin-license": "^3.5.9",
|
|
32
|
-
"@iobroker/adapter-dev": "^1.
|
|
33
|
-
"mocha": "^10.
|
|
34
|
-
"chai": "^4.3.
|
|
35
|
+
"@iobroker/adapter-dev": "^1.2.0",
|
|
36
|
+
"mocha": "^10.2.0",
|
|
37
|
+
"chai": "^4.3.10"
|
|
35
38
|
},
|
|
36
39
|
"bugs": {
|
|
37
40
|
"url": "https://github.com/ioBroker/ioBroker.influxdb/issues"
|