iobroker.ebus 3.1.0 → 3.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2022 rg-engineering <info@rg-engineering.eu>
3
+ Copyright (c) 2017-2023 rg-engineering info@rg-engineering.eu
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -55,7 +55,16 @@ Attention: command in datapoint ebus.0.cmd is deleted after executing of command
55
55
 
56
56
  ## Changelog
57
57
 
58
- ### 3.1.0 (in progress)
58
+ ### 3.2.0 (2023-02-11)
59
+ * (René) **Attention** polled variables must be set as active in admin now
60
+ * (René) search available variables per circuit added in admin
61
+ * (René) DP "find" added to force read of all existing datapoints (Attention: might take a while) and update name in data point tree
62
+
63
+ ### 3.1.1 (2023-01-31)
64
+ * (René) support ebusd 23.1
65
+ * (René) see issue #77: make sure that only one data request is running at the same time
66
+
67
+ ### 3.1.0 (2022-12-01)
59
68
  * (René) support ebusd 22.4
60
69
  * (René) see issue #77: Update data point when read-cmd is used
61
70
  * (René) see issue #78: remove CR, LF in answer from ebusd for DP ebus.0.cmdResult
@@ -203,15 +212,27 @@ Attention: command in datapoint ebus.0.cmd is deleted after executing of command
203
212
  * (René) initial release
204
213
 
205
214
  ## License
206
- Copyright (C) <2017 - 2022> <info@rg-engineering.eu>
207
-
208
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
209
-
210
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
211
-
212
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
213
-
214
-
215
+ MIT License
216
+
217
+ Copyright (c) 2017-2023 rg-engineering info@rg-engineering.eu
218
+
219
+ Permission is hereby granted, free of charge, to any person obtaining a copy
220
+ of this software and associated documentation files (the "Software"), to deal
221
+ in the Software without restriction, including without limitation the rights
222
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
223
+ copies of the Software, and to permit persons to whom the Software is
224
+ furnished to do so, subject to the following conditions:
225
+
226
+ The above copyright notice and this permission notice shall be included in all
227
+ copies or substantial portions of the Software.
228
+
229
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
230
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
231
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
232
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
233
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
234
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
235
+ SOFTWARE.
215
236
 
216
237
 
217
238
 
@@ -56,6 +56,54 @@
56
56
  <!-- you have to define 2 functions in the global scope: -->
57
57
  <script type="text/javascript">
58
58
 
59
+
60
+ //var timeout2;
61
+ function findParams(circuit, onChange, instance) {
62
+ //timeout2 = setTimeout(function () {
63
+ // getUUID(onChange, instance);
64
+ //}, 4000);
65
+
66
+ //function sendTo(_adapter_instance, command, message, callback)
67
+
68
+ console.log("findParams called with " + circuit);
69
+
70
+ sendTo(instance, 'findParams', circuit, function (list) {
71
+ //if (timeout2) {
72
+ // clearTimeout(timeout2);
73
+ // timeout2 = null;
74
+ //}
75
+
76
+ console.log('got params ' + JSON.stringify(list));
77
+
78
+ let polledVars = table2values('polledDP');
79
+
80
+ //console.log('current list ' + JSON.stringify(polledVars));
81
+
82
+ for (let i = 0; i < list.length; i++) {
83
+
84
+ //console.log('add ' + JSON.stringify(list[i]));
85
+
86
+ let entry = {
87
+ active: list[i].active,
88
+ circuit: list[i].circuit,
89
+ name: list[i].name,
90
+ parameter: ""
91
+ }
92
+ polledVars.push(entry);
93
+ }
94
+
95
+ //console.log('new list ' + JSON.stringify(polledVars));
96
+
97
+ values2table('polledDP', polledVars, OnChange, tablePolledDPOnReady);
98
+
99
+ showHideSettings();
100
+ onChange(true);
101
+ M.updateTextFields();
102
+
103
+ });
104
+ }
105
+
106
+
59
107
  // the function loadSettings has to exist ...
60
108
  function load(settings, onChange) {
61
109
 
@@ -86,6 +134,13 @@
86
134
  FillTablePolledDP(settings);
87
135
  FillTableHistoryDP(settings);
88
136
 
137
+ var _id = 'ebus.' + instance;
138
+
139
+ $("#findParams").click(function () {
140
+ let circuit= $("#Circuit4Find").val();
141
+ findParams(circuit, onChange, _id);
142
+ });
143
+
89
144
  }
90
145
 
91
146
  function FillTablePolledDP(settings) {
@@ -288,61 +343,76 @@
288
343
 
289
344
  </div>
290
345
 
291
- <!-- tab "tab-polledDP" -->
292
- <div id="tab-polledDP" class="col s12 page">
346
+ <!-- tab "tab-polledDP" -->
347
+ <div id="tab-polledDP" class="col s12 page">
293
348
 
294
- <div class="row">
295
- <div class="col s6">
296
- <span class="translate">hint_ebusd_polled</span>
297
- </div>
349
+ <div class="row">
350
+ <div class="col s6">
351
+ <span class="translate">hint_ebusd_polled</span>
298
352
  </div>
353
+ </div>
299
354
 
300
- <div class="col s12" id="polledDP">
301
-
302
- <a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a>
355
+ <div class="col s12" id="polledDP">
303
356
 
304
- <div class="table-values-div">
305
- <table id="table_polledDP" class="table-values" style="width: 100%;">
306
- <thead>
307
- <tr>
308
- <th id="polledDP_col_1" data-name="circuit" style="width: 20%; background: #64b5f6 " class="translate">circuit</th>
309
- <th id="polledDP_col_2" data-name="name" style="background: #64b5f6" class="translate">name</th>
310
- <th id="polledDP_col_3" data-name="parameter" style="background: #64b5f6" class="translate">addParameter</th>
311
- <th data-buttons="up down delete" style="width: 100px; background: #64b5f6"></th>
312
- </tr>
313
- </thead>
314
- </table>
357
+ <div class="row">
358
+ <div class="input-field col s2 m2 l2">
359
+ <button class="btn-floating btn-small waves-effect waves-light" title="findParams" id="findParams">
360
+ <i class="material-icons">search</i>
361
+ </button>
362
+ </div>
363
+ <div class="input-field col s4 m4 l4">
364
+ <input class="value" id="Circuit4Find" type="text" />
365
+ <label for="maxretries" class="translate">Circuit4Find</label>
315
366
  </div>
316
367
  </div>
368
+ <div class="row">
369
+ <a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a>
370
+ </div>
371
+ <div class="table-values-div">
372
+ <table id="table_polledDP" class="table-values" style="width: 100%;">
373
+ <thead>
374
+ <tr>
375
+ <th id="polledDP_col_0" data-type="checkbox" data-name="active" style=" background: #64b5f6 " class="translate">active</th>
376
+ <th id="polledDP_col_1" data-type="text" data-name="circuit" style="width: 20%; background: #64b5f6 " class="translate">circuit</th>
377
+ <th id="polledDP_col_2" data-type="text" data-name="name" style="background: #64b5f6" class="translate">name</th>
378
+ <th id="polledDP_col_3" data-type="text" data-name="parameter" style="background: #64b5f6" class="translate">addParameter</th>
379
+ <th data-buttons="up down delete" style="width: 100px; background: #64b5f6"></th>
380
+ </tr>
381
+ </thead>
382
+ </table>
383
+ </div>
317
384
  </div>
385
+ </div>
318
386
 
319
- <!-- tab "tab-historyDP" -->
320
- <div id="tab-historyDP" class="col s12 page">
387
+
321
388
 
322
- <div class="row">
323
- <div class="col s6">
324
- <span class="translate">hint_ebusd_history</span>
325
- </div>
389
+ <!-- tab "tab-historyDP" -->
390
+ <div id="tab-historyDP" class="col s12 page">
391
+
392
+ <div class="row">
393
+ <div class="col s6">
394
+ <span class="translate">hint_ebusd_history</span>
326
395
  </div>
396
+ </div>
327
397
 
328
- <div class="col s12" id="historyDP">
398
+ <div class="col s12" id="historyDP">
329
399
 
330
- <a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a>
400
+ <a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a>
331
401
 
332
- <div class="table-values-div">
333
- <table id="table_historyDP" class="table-values" style="width: 100%;">
334
- <thead>
335
- <tr>
336
- <th id="historyDP_col_1" data-name="name" style="width: 20%; background: #64b5f6 " class="translate">name</th>
337
- <th data-buttons="add up down delete" style="width: 100px; background: #64b5f6"></th>
338
- </tr>
339
- </thead>
340
- </table>
341
- </div>
402
+ <div class="table-values-div">
403
+ <table id="table_historyDP" class="table-values" style="width: 100%;">
404
+ <thead>
405
+ <tr>
406
+ <th id="historyDP_col_1" data-name="name" style="width: 20%; background: #64b5f6 " class="translate">name</th>
407
+ <th data-buttons="add up down delete" style="width: 100px; background: #64b5f6"></th>
408
+ </tr>
409
+ </thead>
410
+ </table>
342
411
  </div>
343
412
  </div>
344
-
345
413
  </div>
414
+
415
+ </div>
346
416
  </div>
347
417
  </body>
348
418
  </html>
package/admin/words.js CHANGED
@@ -24,4 +24,6 @@ systemDictionary = {
24
24
  "target_IP": { "en": "target IP", "de": "Ziel-IP", "ru": "целевой IP-адрес", "pt": "IP alvo", "nl": "doel-IP", "fr": "cible IP", "it": "IP di destinazione", "es": "IP objetivo", "pl": "docelowy adres IP", "uk": "цільовий IP", "zh-cn": "目标IP"},
25
25
  "target_TelnetPort": { "en": "target telnet Port to write data", "de": "target telnet Port zum Schreiben von Daten", "ru": "целевой порт telnet для записи данных", "pt": "destino telnet porta para escrever dados", "nl": "doel telnet-poort om gegevens te schrijven", "fr": "Port telnet cible pour écrire des données", "it": "Porta telnet target per scrivere dati", "es": "target telnet Port para escribir datos", "pl": "docelowy port telnet do zapisu danych", "uk": "target telnet Порт для запису даних", "zh-cn": "目标telnet用于写入数据的端口"},
26
26
  "useBoolean4Onoff": { "en": "use boolean instead string for datapoints with on/off values ", "de": "Verwenden Sie Boolean anstelle von Strings für Datenpunkte mit Ein-/Aus-Werten", "ru": "используйте логическое значение вместо строки для точек данных со значениями включения / выключения", "pt": "use booleano em vez de string para pontos de dados com valores on / off", "nl": "gebruik in plaats daarvan booleaanse string voor datapunten met aan/uit-waarden", "fr": "utiliser une chaîne booléenne à la place pour les points de données avec des valeurs activées/désactivées", "it": "usa la stringa booleana invece per i punti dati con valori on/off", "es": "use booleano en lugar de cadena para puntos de datos con valores de encendido / apagado", "pl": "użyj wartości logicznej zamiast ciągu dla punktów danych z wartościami włączonymi / wyłączonymi", "uk": "використовуйте логічне значення замість рядка для точок даних зі значеннями on/off", "zh-cn": "对具有开/关值的数据点使用布尔值代替字符串"},
27
+ "Circuit4Find": { "en": "Circuit in which parameters are searched ", "de": "Schaltung, in der nach Parametern gesucht wird", "ru": "Цепь, в которой ищутся параметры", "pt": "Circuito no qual se pesquisam parâmetros", "nl": "Circuit waarin parameters worden gezocht", "fr": "Circuit dans lequel les paramètres sont recherchés", "it": "Circuito in cui vengono cercati i parametri", "es": "Circuito en el que se buscan parámetros", "pl": "Obwód, w którym szukane są parametry", "uk": "Схема, в якій здійснюється пошук параметрів", "zh-cn": "搜索参数的电路"},
28
+ "active": { "en": "active", "de": "aktiv", "ru": "активный", "pt": "ativo", "nl": "actief", "fr": "actif", "it": "attivo", "es": "activo", "pl": "aktywny", "uk": "активний", "zh-cn": "积极的"},
27
29
  };
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "ebus",
4
- "version": "3.1.0",
4
+ "version": "3.2.0",
5
5
  "news": {
6
+ "3.2.0": {
7
+ "en": "Attention: polled variables must be set to active \n\r search for available variables added",
8
+ "de": "Achtung: Gepollte Variablen müssen auf aktiv gesetzt werden\n\r Suche nach verfügbaren Variablen hinzugefügt",
9
+ "ru": "Внимание: опрашиваемые переменные должны быть активны\n\r добавлен поиск доступных переменных",
10
+ "pt": "Atenção: as variáveis ​​pesquisadas devem ser definidas como ativas\n\r busca por variáveis ​​disponíveis adicionadas",
11
+ "nl": "Let op: polled variabelen moeten op actief staan\n\r zoeken naar beschikbare variabelen toegevoegd",
12
+ "fr": "Attention : les variables interrogées doivent être définies sur actives\n\r rechercher les variables disponibles ajoutées",
13
+ "it": "Attenzione: le variabili interrogate devono essere impostate come attive\n\r cerca le variabili disponibili aggiunte",
14
+ "es": "Atención: las variables encuestadas deben configurarse como activas\n\r búsqueda de variables disponibles añadidas",
15
+ "pl": "Uwaga: zmienne odpytywane muszą być ustawione jako aktywne\n\r dodano wyszukiwanie dostępnych zmiennych",
16
+ "uk": "Увага: опитувані змінні мають бути активними\n\r додано пошук доступних змінних",
17
+ "zh-cn": "注意:轮询的变量必须设置为活动的\n\r 搜索添加的可用变量"
18
+ },
19
+ "3.1.1": {
20
+ "en": "wait for all commands before update of data",
21
+ "de": "Warten Sie auf alle Befehle, bevor Sie die Daten aktualisieren",
22
+ "ru": "дождаться всех команд перед обновлением данных",
23
+ "pt": "aguarde todos os comandos antes da atualização dos dados",
24
+ "nl": "wacht op alle commando's voordat de gegevens worden bijgewerkt",
25
+ "fr": "attendre toutes les commandes avant la mise à jour des données",
26
+ "it": "attendere tutti i comandi prima dell'aggiornamento dei dati",
27
+ "es": "esperar todos los comandos antes de actualizar los datos",
28
+ "pl": "poczekaj na wszystkie polecenia przed aktualizacją danych",
29
+ "uk": "дочекатися всіх команд перед оновленням даних",
30
+ "zh-cn": "在更新数据之前等待所有命令"
31
+ },
6
32
  "3.1.0": {
7
33
  "en": "optimize answer of ebus.0.cmd",
8
34
  "de": "Antwort von ebus.0.cmd optimieren",
@@ -15,97 +41,6 @@
15
41
  "pl": "zoptymalizować odpowiedź ebus.0.cmd",
16
42
  "uk": "оптимізувати відповідь ebus.0.cmd",
17
43
  "zh-cn": "优化 ebus.0.cmd 的答案"
18
- },
19
- "3.0.7": {
20
- "en": "support of ebusd 22.3",
21
- "de": "Unterstützung von ebusd 22.3",
22
- "ru": "поддержка ebusd 22.3",
23
- "pt": "suporte de ebusd 22.3",
24
- "nl": "ondersteuning van ebusd 22.3",
25
- "fr": "prise en charge d'ebusd 22.3",
26
- "it": "supporto di ebusd 22.3",
27
- "es": "soporte de ebusd 22.3",
28
- "pl": "obsługa ebusd 22.3",
29
- "zh-cn": "支持 ebusd 22.3",
30
- "uk": "підтримка ebusd 22.3"
31
- },
32
- "3.0.6": {
33
- "en": "widget with tooltip",
34
- "de": "Widget mit Tooltip",
35
- "ru": "виджет с подсказкой",
36
- "pt": "widget com dica de ferramenta",
37
- "nl": "widget met knopinfo",
38
- "fr": "widget avec info-bulle",
39
- "it": "widget con descrizione comando",
40
- "es": "widget con información sobre herramientas",
41
- "pl": "widżet z podpowiedź",
42
- "zh-cn": "带有工具提示的小部件",
43
- "uk": "віджет із підказкою"
44
- },
45
- "3.0.2": {
46
- "en": "message installation hint added",
47
- "de": "Nachricht Installationshinweis hinzugefügt",
48
- "ru": "добавлена ​​подсказка установки сообщения",
49
- "pt": "dica de instalação de mensagem adicionada",
50
- "nl": "bericht installatie hint toegevoegd",
51
- "fr": "astuce d'installation de message ajoutée",
52
- "it": "suggerimento per l'installazione del messaggio aggiunto",
53
- "es": "sugerencia de instalación de mensajes agregada",
54
- "pl": "dodano wskazówkę dotyczącą instalacji wiadomości",
55
- "zh-cn": "添加了消息安装提示",
56
- "uk": "додано підказку щодо встановлення повідомлення"
57
- },
58
- "3.0.1": {
59
- "en": "read interval in admin added",
60
- "de": "Leseintervall im Admin hinzugefügt",
61
- "ru": "добавлен интервал чтения в админке",
62
- "pt": "intervalo de leitura no admin adicionado",
63
- "nl": "leesinterval in admin toegevoegd",
64
- "fr": "intervalle de lecture ajouté dans l'administrateur",
65
- "it": "intervallo di lettura in admin aggiunto",
66
- "es": "Intervalo de lectura en el administrador agregado",
67
- "pl": "dodano interwał odczytu w admin",
68
- "zh-cn": "添加了管理员中的读取间隔",
69
- "uk": "додано інтервал читання в адмінці"
70
- },
71
- "3.0.0": {
72
- "en": "from 'scheduled' to 'daemon' adapter changed",
73
- "de": "von 'geplant' zu 'daemon' Adapter geändert",
74
- "ru": "изменен адаптер с «запланированного» на «демон»",
75
- "pt": "adaptador 'agendado' para 'daemon' alterado",
76
- "nl": "van 'scheduled' naar 'daemon' adapter gewijzigd",
77
- "fr": "de l'adaptateur 'scheduled' à 'daemon' changé",
78
- "it": "adattatore da \"programmato\" a \"demone\" modificato",
79
- "es": "Se cambió el adaptador de 'programado' a 'daemon'",
80
- "pl": "Zmieniono adapter z „zaplanowanego” na „demon”",
81
- "zh-cn": "从 'scheduled' 到 'daemon' 适配器已更改",
82
- "uk": "змінено адаптер із 'scheduled' на 'daemon'"
83
- },
84
- "2.6.0": {
85
- "en": " 'bent' replaced by 'axios'",
86
- "de": "'bent' ersetzt durch 'axios'",
87
- "ru": "«согнутый» заменен на «аксиос»",
88
- "pt": "'curvado' substituído por 'axios'",
89
- "nl": "'gebogen' vervangen door 'axios'",
90
- "fr": "'plié' remplacé par 'axios'",
91
- "it": "'piegato' sostituito da 'assios'",
92
- "es": "'doblado' reemplazado por 'axios'",
93
- "pl": "„wygięty” zastąpiony przez „axios”",
94
- "zh-cn": "'bent' 替换为 'axios'",
95
- "uk": "\"bent\" замінено на \"axios\""
96
- },
97
- "2.5.1": {
98
- "en": "maximum retries to send data in case of arbitration error",
99
- "de": "maximale Wiederholungsversuche zum Senden von Daten im Falle eines Vermittlungsfehlers",
100
- "ru": "максимальное количество попыток отправки данных в случае ошибки арбитража",
101
- "pt": "máximo de tentativas para enviar dados em caso de erro de arbitragem",
102
- "nl": "maximaal aantal pogingen om gegevens te verzenden in geval van arbitragefout",
103
- "fr": "nombre maximum de tentatives d'envoi de données en cas d'erreur d'arbitrage",
104
- "it": "numero massimo di tentativi di invio dei dati in caso di errore di arbitrato",
105
- "es": "reintentos máximos para enviar datos en caso de error de arbitraje",
106
- "pl": "maksymalna liczba prób wysłania danych w przypadku błędu arbitrażu",
107
- "zh-cn": "仲裁错误时发送数据的最大重试次数",
108
- "uk": "максимальна кількість повторних спроб надсилання даних у разі помилки арбітражу"
109
44
  }
110
45
  },
111
46
  "titleLang": {
@@ -138,7 +73,7 @@
138
73
  "mode": "daemon",
139
74
  "icon": "ebus.png",
140
75
  "enabled": true,
141
- "messagebox": false,
76
+ "messagebox": true,
142
77
  "extIcon": "https://raw.githubusercontent.com/rg-engineering/ioBroker.ebus/master/admin/ebus.png",
143
78
  "keywords": [
144
79
  "ebus"
package/main.js CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
 
17
17
  const utils = require("@iobroker/adapter-core");
18
- const ebusdMinVersion = [22, 4];
18
+ const ebusdMinVersion = [23, 1];
19
19
  let ebusdVersion = [0, 0];
20
20
  let ebusdUpdateVersion = [0, 0];
21
21
 
@@ -39,6 +39,13 @@ function startAdapter(options) {
39
39
  // is called when adapter shuts down
40
40
  unload: function (callback) {
41
41
  try {
42
+
43
+ if (intervalID != null) {
44
+ clearInterval(intervalID);
45
+ }
46
+ if (updateTimerID != null) {
47
+ clearTimeout(updateTimerID);
48
+ }
42
49
  adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
43
50
  //to do stop intervall
44
51
  callback();
@@ -46,12 +53,29 @@ function startAdapter(options) {
46
53
  callback();
47
54
  }
48
55
  },
49
-
56
+
50
57
  stateChange: async (id, state) => {
51
58
  await HandleStateChange(id, state);
52
59
  },
53
60
  //#######################################
54
61
  //
62
+ message: async (obj) => {
63
+ if (obj) {
64
+ switch (obj.command) {
65
+ case "findParams":
66
+ // e.g. send email or pushover or whatever
67
+ adapter.log.debug("findParams command");
68
+ // Send response in callback if required
69
+ await FindParams(obj);
70
+ break;
71
+ default:
72
+ adapter.log.error("unknown message " + obj.command);
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ //#######################################
78
+ //
55
79
  });
56
80
  adapter = new utils.Adapter(options);
57
81
 
@@ -63,7 +87,8 @@ const axios = require('axios');
63
87
  const net = require("net");
64
88
  const { PromiseSocket } = require("promise-socket");
65
89
 
66
- let intervalID;
90
+ let intervalID=null;
91
+ let updateTimerID=null;
67
92
 
68
93
  async function main() {
69
94
 
@@ -74,7 +99,7 @@ async function main() {
74
99
 
75
100
  await checkVariables();
76
101
 
77
- subscribeVars();
102
+ await subscribeVars();
78
103
 
79
104
  let readInterval = 5;
80
105
  if (parseInt(adapter.config.readInterval) > 0) {
@@ -83,7 +108,27 @@ async function main() {
83
108
  adapter.log.debug("read every " + readInterval + " minutes");
84
109
  intervalID = setInterval(Do, readInterval * 60 * 1000);
85
110
 
111
+ //read at adapterstart
112
+ await Do();
113
+
114
+ }
115
+
116
+ let requestRunning = false;
86
117
 
118
+ async function DoRequest() {
119
+
120
+ adapter.log.debug("DoRequest ");
121
+
122
+ if (!requestRunning) {
123
+ requestRunning = true;
124
+ await ebusd_ReadValues();
125
+
126
+ await ebusd_ReceiveData();
127
+ }
128
+ else {
129
+ adapter.log.debug("DoRequest: do nothing already running ");
130
+ }
131
+ requestRunning = false;
87
132
  }
88
133
 
89
134
  async function Do() {
@@ -92,9 +137,8 @@ async function Do() {
92
137
 
93
138
  await ebusd_Command();
94
139
 
95
- await ebusd_ReadValues();
96
-
97
- await ebusd_ReceiveData();
140
+ await DoRequest();
141
+
98
142
  }
99
143
 
100
144
 
@@ -107,23 +151,58 @@ async function HandleStateChange(id, state) {
107
151
  const ids = id.split(".");
108
152
 
109
153
  if (ids[2] === "cmd") {
110
- await Do();
154
+ await ebusd_Command();
155
+ StartDataRequest();
156
+ //see issue #77: only one request possible
157
+ //await Do();
158
+ }
159
+ //unhandled state change ebus.0.find
160
+ else if (ids[2] === "find") {
161
+ await ebusd_find();
111
162
  }
112
163
  else {
113
164
  adapter.log.warn("unhandled state change " + id);
114
165
  }
115
166
  }
167
+ }
168
+
116
169
 
170
+ function StartDataRequest() {
171
+
172
+ if (updateTimerID != null) {
173
+ //already running
174
+ clearTimeout(updateTimerID);
175
+ updateTimerID = null;
176
+ }
177
+ //start or restart
178
+ updateTimerID = setTimeout(DataRequest, 500);
179
+ adapter.log.debug("StartDataRequest");
117
180
  }
118
181
 
119
182
 
183
+ async function DataRequest() {
184
+ adapter.log.debug("get data after command and timeout");
185
+ if (updateTimerID != null) {
186
+ clearTimeout(updateTimerID);
187
+ updateTimerID = null;
188
+ }
189
+ await DoRequest();
190
+ }
191
+
120
192
 
121
193
  let oPolledVars = [];
122
194
  function FillPolledVars() {
123
195
 
124
196
  if (typeof adapter.config.PolledDPs !== 'undefined' && adapter.config.PolledDPs != null && adapter.config.PolledDPs.length > 0) {
125
197
  adapter.log.debug("use new object list for polled vars");
126
- oPolledVars = adapter.config.PolledDPs;
198
+
199
+ //2023-02-10 only active vars
200
+ for (let i = 0; i < adapter.config.PolledDPs.length; i++) {
201
+ if (adapter.config.PolledDPs[i].active) {
202
+ oPolledVars.push(adapter.config.PolledDPs[i]);
203
+ }
204
+ }
205
+
127
206
  }
128
207
  else {
129
208
  //make it compatible to old versions
@@ -134,7 +213,7 @@ function FillPolledVars() {
134
213
 
135
214
  for (let i = 0; i < oPolled.length; i++) {
136
215
  if (oPolled[i].length > 0) {
137
- console.log('add ' + oPolled[i]);
216
+ //console.log('add ' + oPolled[i]);
138
217
  const value = {
139
218
  circuit: "",
140
219
  name: oPolled[i],
@@ -145,6 +224,9 @@ function FillPolledVars() {
145
224
  }
146
225
  }
147
226
  }
227
+
228
+ adapter.log.info("list of polled vars " + JSON.stringify(oPolledVars));
229
+
148
230
  }
149
231
 
150
232
  let oHistoryVars = [];
@@ -246,11 +328,69 @@ async function ebusd_Command() {
246
328
  }
247
329
  }
248
330
 
331
+ async function ebusd_find(){
332
+ try {
333
+ const socket = new net.Socket();
334
+ const promiseSocket = new PromiseSocket(socket);
335
+
336
+ await promiseSocket.connect(parseInt(adapter.config.targetTelnetPort), adapter.config.targetIP);
337
+ adapter.log.debug("telnet connected for cmd");
338
+ promiseSocket.setTimeout(5000);
339
+
340
+ await promiseSocket.write("find -F circuit,name,comment\n");
341
+
342
+ const data = await promiseSocket.read();
343
+
344
+ if (data.includes("ERR")) {
345
+ adapter.log.warn("received error! sent find, received " + data + " please check ebusd logs for details!");
346
+ }
347
+ else {
348
+ adapter.log.debug("received " + typeof data + " " + data);
349
+ }
350
+
351
+ let str = new TextDecoder().decode(data);
352
+ let datas = str.split(/\r?\n/)
353
+
354
+ for (let i = 0; i < datas.length; i++) {
355
+
356
+ //adapter.log.debug(JSON.stringify(datas[i]));
357
+
358
+ let names = datas[i].split(",");
359
+
360
+ //circuit,name,comment
361
+ await UpdateDP(names[0], names[1], names[2]);
362
+
363
+ let cmd = "read -f -c " + names[0] + " " + names[1] ;
364
+
365
+ adapter.log.debug("send cmd " + cmd);
366
+
367
+ cmd += "\n";
368
+ await promiseSocket.write(cmd);
369
+
370
+ const result = await promiseSocket.read();
371
+
372
+ adapter.log.debug("received " + typeof result + " " + result);
373
+ }
374
+
375
+
376
+ promiseSocket.destroy();
377
+
378
+ } catch (e) {
379
+ adapter.log.error("exception from tcp socket in ebusd_find" + "[" + e + "]");
380
+ }
381
+
382
+ }
383
+
384
+
249
385
 
250
386
  //just call http://192.168.0.123:8889/data
251
387
 
252
- function subscribeVars() {
388
+ async function subscribeVars() {
253
389
  adapter.subscribeStates("cmd");
390
+
391
+ adapter.subscribeStates("find");
392
+
393
+ await adapter.setStateAsync("cmdResult", { ack: true, val: "" });
254
394
  }
255
395
 
256
396
  async function CreateObject(key, obj) {
@@ -287,6 +427,50 @@ async function CreateObject(key, obj) {
287
427
  }
288
428
 
289
429
 
430
+ //circuit,name,comment
431
+ async function UpdateDP(circuit, name, comment) {
432
+
433
+ let key = circuit + ".messages." + name;
434
+ adapter.log.debug("update check for " + key);
435
+
436
+
437
+ // ehp.messages.Injection
438
+ //ebus.0.ehp.messages.Injection
439
+
440
+ const obj = await adapter.getObjectAsync(key);
441
+ adapter.log.debug("update check got " + JSON.stringify(obj));
442
+
443
+
444
+ //update check got null
445
+
446
+ if (obj != null) {
447
+
448
+ if (obj.common.name != comment) {
449
+ adapter.log.debug("update " + key + " " + comment);
450
+ await adapter.extendObject(key, {
451
+ common: {
452
+ name: comment,
453
+ read: true,
454
+ write: false
455
+ }
456
+ });
457
+ }
458
+ }
459
+ else {
460
+ await adapter.setObjectNotExistsAsync(key, {
461
+ type: "channel",
462
+ common: {
463
+ name: comment,
464
+ read: true,
465
+ write: false
466
+ }
467
+ });
468
+ }
469
+
470
+ }
471
+
472
+
473
+
290
474
  async function checkVariables() {
291
475
  adapter.log.debug("init variables ");
292
476
 
@@ -319,6 +503,21 @@ async function checkVariables() {
319
503
  };
320
504
  await CreateObject(key, obj);
321
505
 
506
+ key = "find";
507
+ obj = {
508
+ type: "state",
509
+ common: {
510
+ name: "find existing data points",
511
+ type: "boolean",
512
+ role: "button",
513
+ read: false,
514
+ write: true
515
+ }
516
+ };
517
+ await CreateObject(key, obj);
518
+
519
+
520
+
322
521
  adapter.log.debug("init common variables and " + oHistoryVars.length + " history DP's");
323
522
 
324
523
  if (oHistoryVars.length > 0) {
@@ -355,7 +554,7 @@ async function checkVariables() {
355
554
  obj= {
356
555
  type: "state",
357
556
  common: {
358
- name: "ebus history date as JSON",
557
+ name: "ebus history date / time as JSON",
359
558
  type: "string",
360
559
  role: "value",
361
560
  unit: "",
@@ -954,6 +1153,77 @@ async function ebusd_ReadValues() {
954
1153
  }
955
1154
 
956
1155
 
1156
+ async function FindParams(obj) {
1157
+
1158
+ adapter.log.debug("FindParams " + JSON.stringify(obj));
1159
+
1160
+ let list = [];
1161
+
1162
+ try {
1163
+ let circuit = obj.message;
1164
+
1165
+ const socket = new net.Socket();
1166
+ const promiseSocket = new PromiseSocket(socket);
1167
+
1168
+ await promiseSocket.connect(parseInt(adapter.config.targetTelnetPort), adapter.config.targetIP);
1169
+ adapter.log.debug("telnet connected for cmd");
1170
+ promiseSocket.setTimeout(5000);
1171
+
1172
+ await promiseSocket.write("find -c " + circuit + " -F circuit,name\n");
1173
+
1174
+ const data = await promiseSocket.read();
1175
+
1176
+ if (data.includes("ERR")) {
1177
+ adapter.log.warn("received error! sent find, received " + data + " please check ebusd logs for details!");
1178
+ }
1179
+ else {
1180
+ adapter.log.debug("received " + typeof data + " " + data);
1181
+ }
1182
+ /*
1183
+ received object ehp,AccelerationTestModeehp,AccelerationTestModeehp,ActualEnvironmentPowerehp,ActualEnvironmentPowerehp,ActualEnvironmentPowerPercentageehp,ActualEnvironmentPowerPercentageehp,ApplianceCodeehp,ApplianceCodeehp,Backupehp,Backupehp,BackupHoursehp,BackupHoursHcehp,BackupHoursHwcehp,BackupHysteresisehp,BackupIntegralehp,BackupModeHcehp,BackupModeHwcehp,BackupPowerCutehp,BackupStartsehp,BackupStartsHcehp,BackupStartsHwcehp,BackupTypeehp,BivalentTempehp,Bleedingehp,Bleedingehp,CirPumpehp,CirPumpehp,Code1ehp,Code1Code2Validehp,Code2ehp,Compehp,Compehp,CompControlStateehp,CompCutPressHighCountehp,CompCutPressLowCountehp,CompCutTempCountehp,CompDemandehp,CompHoursehp,CompHoursHcehp,CompHoursHwcehp,CompHysteresisehp,CompIntegralehp,CompPressHighehp,CompPressHighehp,CompPressLowehp,CompPressLowehp,CompStartsehp,CompStartsHcehp,CompStartsHwcehp,CompStateehp,CondensorTempehp,CondensorTempehp,currenterrorehp,Dateehp,DateTimeehp,DeltaTempT6T7ehp,ElectricWiringDiagramehp,ElectricWiringDiagramehp,EnergyBalancingReleaseehp,errorhistoryehp,FlowTempehp,FlowTempehp,FlowtempCoolingMinehp,FlowTempOffsetehp,Hc1Pumpehp,Hc1Pumpehp,Hc1PumpHoursehp,Hc1PumpPortehp,Hc1PumpStartsehp,Hc2Pumpehp,Hc2PumpHoursehp,HcFlowTempehp,HcFlowTempOffsetehp,HcModeDemandHoursehp,HcModeFulfilledHoursehp,HcParallelStorageFillingEnabledehp,HcPressehp,HcReturnTempehp,HcReturnTempehp,HcReturnTempOffsetehp,HeatPumpStatusehp,HeatPumpStatusehp,HeatpumpTypeehp,HwcHcValveehp,HwcHcValveehp,HwcHcValveStartsehp,HwcLaggingTimeehp,HwcLoadingDelayehp,HwcModeDemandHoursehp,HwcModeFulfilledHoursehp,HwcPumpStartsehp,HwcSwitchehp,HwcTempehp,HwcTempehp,HwcTempOffsetehp,HydraulicSchemeehp,ICLOutehp,ICLOutehp,Injectionehp,Integralehp,Mixer1DutyCycleehp,NumberCompStartsehp,OutsideTempehp,OutsideTempOffsetehp,OverpressureThresholdehp,PhaseOrderehp,PhaseOrderehp,PhaseStatusehp,PhaseStatusehp,PowerCutehp,PowerCutPreloadingehp,PressSwitchehp,PressSwitchehp,RebootCounterehp,ReturnTempMaxehp,SetModeehp,SoftwareCodeehp,Source2PumpHoursehp,Sourceehp,Sourceehp,SourceHoursehp,SourcePortehp,SourcePressehp,SourcePumpPrerunTimeehp,SourceStartsehp,SourceSwitchehp,SourceSwitchehp,SourceTempInputehp,SourceTempInputehp,SourceTempInputOffsetehp,SourceTempOutputehp,SourceTempOutputehp,SourceTempOutputOffsetehp,SourceTempOutputT8Minehp,StateSoftwareCodeehp,StateSoftwareCodeehp,Status01ehp,Status02ehp,Status16ehp,Statusehp,StatusCirPumpehp,StorageTempBottomehp,StorageTempBottomehp,StorageTempBottomOffsetehp,StorageTempTopehp,StorageTempTopehp,StorageTempTopOffsetehp,Subcoolingehp,Superheatehp,T19MaxToCompOffehp,TempInputehp,TempInputehp,TempInputOffsetehp,TempOutputehp,TempOutputehp,TempOutputOffsetehp,Timeehp,TimeBetweenTwoCompStartsMinehp,TimeCompOffMinehp,TimeCompOnMinehp,TimeOfNextPredictedPowerCutehp,TimeOfNextPredictedPowerCutehp,Weekdayehp,YieldTotalehp,YieldTotal
1184
+ */
1185
+ let str = new TextDecoder().decode(data);
1186
+ let datas = str.split(/\r?\n/)
1187
+
1188
+ for (let i = 0; i < datas.length; i++) {
1189
+
1190
+ //adapter.log.debug(JSON.stringify(datas[i]));
1191
+
1192
+ let names = datas[i].split(",");
1193
+
1194
+ //doppelte und leere herausfiltern
1195
+ let add = true;
1196
+
1197
+ if (names[0] == "" || names[1] == "") {
1198
+ add = false;
1199
+ }
1200
+ else {
1201
+
1202
+ for (let n = 0; n < list.length; n++) {
1203
+
1204
+ if (list[n].circuit == names[0] && list[n].name == names[1]) {
1205
+ add = false;
1206
+ //already in list
1207
+ }
1208
+ }
1209
+ }
1210
+
1211
+ if (add) {
1212
+ let entry = {
1213
+ active: false,
1214
+ circuit: names[0],
1215
+ name: names[1]
1216
+ }
1217
+
1218
+ list.push(entry);
1219
+ }
1220
+ }
1221
+ } catch (e) {
1222
+ adapter.log.error("exception in FindParams " + "[" + e + "]");
1223
+ }
1224
+ adapter.sendTo(obj.from, obj.command, list, obj.callback);
1225
+ }
1226
+
957
1227
  // If started as allInOne/compact mode => return function to create instance
958
1228
  if (module && module.parent) {
959
1229
  module.exports = startAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.ebus",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "ioBroker ebus Adapter",
5
5
  "author": {
6
6
  "name": "René G.",
@@ -24,8 +24,8 @@
24
24
  "flat": "5.0.2",
25
25
  "net": "1.0.2",
26
26
  "promise-socket": "7.0.0",
27
- "cron": "2.1.0",
28
- "axios": "1.2.0"
27
+ "cron": "2.2.0",
28
+ "axios": "0.27.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@iobroker/adapter-dev": "1.2.0",
@@ -33,20 +33,20 @@
33
33
  "@types/chai": "4.3.4",
34
34
  "@types/chai-as-promised": "7.1.5",
35
35
  "@types/gulp": "4.0.10",
36
- "@types/mocha": "10.0.0",
37
- "@types/node": "18.11.9",
36
+ "@types/mocha": "10.0.1",
37
+ "@types/node": "18.11.18",
38
38
  "@types/proxyquire": "1.3.28",
39
39
  "@types/request-promise-native": "1.0.18",
40
40
  "@types/sinon": "10.0.13",
41
41
  "@types/sinon-chai": "3.2.9",
42
- "axios": "1.2.0",
42
+ "axios": "0.27.2",
43
43
  "chai": "4.3.7",
44
44
  "chai-as-promised": "7.1.1",
45
- "eslint": "8.28.0",
45
+ "eslint": "8.31.0",
46
46
  "gulp": "4.0.2",
47
- "mocha": "10.1.0",
47
+ "mocha": "10.2.0",
48
48
  "proxyquire": "2.1.3",
49
- "sinon": "15.0.0",
49
+ "sinon": "15.0.1",
50
50
  "sinon-chai": "3.7.0"
51
51
  },
52
52
  "main": "main.js",