iobroker.ebus 2.4.5 → 3.0.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.
@@ -28,7 +28,7 @@ jobs:
28
28
  node-version: [12.x]
29
29
 
30
30
  steps:
31
- - uses: actions/checkout@v1
31
+ - uses: actions/checkout@v2
32
32
  - name: Use Node.js ${{ matrix.node-version }}
33
33
  uses: actions/setup-node@v1
34
34
  with:
@@ -58,7 +58,7 @@ jobs:
58
58
  - os: windows-latest
59
59
  node-version: 8.x
60
60
  steps:
61
- - uses: actions/checkout@v1
61
+ - uses: actions/checkout@v2
62
62
  - name: Use Node.js ${{ matrix.node-version }}
63
63
  uses: actions/setup-node@v1
64
64
  with:
@@ -78,7 +78,7 @@ jobs:
78
78
  if: startsWith(runner.OS, 'windows')
79
79
  run: set DEBUG=testing:* & npm run test:integration
80
80
 
81
- # TODO: To enable automatic npm releases, create a token on npmjs.org
81
+ # TODO: To enable automatic npm releases, create a token on npmjs.org
82
82
  # Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
83
83
  # Then uncomment the following block:
84
84
 
@@ -90,7 +90,7 @@ jobs:
90
90
  # if: |
91
91
  # contains(github.event.head_commit.message, '[skip ci]') == false &&
92
92
  # github.event_name == 'push' &&
93
- #
93
+ # github.event.base_ref == 'refs/heads/master' &&
94
94
  # startsWith(github.ref, 'refs/tags/v')
95
95
  #
96
96
  # runs-on: ubuntu-latest
@@ -99,7 +99,7 @@ jobs:
99
99
  # node-version: [12.x]
100
100
  #
101
101
  # steps:
102
- # - uses: actions/checkout@v1
102
+ # - uses: actions/checkout@v2
103
103
  # - name: Use Node.js ${{ matrix.node-version }}
104
104
  # uses: actions/setup-node@v1
105
105
  # with:
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) <2017 - 2021> <info@rg-engineering.eu>
1
+ Copyright (C) <2017 - 2022> <info@rg-engineering.eu>
2
2
 
3
3
  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:
4
4
 
package/README.md CHANGED
@@ -30,7 +30,10 @@ There is a possibillity to poll data which are not polled by ebusd directly. Com
30
30
 
31
31
  Another feature is to send any command to ebusd and receive answer to work with e.g. scripts.
32
32
 
33
- current supported ebusd-version: 21.2
33
+ current supported ebusd-version: 22.2
34
+
35
+ **Attention** with ebusd - version 22.1 config path has been changed to http://cfg.ebusd.eu/. Make sure you change it in your installation of ebusd.
36
+ details see in [changelog](https://github.com/john30/ebusd/blob/master/ChangeLog.md)
34
37
 
35
38
 
36
39
  ## how to send commands to ebusd
@@ -52,6 +55,16 @@ Attention: command in datapoint ebus.0.cmd is deleted after executing of command
52
55
 
53
56
  ## Changelog
54
57
 
58
+ ### 3.0.0 (2022-04-02)
59
+ * (René) **ATTENTION** change from scheduled to daemon adapter
60
+ * (René) bent by axios replaced
61
+
62
+ ### 2.5.1 (2021-12-29)
63
+ * (René) adjustable retries to send data if arbitration error appeared
64
+
65
+ ### 2.5.0 (2021-12-28)
66
+ * (René) see issue #62: support ebusd 21.3
67
+
55
68
  ### 2.4.5 (2021-11-07)
56
69
  * (René) bug fix color of labels in widget
57
70
 
@@ -165,7 +178,7 @@ Attention: command in datapoint ebus.0.cmd is deleted after executing of command
165
178
  * (René) initial release
166
179
 
167
180
  ## License
168
- Copyright (C) <2017 - 2021> <info@rg-engineering.eu>
181
+ Copyright (C) <2017 - 2022> <info@rg-engineering.eu>
169
182
 
170
183
  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:
171
184
 
@@ -273,30 +273,14 @@
273
273
  <label for="parseTimeout" class="translate">parse_timeout</label>
274
274
  </div>
275
275
  </div>
276
+ <div class="row">
277
+ <div class="input-field col s12 m4 l3">
278
+ <input class="value number" id="maxretries" size="3" maxlength="3" type="number" min="0" max="10" />
279
+ <label for="maxretries" class="translate">maxretries</label>
280
+ </div>
281
+ </div>
276
282
 
277
- <!--
278
- <div class="row">
279
- <div class="input-field col s6">
280
- <textarea class="value materialize-textarea polled" id="PolledValues"></textarea>
281
- <label class="translate" for="PolledValues">ListOfAllPolledValues</label>
282
- </div>
283
-
284
- <div class="col s6">
285
- <span class="translate">hint_ebusd_polled</span>
286
- </div>
287
- </div>
288
-
289
- <div class="row">
290
- <div class="input-field col s6">
291
- <textarea class="value materialize-textarea polled" id="HistoryValues"></textarea>
292
- <label class="translate" for="HistoryValues">ListOfAllHistoryValues</label>
293
- </div>
294
-
295
- <div class="col s6">
296
- <span class="translate">hint_ebusd_history</span>
297
- </div>
298
- </div>
299
- -->
283
+
300
284
 
301
285
  </div>
302
286
 
package/admin/words.js CHANGED
@@ -9,6 +9,7 @@ systemDictionary = {
9
9
  "hint_ebusd_history": { "en": "list of all datapoint names which should be used with ebus history widget. ", "de": "Liste aller Datenpunktnamen, die mit dem ebus-History-Widget verwendet werden sollen.", "ru": "список всех имен точек данных, которые следует использовать с виджетом истории ebus.", "pt": "lista de todos os nomes de pontos de dados que devem ser usados ​​com o widget de histórico do ebus.", "nl": "lijst met alle datapuntnamen die moeten worden gebruikt met de ebus-geschiedeniswidget.", "fr": "liste de tous les noms de points de données qui doivent être utilisés avec le widget historique ebus.", "it": "elenco di tutti i nomi dei punti dati che dovrebbero essere utilizzati con il widget cronologia ebus.", "es": "lista de todos los nombres de puntos de datos que deben usarse con el widget de historial de ebus.", "pl": "lista wszystkich nazw punktów danych, które powinny być używane z widżetem historii ebus.", "zh-cn": "应与 ebus 历史小部件一起使用的所有数据点名称的列表。"},
10
10
  "hint_ebusd_polled": { "en": "list of all datapoint names which should be polled from adapter. Do not add datapoints which are already polled from ebusd. Circuit and additional parameter are optionally.", "de": "Liste aller Datenpunktnamen, die vom Adapter abgefragt werden sollen. ", "ru": "список всех имен точек данных, которые должны быть опрошены от адаптера. ", "pt": "lista de todos os nomes de pontos de dados que devem ser pesquisados ​​no adaptador. ", "nl": "lijst met alle datapuntnamen die van de adapter moeten worden opgevraagd. ", "fr": "liste de tous les noms de points de données qui doivent être interrogés à partir de l'adaptateur. ", "it": "elenco di tutti i nomi dei punti dati che devono essere interrogati dall'adattatore. ", "es": "lista de todos los nombres de puntos de datos que deben consultarse desde el adaptador. ", "pl": "lista wszystkich nazw punktów danych, które powinny być odpytywane z adaptera. ", "zh-cn": "应从适配器轮询的所有数据点名称的列表。"},
11
11
  "historyDP": { "en": "history datapoints", "de": "Verlaufsdatenpunkte", "ru": "исторические данные", "pt": "pontos de dados de história", "nl": "geschiedenis datapunten", "fr": "points de données d'historique", "it": "punti dati della cronologia", "es": "puntos de datos históricos", "pl": "punkty danych historii", "zh-cn": "历史数据点"},
12
+ "maxretries": { "en": "maximum number of retries to send a command ", "de": "maximale Anzahl von Wiederholungen, um einen Befehl zu senden", "ru": "максимальное количество попыток отправки команды", "pt": "número máximo de tentativas para enviar um comando", "nl": "maximum aantal pogingen om een ​​opdracht te verzenden", "fr": "nombre maximum de tentatives pour envoyer une commande", "it": "numero massimo di tentativi per inviare un comando", "es": "número máximo de reintentos para enviar un comando", "pl": "maksymalna liczba ponownych prób wysłania polecenia", "zh-cn": "发送命令的最大重试次数"},
12
13
  "name": { "en": "name", "de": "Name", "ru": "имя", "pt": "nome", "nl": "naam", "fr": "Nom", "it": "nome", "es": "nombre", "pl": "Nazwa", "zh-cn": "姓名"},
13
14
  "parse_timeout": { "en": "download and poll timeout [seconds]", "de": "Download und Abfrage-Timeout [Sekunden]", "ru": "время ожидания загрузки и опроса [секунд]", "pt": "tempo de download e poll timeout [segundos]", "nl": "downloaden en poll time-out [seconden]", "fr": "délai de téléchargement et d'interrogation [secondes]", "it": "download e polling timeout [secondi]", "es": "tiempo de espera de descarga y encuesta [segundos]", "pl": "czas pobierania i odpytywania [sekundy]", "zh-cn": "下载和轮询超时[秒]"},
14
15
  "polledDP": { "en": "polled datapoints", "de": "abgefragte Datenpunkte", "ru": "опрошенные точки данных", "pt": "pontos de dados sondados", "nl": "opgevraagde datapunten", "fr": "points de données interrogés", "it": "punti dati interrogati", "es": "puntos de datos sondeados", "pl": "odpytywane punkty danych", "zh-cn": "轮询数据点"},
package/io-package.json CHANGED
@@ -1,151 +1,43 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "ebus",
4
- "version": "2.4.5",
4
+ "version": "3.0.0",
5
5
  "news": {
6
- "2.4.5": {
7
- "en": "bug fix color of labels in widget",
8
- "de": "Fehlerkorrektur Farbe der Labels im Widget",
9
- "ru": "исправлена ​​ошибка цвета меток в виджете",
10
- "pt": "correção de bug de cor de rótulos no widget",
11
- "nl": "bug fix kleur van labels in widget",
12
- "fr": "correction de bogues couleur des étiquettes dans le widget",
13
- "it": "bug fix colore delle etichette nel widget",
14
- "es": "corrección de errores de color de las etiquetas en el widget",
15
- "pl": "naprawa błędu koloru etykiet w widżecie",
16
- "zh-cn": "错误修复小部件中标签的颜色"
6
+ "3.0.0": {
7
+ "en": "from 'scheduled' to 'daemon' adapter changed",
8
+ "de": "von 'geplant' zu 'daemon' Adapter geändert",
9
+ "ru": "изменен адаптер с «запланированного» на «демон»",
10
+ "pt": "adaptador 'agendado' para 'daemon' alterado",
11
+ "nl": "van 'scheduled' naar 'daemon' adapter gewijzigd",
12
+ "fr": "de l'adaptateur 'scheduled' à 'daemon' changé",
13
+ "it": "adattatore da \"programmato\" a \"demone\" modificato",
14
+ "es": "Se cambió el adaptador de 'programado' a 'daemon'",
15
+ "pl": "Zmieniono adapter z „zaplanowanego” na „demon”",
16
+ "zh-cn": "从 'scheduled' 到 'daemon' 适配器已更改"
17
17
  },
18
- "2.4.4": {
19
- "en": "avoid endles loops",
20
- "de": "Endlosschleifen vermeiden",
21
- "ru": "избегать петель endles",
22
- "pt": "evite loops de endles",
23
- "nl": "vermijd eindeloze lussen",
24
- "fr": "éviter les boucles sans fin",
25
- "it": "evita i loop infiniti",
26
- "es": "evitar bucles endles",
27
- "pl": "unikaj niekończących się pętli",
28
- "zh-cn": "避免无限循环"
18
+ "2.6.0": {
19
+ "en": " 'bent' replaced by 'axios'",
20
+ "de": "'bent' ersetzt durch 'axios'",
21
+ "ru": "«согнутый» заменен на «аксиос»",
22
+ "pt": "'curvado' substituído por 'axios'",
23
+ "nl": "'gebogen' vervangen door 'axios'",
24
+ "fr": "'plié' remplacé par 'axios'",
25
+ "it": "'piegato' sostituito da 'assios'",
26
+ "es": "'doblado' reemplazado por 'axios'",
27
+ "pl": "„wygięty” zastąpiony przez „axios”",
28
+ "zh-cn": "'bent' 替换为 'axios'"
29
29
  },
30
- "2.4.3": {
31
- "en": "small bugs solved",
32
- "de": "kleine Fehler behoben",
33
- "ru": "исправлены мелкие ошибки",
34
- "pt": "pequenos bugs resolvidos",
35
- "nl": "kleine bugs opgelost",
36
- "fr": "petits bugs résolus",
37
- "it": "piccoli bug risolti",
38
- "es": "pequeños errores resueltos",
39
- "pl": "małe błędy rozwiązane",
40
- "zh-cn": "小错误已解决"
41
- },
42
- "2.4.0": {
43
- "en": "overwork handling of read and history datapoints; support of list of commands ",
44
- "de": "Überarbeitung von Lese- und Verlaufsdatenpunkten; ",
45
- "ru": "чрезмерная работа с точками чтения и истории; ",
46
- "pt": "excesso de trabalho no manuseio de pontos de dados de leitura e histórico; ",
47
- "nl": "overwerk afhandeling van lees- en geschiedenisdatapunten; ",
48
- "fr": "traitement excessif des points de données de lecture et d'historique ; ",
49
- "it": "gestione del lavoro eccessivo dei punti dati di lettura e cronologia; ",
50
- "es": "manejo de exceso de trabajo de los puntos de datos de lectura e historial; ",
51
- "pl": "przepracowanie obsługi odczytanych i historycznych punktów danych; ",
52
- "zh-cn": "读取和历史数据点的过度处理;"
53
- },
54
- "2.3.1": {
55
- "en": "support for ebusd 21.2",
56
- "de": "unterstützung für ebusd 21.2",
57
- "ru": "поддержка ebusd 21.2",
58
- "pt": "suporte para ebusd 21.2",
59
- "nl": "ondersteuning voor ebusd 21.2",
60
- "fr": "prise en charge d'ebusd 21.2",
61
- "it": "supporto per ebusd 21.2",
62
- "es": "soporte para ebusd 21.2",
63
- "pl": "obsługa ebusd 21,2",
64
- "zh-cn": "支持 ebusd 21.2"
65
- },
66
- "2.2.7": {
67
- "en": "bug fix for wrong data type logs",
68
- "de": "Bugfix für falsche Datentyp-Logs",
69
- "ru": "исправление ошибки для журналов неправильного типа данных",
70
- "pt": "correção de bug para registros de tipo de dados errado",
71
- "nl": "bugfix voor logs van verkeerde gegevenstypes",
72
- "fr": "correction de bogues pour les journaux de type de données incorrect",
73
- "it": "correzione di bug per log di tipi di dati errati",
74
- "es": "corrección de errores para registros de tipo de datos incorrectos",
75
- "pl": "poprawka błędów w logach z nieprawidłowymi typami danych",
76
- "zh-cn": "错误数据类型日志的错误修复"
77
- },
78
- "2.2.5": {
79
- "en": "dependencies updated",
80
- "de": "Abhängigkeiten aktualisiert",
81
- "ru": "зависимости обновлены",
82
- "pt": "dependências atualizadas",
83
- "nl": "afhankelijkheden bijgewerkt",
84
- "fr": "dépendances mises à jour",
85
- "it": "dipendenze aggiornate",
86
- "es": "dependencias actualizadas",
87
- "pl": "zaktualizowane zależności",
88
- "zh-cn": "依赖关系已更新"
89
- },
90
- "2.2.4": {
91
- "en": "bug fix: exception in widget removed",
92
- "de": "Fehlerbehebung: Ausnahme im Widget entfernt",
93
- "ru": "исправление ошибки: исключение в виджете удалено",
94
- "pt": "correção de bug: exceção no widget removida",
95
- "nl": "bug fix: uitzondering in widget verwijderd",
96
- "fr": "correction de bogue: exception dans le widget supprimée",
97
- "it": "correzione bug: eccezione nel widget rimossa",
98
- "es": "corrección de errores: excepción en el widget eliminado",
99
- "pl": "poprawka: wyjątek w widżecie został usunięty",
100
- "zh-cn": "错误修复:删除了小部件中的异常"
101
- },
102
- "2.2.3": {
103
- "en": "create history DP if not available ",
104
- "de": "History-DP erstellen, falls nicht verfügbar",
105
- "ru": "создать историю DP, если недоступен",
106
- "pt": "criar histórico DP se não estiver disponível",
107
- "nl": "maak een geschiedenis-DP als deze niet beschikbaar is",
108
- "fr": "créer l'historique DP s'il n'est pas disponible",
109
- "it": "creare la cronologia DP se non disponibile",
110
- "es": "crear historial DP si no está disponible",
111
- "pl": "utwórz historię DP, jeśli nie jest dostępna",
112
- "zh-cn": "创建历史记录DP(如果不可用)"
113
- },
114
- "2.2.0": {
115
- "en": "change DP only if necessary to reduce system load",
116
- "de": "Ändern Sie den DP nur bei Bedarf, um die Systemlast zu verringern",
117
- "ru": "изменяйте DP только в случае необходимости для снижения нагрузки на систему",
118
- "pt": "mude DP apenas se necessário para reduzir a carga do sistema",
119
- "nl": "verander DP alleen indien nodig om de systeembelasting te verminderen",
120
- "fr": "changer DP uniquement si nécessaire pour réduire la charge du système",
121
- "it": "cambiare DP solo se necessario per ridurre il carico del sistema",
122
- "es": "cambie DP solo si es necesario para reducir la carga del sistema",
123
- "pl": "zmień DP tylko wtedy, gdy jest to konieczne, aby zmniejszyć obciążenie systemu",
124
- "zh-cn": "仅在需要减少系统负载时才更改DP"
125
- },
126
- "2.1.1": {
127
- "en": "refactoring: 'async/await' used",
128
- "de": "Refactoring: 'async / await' verwendet",
129
- "ru": "рефакторинг: используется async / await",
130
- "pt": "refatoração: 'async / waitit' usado",
131
- "nl": "refactoring: 'async / await' gebruikt",
132
- "fr": "refactoring: 'async / wait' utilisé",
133
- "it": "refactoring: 'async / await' usato",
134
- "es": "refactorización: 'async / await' usado",
135
- "pl": "refaktoryzacja: użyto opcji „asynchronizuj / czekaj”",
136
- "zh-cn": "重构:使用“异步/等待”"
137
- },
138
- "1.0.0": {
139
- "en": "update to flot 3.0",
140
- "de": "Update auf Flot 3.0",
141
- "ru": "обновление до флота 3.0",
142
- "pt": "atualizar para o flot 3.0",
143
- "nl": "update naar flot 3.0",
144
- "fr": "mise à jour vers flot 3.0",
145
- "it": "aggiornamento a flot 3.0",
146
- "es": "actualizar a flot 3.0",
147
- "pl": "aktualizacja do flot 3.0",
148
- "zh-cn": "更新到flot 3.0"
30
+ "2.5.1": {
31
+ "en": "maximum retries to send data in case of arbitration error",
32
+ "de": "maximale Wiederholungsversuche zum Senden von Daten im Falle eines Vermittlungsfehlers",
33
+ "ru": "максимальное количество попыток отправки данных в случае ошибки арбитража",
34
+ "pt": "máximo de tentativas para enviar dados em caso de erro de arbitragem",
35
+ "nl": "maximaal aantal pogingen om gegevens te verzenden in geval van arbitragefout",
36
+ "fr": "nombre maximum de tentatives d'envoi de données en cas d'erreur d'arbitrage",
37
+ "it": "numero massimo di tentativi di invio dei dati in caso di errore di arbitrato",
38
+ "es": "reintentos máximos para enviar datos en caso de error de arbitraje",
39
+ "pl": "maksymalna liczba prób wysłania danych w przypadku błędu arbitrażu",
40
+ "zh-cn": "仲裁错误时发送数据的最大重试次数"
149
41
  }
150
42
  },
151
43
  "title": "ebus",
@@ -174,8 +66,7 @@
174
66
  "zh-cn": "ebus适配器;"
175
67
  },
176
68
  "platform": "Javascript/Node.js",
177
- "mode": "schedule",
178
- "schedule": "*/5 * * * *",
69
+ "mode": "daemon",
179
70
  "icon": "ebus.png",
180
71
  "enabled": true,
181
72
  "messagebox": true,
@@ -189,6 +80,11 @@
189
80
  "type": "hardware",
190
81
  "license": "MIT",
191
82
  "materialize": true,
83
+ "dependencies": [
84
+ {
85
+ "js-controller": ">=2.0.0"
86
+ }
87
+ ],
192
88
  "plugins": {
193
89
  "sentry": {
194
90
  "dsn": "https://bb7e6f51a1274ced81576d84f82f667e@o390433.ingest.sentry.io/5434784"
@@ -217,6 +113,8 @@
217
113
  "parseTimeout": 60,
218
114
  "useBoolean4Onoff": false,
219
115
  "PolledDPs": [],
220
- "HistoryDPs": []
116
+ "HistoryDPs": [],
117
+ "maxretries": 5,
118
+ "readInterval": 5
221
119
  }
222
120
  }
package/main.js CHANGED
@@ -11,8 +11,11 @@
11
11
  /*jslint node: true */
12
12
  "use strict";
13
13
 
14
+
15
+
16
+
14
17
  const utils = require("@iobroker/adapter-core");
15
- const ebusdMinVersion = [21, 2];
18
+ const ebusdMinVersion = [22, 2];
16
19
  let ebusdVersion = [0, 0];
17
20
  let ebusdUpdateVersion = [0, 0];
18
21
 
@@ -21,6 +24,8 @@ function startAdapter(options) {
21
24
  options = options || {};
22
25
  Object.assign(options, {
23
26
  name: "ebus",
27
+ //#######################################
28
+ //
24
29
  ready: function () {
25
30
  try {
26
31
  //adapter.log.debug('start');
@@ -29,7 +34,39 @@ function startAdapter(options) {
29
34
  catch (e) {
30
35
  adapter.log.error("exception catch after ready [" + e + "]");
31
36
  }
32
- }
37
+ },
38
+ //#######################################
39
+ // is called when adapter shuts down
40
+ unload: function (callback) {
41
+ try {
42
+ adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
43
+ //to do stop intervall
44
+ callback();
45
+ } catch (e) {
46
+ callback();
47
+ }
48
+ },
49
+ //#######################################
50
+ //
51
+ SIGINT: function () {
52
+ adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
53
+ CronStop();
54
+ },
55
+ //#######################################
56
+ // is called if a subscribed object changes
57
+ //objectChange: function (id, obj) {
58
+ // adapter.log.debug("[OBJECT CHANGE] ==== " + id + " === " + JSON.stringify(obj));
59
+ //},
60
+ //#######################################
61
+ // is called if a subscribed state changes
62
+ //stateChange: function (id, state) {
63
+ //HandleStateChange(id, state);
64
+ //},
65
+ stateChange: async (id, state) => {
66
+ await HandleStateChange(id, state);
67
+ },
68
+ //#######################################
69
+ //
33
70
  });
34
71
  adapter = new utils.Adapter(options);
35
72
 
@@ -37,18 +74,21 @@ function startAdapter(options) {
37
74
  }
38
75
 
39
76
  //var request = require('request');
40
- const bent = require("bent");
77
+ //const bent = require("bent");
78
+ const axios = require('axios');
41
79
  //const parseString = require("xml2js").parseString;
42
80
  const net = require("net");
43
81
  const { PromiseSocket } = require("promise-socket");
44
82
 
45
83
 
46
84
 
47
- let killTimer;
85
+ //let killTimer;
86
+ let intervalID;
48
87
 
49
88
 
50
89
  async function main() {
51
90
 
91
+ /*
52
92
  let nParseTimeout = 60;
53
93
  if (adapter.config.parseTimeout > 0) {
54
94
  nParseTimeout = adapter.config.parseTimeout;
@@ -62,30 +102,68 @@ async function main() {
62
102
  //process.exit(0);
63
103
  adapter.terminate ? adapter.terminate(15) : process.exit(15);
64
104
  }, nParseTimeout);
105
+ */
65
106
 
66
107
  adapter.log.debug("start with interface ebusd ");
67
108
 
68
109
  FillPolledVars();
69
110
  FillHistoryVars();
70
111
 
71
- await ebusd_checkVariables();
112
+ await checkVariables();
72
113
 
73
- await ebusd_Command();
74
- await ebusd_ReadValues();
114
+ subscribeVars();
75
115
 
76
116
  //await TestFunction();
77
117
 
78
- await ebusd_ReceiveData();
118
+ let readInterval = 5;
119
+ if (parseInt(adapter.config.readInterval) > 0) {
120
+ readInterval = adapter.config.readInterval;
121
+ }
122
+ adapter.log.debug("read every " + readInterval + " minutes");
123
+ intervalID = setInterval(Do, readInterval * 60 * 1000);
79
124
 
125
+ /*
80
126
  if (killTimer) {
81
127
  clearTimeout(killTimer);
82
128
  adapter.log.debug("timer killed");
83
129
  }
84
130
 
85
131
  adapter.terminate ? adapter.terminate(0) : process.exit(0);
132
+ */
133
+ }
134
+
135
+ async function Do() {
136
+
137
+ adapter.log.debug("starting ... " );
86
138
 
139
+ await ebusd_Command();
140
+
141
+ await ebusd_ReadValues();
142
+
143
+ await ebusd_ReceiveData();
87
144
  }
88
145
 
146
+
147
+ async function HandleStateChange(id, state) {
148
+
149
+
150
+ if (state.ack !== true) {
151
+
152
+ adapter.log.debug("handle state change " + id);
153
+ const ids = id.split(".");
154
+
155
+ if (ids[2] === "cmd") {
156
+ await ebusd_Command();
157
+ }
158
+ else {
159
+ adapter.log.warn("unhandled state change " + id);
160
+ }
161
+ }
162
+
163
+ }
164
+
165
+
166
+
89
167
  let oPolledVars = [];
90
168
  function FillPolledVars() {
91
169
 
@@ -143,93 +221,7 @@ function FillHistoryVars() {
143
221
  }
144
222
 
145
223
 
146
- async function Common_checkVariables() {
147
224
 
148
- adapter.log.debug("init common variables and " + oHistoryVars.length + " history DP's");
149
- let key;
150
- let obj;
151
-
152
- if (oHistoryVars.length > 0) {
153
-
154
- if (oHistoryVars.length > 4) {
155
- adapter.log.warn("too many history values " + oHistoryVars.length + " -> maximum is 4");
156
- }
157
-
158
- for (let n = 1; n <= oHistoryVars.length; n++) {
159
-
160
- if (oHistoryVars[n - 1].name.length > 0) {
161
- const name = "history value " + n + " as JSON " + oHistoryVars[n - 1].name;
162
- key = "history.value" + n;
163
- await adapter.setObjectNotExistsAsync(key, {
164
- type: "state",
165
- common: {
166
- name: name,
167
- type: "string",
168
- role: "value",
169
- unit: "",
170
- read: true,
171
- write: false
172
- },
173
- native: { location: key }
174
- });
175
-
176
- obj = await adapter.getObjectAsync(key);
177
-
178
- if (obj != null) {
179
-
180
- if (obj.common.role != "value" || obj.common.name != name) {
181
- await adapter.extendObject(key, {
182
- common: {
183
- name: name,
184
- role: "value",
185
- }
186
- });
187
- }
188
- }
189
- }
190
- else {
191
- adapter.log.warn("ignoring history value " + n + " (invalid name)");
192
- }
193
- }
194
-
195
- key = "history.date";
196
- await adapter.setObjectNotExistsAsync(key, {
197
- type: "state",
198
- common: { name: "ebus history date as JSON", type: "string", role: "value", unit: "", read: true, write: false },
199
- native: { location: key }
200
- });
201
- obj = await adapter.getObjectAsync(key);
202
-
203
- if (obj != null) {
204
-
205
- if (obj.common.role != "value") {
206
- await adapter.extendObject(key, {
207
- common: {
208
- role: "value",
209
- }
210
- });
211
- }
212
- }
213
- }
214
- key = "history.error";
215
- await adapter.setObjectNotExistsAsync(key, {
216
- type: "state",
217
- common: { name: "ebus error", type: "string", role: "value", unit: "", read: true, write: false },
218
- native: { location: key }
219
- });
220
- obj = await adapter.getObjectAsync(key);
221
-
222
- if (obj != null) {
223
-
224
- if (obj.common.role != "value") {
225
- await adapter.extendObject(key, {
226
- common: {
227
- role: "value",
228
- }
229
- });
230
- }
231
- }
232
- }
233
225
 
234
226
 
235
227
 
@@ -299,7 +291,12 @@ async function ebusd_Command() {
299
291
 
300
292
  //just call http://192.168.0.123:8889/data
301
293
 
302
- async function ebusd_checkVariables() {
294
+ function subscribeVars() {
295
+ adapter.subscribeStates("cmd");
296
+ }
297
+
298
+
299
+ async function checkVariables() {
303
300
  adapter.log.debug("init variables ");
304
301
 
305
302
  let key;
@@ -353,7 +350,92 @@ async function ebusd_checkVariables() {
353
350
  });
354
351
  }
355
352
  }
356
- Common_checkVariables();
353
+
354
+
355
+
356
+ adapter.log.debug("init common variables and " + oHistoryVars.length + " history DP's");
357
+
358
+
359
+ if (oHistoryVars.length > 0) {
360
+
361
+ if (oHistoryVars.length > 4) {
362
+ adapter.log.warn("too many history values " + oHistoryVars.length + " -> maximum is 4");
363
+ }
364
+
365
+ for (let n = 1; n <= oHistoryVars.length; n++) {
366
+
367
+ if (oHistoryVars[n - 1].name.length > 0) {
368
+ const name = "history value " + n + " as JSON " + oHistoryVars[n - 1].name;
369
+ key = "history.value" + n;
370
+ await adapter.setObjectNotExistsAsync(key, {
371
+ type: "state",
372
+ common: {
373
+ name: name,
374
+ type: "string",
375
+ role: "value",
376
+ unit: "",
377
+ read: true,
378
+ write: false
379
+ },
380
+ native: { location: key }
381
+ });
382
+
383
+ obj = await adapter.getObjectAsync(key);
384
+
385
+ if (obj != null) {
386
+
387
+ if (obj.common.role != "value" || obj.common.name != name) {
388
+ await adapter.extendObject(key, {
389
+ common: {
390
+ name: name,
391
+ role: "value",
392
+ }
393
+ });
394
+ }
395
+ }
396
+ }
397
+ else {
398
+ adapter.log.warn("ignoring history value " + n + " (invalid name)");
399
+ }
400
+ }
401
+
402
+ key = "history.date";
403
+ await adapter.setObjectNotExistsAsync(key, {
404
+ type: "state",
405
+ common: { name: "ebus history date as JSON", type: "string", role: "value", unit: "", read: true, write: false },
406
+ native: { location: key }
407
+ });
408
+ obj = await adapter.getObjectAsync(key);
409
+
410
+ if (obj != null) {
411
+
412
+ if (obj.common.role != "value") {
413
+ await adapter.extendObject(key, {
414
+ common: {
415
+ role: "value",
416
+ }
417
+ });
418
+ }
419
+ }
420
+ }
421
+ key = "history.error";
422
+ await adapter.setObjectNotExistsAsync(key, {
423
+ type: "state",
424
+ common: { name: "ebus error", type: "string", role: "value", unit: "", read: true, write: false },
425
+ native: { location: key }
426
+ });
427
+ obj = await adapter.getObjectAsync(key);
428
+
429
+ if (obj != null) {
430
+
431
+ if (obj.common.role != "value") {
432
+ await adapter.extendObject(key, {
433
+ common: {
434
+ role: "value",
435
+ }
436
+ });
437
+ }
438
+ }
357
439
  }
358
440
 
359
441
 
@@ -387,13 +469,19 @@ async function ebusd_ReceiveData() {
387
469
  adapter.log.debug("request data from " + sUrl);
388
470
 
389
471
  try {
390
-
472
+ /*
391
473
  const getBuffer = bent("string");
392
474
  const buffer = await getBuffer(sUrl);
475
+ */
476
+
477
+ const buffer = await axios.get(sUrl);
393
478
 
394
- const oData = JSON.parse(buffer);
479
+ adapter.log.debug("got data " + typeof buffer.data + " " + JSON.stringify(buffer.data));
395
480
 
396
- adapter.log.debug("oData " + JSON.stringify(oData));
481
+ //const oData = JSON.parse(buffer.data);
482
+ const oData = buffer.data;
483
+
484
+ //adapter.log.debug("oData " + oData);
397
485
 
398
486
  const flatten = require("flat");
399
487
 
@@ -841,10 +929,6 @@ read -f YieldTotal,read LegioProtectionEnabled,read -f -c broadcast outsidetemp
841
929
  //here we need a loop over all configured read data in admin-page
842
930
  async function ebusd_ReadValues() {
843
931
 
844
-
845
-
846
-
847
-
848
932
  if (oPolledVars.length > 0) {
849
933
 
850
934
  adapter.log.debug("to poll ctr " + oPolledVars.length + " vals: " + JSON.stringify(oPolledVars));
@@ -857,6 +941,7 @@ async function ebusd_ReadValues() {
857
941
  adapter.log.debug("telnet connected to poll variables " + adapter.config.targetIP + " port " + adapter.config.targetTelnetPort);
858
942
  promiseSocket.setTimeout(5000);
859
943
 
944
+ let retries = 0;
860
945
  for (let nCtr = 0; nCtr < oPolledVars.length; nCtr++) {
861
946
 
862
947
  let circuit = "";
@@ -879,6 +964,22 @@ async function ebusd_ReadValues() {
879
964
  //received ERR: arbitration lost for YieldThisYear
880
965
  if (data.includes("ERR")) {
881
966
  adapter.log.error("sent " + cmd + ", received " + data + " for " + JSON.stringify(oPolledVars[nCtr]));
967
+
968
+ /*
969
+ * sent read -f YieldLastYear, received ERR: arbitration lost for {"circuit":"","name":"YieldLastYear","parameter":""}
970
+ * */
971
+ if (data.includes("arbitration lost")) {
972
+
973
+ retries++;
974
+ if (retries > adapter.config.maxretries) {
975
+ adapter.log.error("max retries, skip cmd " + cmd);
976
+ retries = 0;
977
+ }
978
+ else {
979
+ nCtr--;
980
+ adapter.log.debug("retry to send data ");
981
+ }
982
+ }
882
983
  }
883
984
  else {
884
985
  adapter.log.debug("received " + data + " for " + JSON.stringify(oPolledVars[nCtr]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.ebus",
3
- "version": "2.4.5",
3
+ "version": "3.0.0",
4
4
  "description": "ioBroker ebus Adapter",
5
5
  "author": {
6
6
  "name": "René G.",
@@ -20,32 +20,32 @@
20
20
  "url": "https://github.com/rg-engineering/ioBroker.ebus"
21
21
  },
22
22
  "dependencies": {
23
- "@iobroker/adapter-core": "2.5.1",
24
- "@sentry/node": "6.14.1",
25
- "bent": "7.3.12",
23
+ "@iobroker/adapter-core": "2.6.0",
24
+ "@sentry/node": "6.19.3",
26
25
  "flat": "5.0.2",
27
26
  "net": "1.0.2",
28
- "promise-socket": "7.0.0"
27
+ "promise-socket": "7.0.0",
28
+ "cron": "1.8.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@iobroker/testing": "2.5.2",
32
- "@types/chai": "4.2.22",
33
- "@types/chai-as-promised": "7.1.4",
31
+ "@iobroker/testing": "2.5.6",
32
+ "@types/chai": "4.3.0",
33
+ "@types/chai-as-promised": "7.1.5",
34
34
  "@types/gulp": "4.0.9",
35
- "@types/mocha": "9.0.0",
36
- "@types/node": "16.11.6",
35
+ "@types/mocha": "9.1.0",
36
+ "@types/node": "17.0.23",
37
37
  "@types/proxyquire": "1.3.28",
38
38
  "@types/request-promise-native": "1.0.18",
39
- "@types/sinon": "10.0.6",
40
- "@types/sinon-chai": "3.2.5",
41
- "axios": "0.24.0",
42
- "chai": "4.3.4",
39
+ "@types/sinon": "10.0.11",
40
+ "@types/sinon-chai": "3.2.8",
41
+ "axios": "0.26.1",
42
+ "chai": "4.3.6",
43
43
  "chai-as-promised": "7.1.1",
44
- "eslint": "8.1.0",
44
+ "eslint": "8.12.0",
45
45
  "gulp": "4.0.2",
46
- "mocha": "9.1.3",
46
+ "mocha": "9.2.2",
47
47
  "proxyquire": "2.1.3",
48
- "sinon": "12.0.1",
48
+ "sinon": "13.0.1",
49
49
  "sinon-chai": "3.7.0"
50
50
  },
51
51
  "main": "main.js",