iobroker.sonoff 2.5.7 → 3.1.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/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sonoff",
4
- "version": "2.5.7",
4
+ "version": "3.1.0",
5
5
  "news": {
6
+ "3.1.0": {
7
+ "en": "Important: Node.js 18.x and js-controller 5.0.19+ is needed at minimum\nupgraded states for Tasmota 13.4.0.3 20240402\nenhanced some log messages\nAdded PWM Items\nFixed QoS handling to prevent invalid resubmissions\nPrevent creation of storeMap property in common and cleanup",
8
+ "de": "Wichtig: Node.js 18.x und js-controller 5.0.19+ ist mindestens erforderlich\naktualisierte Zustände für Tasmota 13.4.0.3 20240402\neinige log-nachrichten erweitert\nPWM Waren\nBehobene QoS-Behandlung, um ungültige Wiedereinsetzungen zu verhindern\nVerhindern Sie die Erstellung von Geschäft Karte Immobilien gemeinsam und sauber",
9
+ "ru": "Важно: Node.js 18.x и js-контроллер 5.0.19+ необходимо как минимум\nмодернизированные штаты для Тасмота 13.4.0.3 20240402\nрасширенные сообщения\nДобавлено PWM Пункты\nФиксированная обработка QoS для предотвращения неправильных повторной подачи\nПредотвращение создания магазина Карта недвижимости в целом и очистки",
10
+ "pt": "Importante: Node.js 18.x e js-controller 5.0.19+ é necessário no mínimo\nestados atualizados para Tasmota 13.4.0.3 20240402\nmelhorou algumas mensagens de log\nAdicionado PWM Itens\nManuseio QoS fixo para evitar resubmissões inválidas\nImpedir a criação de loja Propriedade do mapa em comum e limpeza",
11
+ "nl": "Belangrijk: Node.js 18.x en js-controller 5.0.19+ is minimaal nodig\nverbeterde staten voor Tasmota 13.4.0.3 20240402\nsommige logberichten verbeterd\nToegevoegd PWM Artikelen\nVaste QoS-behandeling om ongeldige resubmissions te voorkomen\nVoorkoming van de oprichting van een opslagplaats Kaart eigendom gemeenschappelijk en opruimen",
12
+ "fr": "Important: Node.js 18.x et js-controller 5.0.19+ est nécessaire au minimum\nétats améliorés pour Tasmota 13.4.03 202402\namélioré certains messages de journal\nAjouté PWM Éléments\nManipulation fixe de QoS pour empêcher les nouvelles présentations non valides\nEmpêcher la création de magasins Carte propriété en commun et nettoyage",
13
+ "it": "Importante: Node.js 18.x e js-controller 5.0.19+ è necessario al minimo\nstati aggiornati per Tasmota 13.4.0.3 20240402\nmigliorato alcuni messaggi di log\nAggiunto PWM Articoli\nMovimentazione QoS fissa per evitare resubmissioni non valide\nPrevenire la creazione di negozio Mappa di proprietà in comune e pulizia",
14
+ "es": "Importante: Node.js 18.x y js-controller 5.0.19+ se necesita al mínimo\nestados actualizados para Tasmota 13.4.0.3 20240402\nmejorar algunos mensajes de registro\nAñadido PWM Temas\nManejo fijo de QoS para prevenir las remisiones inválidas\nPrevenir la creación de la tienda Mapa propiedad en común y limpieza",
15
+ "pl": "Ważne: Node.js 18.x i sterownik js- 5.0.19 + jest potrzebny co najmniej\nzaktualizowane stany dla Tasmota 13.4.0.3 20240402\npoprawiła niektóre komunikaty dziennika\nDodano PWM Pozycje\nNaprawiono obsługę QoS, aby zapobiec niepoprawnym ponownym uruchomieniom\nZapobieganie tworzeniu magazynu Map właściwość wspólne i sprzątanie",
16
+ "uk": "Важливо: Node.js 18.x і js-controller 5.0.19+ необхідний мінімум\nоновлені стани для Тасмота 13.4.0.3 20240402\nрозширено деяких повідомлень журналу\nДодано PWM Товари\nВиправлена обробка QoS для запобігання недійсних відповідей\nПрофілактика створення магазину Карта нерухомості в загальному і чистому вигляді",
17
+ "zh-cn": "重要:节点.js 18.x和js控制器 5.0.19+至少需要\n塔斯莫塔州升级\n增强一些日志消息\n已添加的 PWM 项目\n防止重新提交无效的固定QoS处理\n防止创建仓库 共同和清理的映射属性"
18
+ },
19
+ "3.0.3": {
20
+ "en": "Added migration of password on JSON Config",
21
+ "de": "Migration von Passwort auf JSON Config hinzugefügt",
22
+ "ru": "Добавлена миграция пароля на JSON Config",
23
+ "pt": "Adicionado migração de senha em JSON Config",
24
+ "nl": "Vermelding van wachtwoord op JSON Config",
25
+ "fr": "Ajout de la migration de mot de passe sur JSON Config",
26
+ "it": "Aggiunta migrazione di password su JSON Config",
27
+ "es": "Migración agregada de contraseña en JSON Config",
28
+ "pl": "Dostęp do migracji haseł JSON Config",
29
+ "uk": "Додано міграції пароля на JSON Config",
30
+ "zh-cn": "A. 增加联索行动密码的移徙"
31
+ },
6
32
  "2.5.7": {
7
33
  "en": "Disabled the logging of username and password during connection errors\nadded json config",
8
34
  "de": "Deaktiviert die Protokollierung von Benutzername und Passwort während der Verbindungsfehler\nadd json config",
@@ -39,7 +65,8 @@
39
65
  "it": "Risolto il caso di crash segnalato da Sentry",
40
66
  "es": "Solucionar caso de bloqueo informado por Sentry",
41
67
  "pl": "Napraw przypadek awarii zgłoszony przez Sentry",
42
- "zh-cn": "修复 Sentry 报告的崩溃案例"
68
+ "zh-cn": "修复 Sentry 报告的崩溃案例",
69
+ "uk": "Виправте випадок збою, про який повідомляє Sentry"
43
70
  },
44
71
  "2.5.0": {
45
72
  "en": "Implement writing of NSPanel Widget changes\nFix crash case reported by Sentry",
@@ -51,7 +78,8 @@
51
78
  "it": "Implementare la scrittura delle modifiche al Widget NSPanel\nRisolto il caso di crash segnalato da Sentry",
52
79
  "es": "Implementar la escritura de cambios de NSPanel Widget\nSolucionar caso de bloqueo informado por Sentry",
53
80
  "pl": "Zaimplementuj pisanie zmian NSPanel Widget\nNapraw przypadek awarii zgłoszony przez Sentry",
54
- "zh-cn": "实现编写 NSPanel Widget 更改\n修复 Sentry 报告的崩溃案例"
81
+ "zh-cn": "实现编写 NSPanel Widget 更改\n修复 Sentry 报告的崩溃案例",
82
+ "uk": "Реалізувати написання змін NSPanel Widget\nВиправте випадок збою, про який повідомляє Sentry"
55
83
  },
56
84
  "2.4.7": {
57
85
  "en": "Fix crash case (Sentry IOBROKER-SONOFF-1S)",
@@ -63,31 +91,8 @@
63
91
  "it": "Risolto il crash case (Sentry IOBROKER-SONOFF-1S)",
64
92
  "es": "Reparar caso de bloqueo (Sentry IOBROKER-SONOFF-1S)",
65
93
  "pl": "Napraw przypadek awarii (Sentry IOBROKER-SONOFF-1S)",
66
- "zh-cn": "修复崩溃案例(Sentry IOBROKER-SONOFF-1S)"
67
- },
68
- "2.4.6": {
69
- "en": "Fix some crash cases reported by Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nAdjust Uptime to mixed because it seems that it can be number or string",
70
- "de": "Behebung einiger von Sentry gemeldeter Absturzfälle (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nStellen Sie die Betriebszeit auf gemischt ein, da es sich anscheinend um eine Zahl oder eine Zeichenfolge handeln kann",
71
- "ru": "Исправьте некоторые случаи сбоев, о которых сообщает Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nОтрегулируйте время работы до смешанного, потому что кажется, что это может быть число или строка",
72
- "pt": "Corrigir alguns casos de falha relatados pelo Sentinela (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nAjuste o tempo de atividade para misto porque parece que pode ser um número ou uma string",
73
- "nl": "Enkele crashgevallen gemeld door Sentry repareren (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nStel Uptime in op gemengd omdat het lijkt alsof het een nummer of een tekenreeks kan zijn",
74
- "fr": "Correction de certains cas de plantage signalés par Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nAjustez le temps de disponibilité sur mixte car il semble qu'il puisse s'agir d'un nombre ou d'une chaîne",
75
- "it": "Risolti alcuni casi di crash segnalati da Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nRegola Uptime su misto perché sembra che possa essere un numero o una stringa",
76
- "es": "Solucione algunos casos de bloqueo informados por Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nAjuste el tiempo de actividad a mixto porque parece que puede ser un número o una cadena",
77
- "pl": "Napraw niektóre przypadki awarii zgłaszane przez Sentry (IOBROKER-SONOFF-B, IOBROKER-SONOFF-R, IOBROKER-SONOFF-4, IOBROKER-SONOFF-1, IOBROKER-SONOFF-13, IOBROKER-SONOFF-1J, IOBROKER-SONOFF-16, IOBROKER-SONOFF-3, IOBROKER-SONOFF-H)\nDostosuj Uptime do mieszanego, ponieważ wydaje się, że może to być liczba lub ciąg",
78
- "zh-cn": "修复 Sentry 报告的一些崩溃案例(IOBROKER-SONOFF-B、IOBROKER-SONOFF-R、IOBROKER-SONOFF-4、IOBROKER-SONOFF-1、IOBROKER-SONOFF-13、IOBROKER-SONOFF-1J、IOBROKER-SONOFF-16、 IOBROKER-SONOFF-3、IOBROKER-SONOFF-H)\n将 Uptime 调整为混合,因为它似乎可以是数字或字符串"
79
- },
80
- "2.4.5": {
81
- "en": "Fix some crash cases reported by Sentry",
82
- "de": "Beheben Sie einige von Sentry gemeldete Absturzfälle",
83
- "ru": "Исправить некоторые случаи сбоев, о которых сообщает Sentry",
84
- "pt": "Corrija alguns casos de falha relatados pelo Sentry",
85
- "nl": "Enkele crashgevallen gemeld door Sentry oplossen",
86
- "fr": "Correction de certains cas de plantage signalés par Sentry",
87
- "it": "Risolti alcuni casi di crash segnalati da Sentry",
88
- "es": "Arregle algunos casos de fallas reportados por Sentry",
89
- "pl": "Napraw niektóre przypadki awarii zgłoszone przez Sentry",
90
- "zh-cn": "修复 Sentry 报告的一些崩溃案例"
94
+ "zh-cn": "修复崩溃案例(Sentry IOBROKER-SONOFF-1S)",
95
+ "uk": "Виправити випадок збою (Sentry IOBROKER-SONOFF-1S)"
91
96
  }
92
97
  },
93
98
  "title": "Sonoff",
@@ -101,7 +106,8 @@
101
106
  "it": "Sonoff",
102
107
  "es": "Sonoff",
103
108
  "pl": "Sonoff",
104
- "zh-cn": "索诺夫"
109
+ "zh-cn": "索诺夫",
110
+ "uk": "Сонофф"
105
111
  },
106
112
  "desc": {
107
113
  "en": "This adapter allows to connect sonoff components via MQTT",
@@ -113,12 +119,16 @@
113
119
  "it": "Questo adattatore consente di collegare i componenti Sonoff via MQTT",
114
120
  "es": "Este adaptador permite conectar componentes de sonof a través de MQTT",
115
121
  "pl": "Ten adapter umożliwia łączenie komponentów sonoff za pośrednictwem MQTT",
116
- "zh-cn": "该适配器允许通过MQTT连接Sonoff组件"
122
+ "zh-cn": "该适配器允许通过MQTT连接Sonoff组件",
123
+ "uk": "Цей адаптер дозволяє підключати компоненти sonoff через MQTT"
117
124
  },
118
125
  "authors": [
119
126
  "bluefox <dogafox@gmail.com>"
120
127
  ],
121
- "license": "MIT",
128
+ "licenseInformation": {
129
+ "license": "MIT",
130
+ "type": "free"
131
+ },
122
132
  "platform": "Javascript/Node.js",
123
133
  "mode": "daemon",
124
134
  "compact": true,
@@ -143,7 +153,7 @@
143
153
  "type": "lighting",
144
154
  "dependencies": [
145
155
  {
146
- "js-controller": ">=2.0.0"
156
+ "js-controller": ">=5.0.19"
147
157
  }
148
158
  ],
149
159
  "plugins": {
@@ -152,11 +162,17 @@
152
162
  }
153
163
  }
154
164
  },
165
+ "encryptedNative": [
166
+ "password"
167
+ ],
168
+ "protectedNative": [
169
+ "password"
170
+ ],
155
171
  "native": {
156
172
  "port": 1883,
157
173
  "bind": "0.0.0.0",
158
174
  "user": "",
159
- "pass": "",
175
+ "password": "",
160
176
  "timeout": 300,
161
177
  "TELE_SENSOR": true,
162
178
  "TELE_STATE": false,
package/lib/datapoints.js CHANGED
@@ -6,6 +6,7 @@ module.exports = {
6
6
  A2: {type: 'number', role: 'value', read: true, write: false},
7
7
  A3: {type: 'number', role: 'value', read: true, write: false},
8
8
  ANALOG: {type: 'object', role: 'state', read: true, write: false},
9
+ Ap: {type: 'number', role: 'value', read: true, write: false},
9
10
  APMac: {type: 'number', role: 'state', read: true, write: false},
10
11
  Action: {type: 'string', role: 'value', read: true, write: true},
11
12
  AirQuality: {type: 'number', role: 'value', read: true, write: false, unit: '%'},
@@ -53,7 +54,7 @@ module.exports = {
53
54
  Green: {type: 'number', role: 'level.color.green', read: true, write: true, min: 0, max: 100},
54
55
  HSBColor: {type: 'string', role: 'value.hsb', read: true, write: true},
55
56
  Hostname: {type: 'string', role: 'state', read: true, write: false},
56
- Hue: {type: 'number', role: 'level.color.hue', read: true, write: true, min: 0}, // max ??
57
+ Hue: {type: 'number', role: 'level.color.hue', read: true, write: true, min: 0, max: 360},
57
58
  Humidity: {type: 'number', role: 'value.humidity', read: true, write: false, unit: '%'},
58
59
  IPAddress: {type: 'string', role: 'state', read: true, write: false},
59
60
  IPaddress: {type: 'string', role: 'state', read: true, write: false},
@@ -68,12 +69,28 @@ module.exports = {
68
69
  Leistung: {type: 'number', role: 'value.power.consumption', read: true, write: false, unit: 'W'},
69
70
  Light: {type: 'number', role: 'value', read: true, write: false, unit: 'lx'},
70
71
  Longitude: {type: 'number', role: 'value.gps.longitude', read: true, write: false, unit: '°'},
71
- Mode: {type: 'number', role: 'value', read: true, write: true},
72
+ Mode: {type: 'string', role: 'state', read: true, write: true},
72
73
  Module: {type: 'string', role: 'state', read: true, write: false},
73
74
  Noise: {type: 'number', role: 'value', read: true, write: false, unit: 'dB'},
74
75
  Output: {type: 'number', role: 'value', read: true, write: true},
75
76
  Outsidetemp: {type: 'number', role: 'value.temperature', read: true, write: false, unit: '°C'},
76
77
  PM10: {type: 'number', role: 'value', read: true, write: false, unit: 'ug/m3'},
78
+ PWM1: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
79
+ PWM2: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
80
+ PWM3: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
81
+ PWM4: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
82
+ PWM5: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
83
+ PWM6: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
84
+ PWM7: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
85
+ PWM8: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
86
+ PWM9: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
87
+ PWM10: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
88
+ PWM11: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
89
+ PWM12: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
90
+ PWM13: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
91
+ PWM14: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
92
+ PWM15: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
93
+ PWM16: {type: 'number', role: 'value', read: true, write: true, min: 0, max: 1023},
77
94
  POWER10: {type: 'boolean', role: 'switch', read: true, write: true, storeMap: true},
78
95
  POWER11: {type: 'boolean', role: 'switch', read: true, write: true, storeMap: true},
79
96
  POWER12: {type: 'boolean', role: 'switch', read: true, write: true, storeMap: true},
@@ -123,7 +140,7 @@ module.exports = {
123
140
  SHUTTER3: {type: 'number', role: 'state', read: true, write: false},
124
141
  SHUTTER4: {type: 'number', role: 'state', read: true, write: false},
125
142
  SSId: {type: 'string', role: 'state', read: true, write: false},
126
- Saturation: {type: 'number', role: 'level.color.saturation', read: true, write: true, min: 0}, // max: 100 ??
143
+ Saturation: {type: 'number', role: 'level.color.saturation', read: true, write: true, min: 0, max: 255},
127
144
  Scheme: {type: 'number', role: 'value', read: true, write: true},
128
145
  SeaPressure: {type: 'number', role: 'value.pressure', read: true, write: false, unit: 'hPa'},
129
146
  SleepMode: {type: 'string', role: 'state', read: true, write: false},
@@ -176,7 +193,6 @@ module.exports = {
176
193
  WW_POWER: {type: 'boolean', role: 'switch.light', read: true, write: true, storeMap: true},
177
194
  Wakeup: {type: 'string', role: 'state', read: true, write: true},
178
195
  Warmwater: {type: 'number', role: 'value.temperature', read: true, write: false, unit: '°C'},
179
- Wifi_SSId: {type: 'string', role: 'state', read: true, write: true},
180
196
  Window: {type: 'number', role: 'value', read: true, write: true},
181
197
  Yesterday: {type: 'number', role: 'value.power.consumption', read: true, write: false, unit: 'kWh'},
182
198
  eCO2: {type: 'number', role: 'value.eco2', read: true, write: false, unit: 'ppm'},
package/lib/server.js CHANGED
@@ -3,10 +3,10 @@
3
3
  const mqtt = require('mqtt-connection');
4
4
  const net = require('net');
5
5
  const types = require('./datapoints');
6
- //const memwatch = require('memwatch-next');
7
- //const heapdump = require('heapdump');
6
+ // const memwatch = require('memwatch-next');
7
+ // const heapdump = require('heapdump');
8
8
  const hueCalc = true;
9
- //var heapTest = 0;
9
+ // var heapTest = 0;
10
10
  const FORBIDDEN_CHARS = /[\]\[*,;'"`<>\\?]/g;
11
11
  const mappingClients = {};
12
12
 
@@ -218,7 +218,7 @@ function MQTTServer(adapter) {
218
218
  }
219
219
 
220
220
  function _setState(id, val, callback) {
221
- adapter.log.debug(`Set State after task: ${id}`);
221
+ adapter.log.debug(`Set state after task: ${id}`);
222
222
  adapter.setForeignState(id, val, true, callback);
223
223
  }
224
224
 
@@ -236,7 +236,7 @@ function MQTTServer(adapter) {
236
236
  if (callback) {
237
237
  taskCallbacks.push(callback);
238
238
  }
239
- adapter.log.debug(`updateState ${task.id} - ${tasks.length}`);
239
+ adapter.log.debug(`Update state ${task.id} - ${tasks.length}`);
240
240
  if (tasks.length === 1) {
241
241
  processTasks();
242
242
  }
@@ -276,9 +276,9 @@ function MQTTServer(adapter) {
276
276
  // set white to rgb or rgbww
277
277
  adapter.getObject(id, (err, obj) => {
278
278
  if (!obj) {
279
- adapter.log.warn(`invalid rgbww obj for ${id}`);
279
+ adapter.log.warn(`Invalid rgbww obj for ${id}`);
280
280
  } else if (typeof state.val !== 'string') {
281
- adapter.log.warn(`invalid rgbww state value for ${id} : ${JSON.stringify(state.val)} needs to be a string`);
281
+ adapter.log.warn(`Invalid rgbww state value for ${id} : ${JSON.stringify(state.val)} needs to be a string`);
282
282
  } else {
283
283
  const role = obj.common.role;
284
284
  let color;
@@ -380,7 +380,7 @@ function MQTTServer(adapter) {
380
380
  const idAlive = `${deviceDesc}.Color`;
381
381
  adapter.getForeignState(idAlive, (err, state) => {
382
382
  if (!state || typeof state.val !== 'string') {
383
- adapter.log.info(`invalid state Color for ${idAlive}, correcting value to #000000`);
383
+ adapter.log.info(`Invalid state color for ${idAlive}, correcting value to #000000`);
384
384
  adapter.setState(idAlive, '#000000', false);
385
385
  return;
386
386
  }
@@ -475,7 +475,7 @@ function MQTTServer(adapter) {
475
475
  adapter.getForeignObject(idAlive, (err, obj) => {
476
476
  if (!obj) {
477
477
  // no color object
478
- adapter.log.warn(`unknown object: ${id}: ${state}`);
478
+ adapter.log.warn(`Unknown object: ${id}: ${state}`);
479
479
  } else {
480
480
  const role = obj.common.role;
481
481
  //if (role='level.color.rgb') return;
@@ -492,7 +492,7 @@ function MQTTServer(adapter) {
492
492
  const idAlive = `${deviceDesc}.Color`;
493
493
  adapter.getForeignState(idAlive, (err, state) => {
494
494
  if (!state) {
495
- adapter.log.warn('ill state Color');
495
+ adapter.log.warn('ill state color');
496
496
  return;
497
497
  }
498
498
  const color = state.val.substring(1);
@@ -527,7 +527,7 @@ function MQTTServer(adapter) {
527
527
  const idAlive = `${deviceDesc}.Color`;
528
528
  adapter.getForeignState(idAlive, (err, state) => {
529
529
  if (!state) {
530
- adapter.log.warn('ill state Color');
530
+ adapter.log.warn('ill state color');
531
531
  return;
532
532
  }
533
533
  const color = state.val.substring(1);
@@ -608,7 +608,7 @@ function MQTTServer(adapter) {
608
608
  // other objects
609
609
  adapter.getObject(id, (err, obj) => {
610
610
  if (!obj) {
611
- adapter.log.warn(`invalid obj ${id}`);
611
+ adapter.log.warn(`Invalid object ${id}`);
612
612
  } else {
613
613
  const type = obj.common.type;
614
614
  switch (type) {
@@ -675,11 +675,15 @@ function MQTTServer(adapter) {
675
675
  cacheAddedObjects[task.id] = true;
676
676
  adapter.getForeignObject(task.id, (err, obj) => {
677
677
  if (!obj || !obj.common) {
678
+ if (task.data.common.storeMap) {
679
+ task.data = JSON.parse(JSON.stringify(task.data)); // copy
680
+ delete task.data.common.storeMap;
681
+ }
678
682
  adapter.setForeignObject(task.id, task.data, (err) => {
679
683
  if (err) {
680
- adapter.log.warn(`New Object creation error: ${err.message}`)
684
+ adapter.log.warn(`New object creation error: ${err.message}`)
681
685
  } else {
682
- adapter.log.info(`new object created: ${task.id}`);
686
+ adapter.log.info(`New object created: ${task.id}`);
683
687
  }
684
688
  if (task.cb) {
685
689
  task.cb(task.id, task.cbArg, () => {
@@ -691,8 +695,12 @@ function MQTTServer(adapter) {
691
695
  setImmediate(processTasks);
692
696
  }
693
697
  });
694
- } else if (obj.common.type !== task.data.common.type) {
695
- adapter.extendObject(task.id, {common: {type: task.data.common.type}}, err => {
698
+ } else if (obj.common.type !== task.data.common.type || obj.common.storeMap !== undefined) {
699
+ obj.common.type = task.data.common.type;
700
+ if (obj.common.storeMap !== undefined) {
701
+ delete obj.common.storeMap;
702
+ }
703
+ adapter.setForeignObject(task.id, obj, err => {
696
704
  if (err) {
697
705
  adapter.log.warn(`Object update error: ${err.message}`)
698
706
  } else {
@@ -848,12 +856,12 @@ function MQTTServer(adapter) {
848
856
  try {
849
857
  messages[i].ts = Date.now();
850
858
  messages[i].count++;
851
- adapter.log.debug(`Client [${client.id}] Resend messages on connect: ${messages[i].topic} = ${messages[i].payload}`);
859
+ adapter.log.debug(`Client [${client.id}] resend messages on connect: ${messages[i].topic} = ${messages[i].payload}`);
852
860
  if (messages[i].cmd === 'publish') {
853
861
  client.publish(messages[i]);
854
862
  }
855
863
  } catch (e) {
856
- adapter.log.warn(`Client [${client.id}] Cannot resend message: ${e}`);
864
+ adapter.log.warn(`Client [${client.id}] cannot resend message: ${e}`);
857
865
  }
858
866
 
859
867
  if (adapter.config.sendInterval) {
@@ -1128,7 +1136,7 @@ function MQTTServer(adapter) {
1128
1136
  updateState(obj, val);
1129
1137
 
1130
1138
  if (powerStateFound) {
1131
- adapter.log.debug(`Got .STATE.POWER value message -> auto add .POWER object from ${obj.id}`);
1139
+ adapter.log.debug(`Got .STATE.POWER value message ==> auto add .POWER object from ${obj.id}`);
1132
1140
  let powerId = obj.id.replace('.STATE.POWER', '.POWER');
1133
1141
  let powerName = obj.data.common.name.replace(' STATE POWER', ' POWER');
1134
1142
  let powerObj = Object.assign({}, obj);
@@ -1162,7 +1170,7 @@ function MQTTServer(adapter) {
1162
1170
  }
1163
1171
 
1164
1172
  let val = packet.payload.toString('utf8');
1165
- adapter.log.debug(`[${client.id}] Received: ${packet.topic} = ${val}`);
1173
+ adapter.log.debug(`Client [${client.id}] received: ${packet.topic} = ${val}`);
1166
1174
 
1167
1175
  /*
1168
1176
  adapter.getForeignState('system.adapter.sonoff.0.memRss', (err, state) => {
@@ -1238,7 +1246,7 @@ function MQTTServer(adapter) {
1238
1246
  checkData(client, packet.topic, NO_PREFIX, JSON.parse(val));
1239
1247
  }
1240
1248
  } catch (e) {
1241
- adapter.log.warn(`Cannot parse data "${stateId}": _${val}_ - ${e}`);
1249
+ adapter.log.warn(`Client [${client.id}] cannot parse data "${stateId}": _${val}_ - ${e}`);
1242
1250
  }
1243
1251
  }
1244
1252
  return;
@@ -1265,7 +1273,7 @@ function MQTTServer(adapter) {
1265
1273
  //adapter.log.warn('log sensor parse"' + stateId + '": _' + val);
1266
1274
  }
1267
1275
  } catch (e) {
1268
- adapter.log.warn(`Cannot parse data "${stateId}": _${val}_ - ${e}`);
1276
+ adapter.log.warn(`Client [${client.id}] cannot parse data"${stateId}": _${val}_ - ${e}`);
1269
1277
  }
1270
1278
  } else if (parts[0] === 'tele' && stateId.match(/^INFO\d?$/)) {
1271
1279
  // tele/SonoffPOW/INFO1 = {"Module":"Sonoff Pow", "Version":"5.8.0", "FallbackTopic":"SonoffPOW", "GroupTopic":"sonoffs"}
@@ -1274,14 +1282,14 @@ function MQTTServer(adapter) {
1274
1282
  try {
1275
1283
  checkData(client, packet.topic, 'INFO', JSON.parse(val));
1276
1284
  } catch (e) {
1277
- adapter.log.warn(`Cannot parse data"${stateId}": _${val}_ - ${e}`);
1285
+ adapter.log.warn(`Client [${client.id}] cannot parse data"${stateId}": _${val}_ - ${e}`);
1278
1286
  }
1279
1287
  } else if (parts[0] === 'tele' && stateId.match(/^(ENERGY)\d?$/)) {
1280
1288
  // tele/sonoff_4ch/ENERGY = {"Time":"2017-10-02T19:24:32", "Total":1.753, "Yesterday":0.308, "Today":0.205, "Period":0, "Power":3, "Factor":0.12, "Voltage":221, "Current":0.097}
1281
1289
  try {
1282
1290
  checkData(client, packet.topic, 'ENERGY', JSON.parse(val));
1283
1291
  } catch (e) {
1284
- adapter.log.warn(`Cannot parse data"${stateId}": _${val}_ - ${e}`);
1292
+ adapter.log.warn(`Client [${client.id}] cannot parse data"${stateId}": _${val}_ - ${e}`);
1285
1293
  }
1286
1294
  } else if (types[stateId]) {
1287
1295
  // /ESP_BOX/BM280/Pressure = 1010.09
@@ -1372,7 +1380,7 @@ function MQTTServer(adapter) {
1372
1380
  client.destroy();
1373
1381
  }
1374
1382
  } catch (e) {
1375
- adapter.log.warn(`Client [${client.id}] Cannot close client: ${e}`);
1383
+ adapter.log.warn(`Client [${client.id}] cannot close client: ${e}`);
1376
1384
  }
1377
1385
  }
1378
1386
 
@@ -1385,7 +1393,7 @@ function MQTTServer(adapter) {
1385
1393
  const message = clients[clientId]._messages[m];
1386
1394
  if (now - message.ts >= adapter.config.retransmitInterval) {
1387
1395
  if (message.count > adapter.config.retransmitCount) {
1388
- adapter.log.warn(`Client [${clientId}] Message ${message.messageId} deleted after ${message.count} retries`);
1396
+ adapter.log.warn(`Client [${clientId}] message ${message.messageId} deleted after ${message.count} retries`);
1389
1397
  clients[clientId]._messages.splice(m, 1);
1390
1398
  continue;
1391
1399
  }
@@ -1394,12 +1402,12 @@ function MQTTServer(adapter) {
1394
1402
  message.count++;
1395
1403
  message.ts = now;
1396
1404
  try {
1397
- adapter.log.debug(`Client [${clientId}] Resend message topic: ${message.topic}, payload: ${message.payload}`);
1405
+ adapter.log.debug(`Client [${clientId}] resend message topic: ${message.topic}, payload: ${message.payload}`);
1398
1406
  if (message.cmd === 'publish') {
1399
1407
  clients[clientId].publish(message);
1400
1408
  }
1401
1409
  } catch (e) {
1402
- adapter.log.warn(`Client [${clientId}] Cannot publish message: ${e}`);
1410
+ adapter.log.warn(`Client [${clientId}] cannot publish message: ${e}`);
1403
1411
  }
1404
1412
 
1405
1413
  if (adapter.config.sendInterval) {
@@ -1454,7 +1462,7 @@ function MQTTServer(adapter) {
1454
1462
  options.password = options.password.toString();
1455
1463
  }
1456
1464
  if (config.user !== options.username ||
1457
- config.pass !== options.password) {
1465
+ config.password !== options.password) {
1458
1466
  adapter.log.warn(`Client [${client.id}] has invalid password or username`);
1459
1467
  client.connack({returnCode: 4});
1460
1468
  if (oldClient) {
@@ -1470,7 +1478,7 @@ function MQTTServer(adapter) {
1470
1478
  }
1471
1479
 
1472
1480
  if (oldClient) {
1473
- adapter.log.info(`Client [${client.id}] reconnected. Old secret ${clients[client.id].__secret}. New secret ${client.__secret}`);
1481
+ adapter.log.info(`Client [${client.id}] reconnected. Old secret ${clients[client.id].__secret} ==> New secret ${client.__secret}`);
1474
1482
  // need to destroy the old client
1475
1483
 
1476
1484
  if (client.__secret !== clients[client.id].__secret) {
@@ -1556,7 +1564,7 @@ function MQTTServer(adapter) {
1556
1564
  const pack = client._messages && client._messages.find(e => e.messageId === packet.messageId);
1557
1565
  if (pack) {
1558
1566
  // duplicate message => ignore
1559
- adapter.log.warn(`Client [${client.id}] Ignored duplicate message with ID: ${packet.messageId}`);
1567
+ adapter.log.warn(`Client [${client.id}] ignored duplicate message with ID: ${packet.messageId}`);
1560
1568
  return;
1561
1569
  } else {
1562
1570
  packet.ts = Date.now();
@@ -1595,7 +1603,7 @@ function MQTTServer(adapter) {
1595
1603
  if (pos !== null) {
1596
1604
  client.pubrel({messageId: packet.messageId});
1597
1605
  } else {
1598
- adapter.log.warn(`Client [${client.id}] Received pubrec on ${client.id} for unknown messageId ${packet.messageId}`);
1606
+ adapter.log.warn(`Client [${client.id}] received pubrec on ${client.id} for unknown message ID: ${packet.messageId}`);
1599
1607
  }
1600
1608
  });
1601
1609
 
@@ -1621,7 +1629,7 @@ function MQTTServer(adapter) {
1621
1629
  if (pos !== null) {
1622
1630
  client._messages.splice(pos, 1);
1623
1631
  } else {
1624
- adapter.log.warn(`Client [${client.id}] Received pubcomp for unknown message ID: ${packet.messageId}`);
1632
+ adapter.log.warn(`Client [${client.id}] received pubcomp for unknown message ID: ${packet.messageId}`);
1625
1633
  }
1626
1634
  });
1627
1635
 
@@ -1652,8 +1660,9 @@ function MQTTServer(adapter) {
1652
1660
  client.pubcomp({messageId: packet.messageId});
1653
1661
 
1654
1662
  receivedTopic(client._messages[pos], client);
1663
+ client._messages && client._messages.splice(pos, 1);
1655
1664
  } else {
1656
- adapter.log.warn(`Client [${client.id}] Received pubrel on ${client.id} for unknown messageId ${packet.messageId}`);
1665
+ adapter.log.warn(`Client [${client.id}] received pubrel on ${client.id} for unknown messageId ${packet.messageId}`);
1657
1666
  }
1658
1667
  });
1659
1668
 
@@ -1679,10 +1688,10 @@ function MQTTServer(adapter) {
1679
1688
  });
1680
1689
 
1681
1690
  if (pos !== null) {
1682
- adapter.log.debug(`Client [${client.id}] Received puback for ${client.id} message ID: ${packet.messageId}`);
1691
+ adapter.log.debug(`Client [${client.id}] received puback for ${client.id} message ID: ${packet.messageId}`);
1683
1692
  client._messages && client._messages.splice(pos, 1);
1684
1693
  } else {
1685
- adapter.log.warn(`Client [${client.id}] Received puback for unknown message ID: ${packet.messageId}`);
1694
+ adapter.log.warn(`Client [${client.id}] received puback for unknown message ID: ${packet.messageId}`);
1686
1695
  }
1687
1696
  });
1688
1697
 
@@ -1731,9 +1740,8 @@ function MQTTServer(adapter) {
1731
1740
  });
1732
1741
  });
1733
1742
 
1734
- server.on('error', err => {
1735
- adapter.log.error(`Can not start Server ${err}`);
1736
- });
1743
+ server.on('error', err =>
1744
+ adapter.log.error(`Can not start Server ${err}`));
1737
1745
 
1738
1746
  config.port = parseInt(config.port, 10) || 1883;
1739
1747
 
package/main.js CHANGED
@@ -25,23 +25,36 @@ function decrypt(key, value) {
25
25
 
26
26
  function startAdapter(options) {
27
27
  options = options || {};
28
- Object.assign(options, {name: adapterName});
28
+ Object.assign(options, { name: adapterName });
29
29
 
30
30
  adapter = new utils.Adapter(options);
31
31
 
32
32
  adapter.on('ready', () => {
33
- // it must be like this
34
-
35
- adapter.getForeignObject('system.config', (err, obj) => {
36
- if (obj && obj.native && obj.native.secret) {
37
- //noinspection JSUnresolvedVariable
38
- adapter.config.pass = decrypt(obj.native.secret, adapter.config.pass);
39
- } else {
40
- //noinspection JSUnresolvedVariable
41
- adapter.config.pass = decrypt('Zgfr56gFe87jJOM', adapter.config.pass);
42
- }
33
+ // delete pass if a password set
34
+ if (adapter.config.password && adapter.config.pass) {
35
+ // delete adapter.config.pass
36
+ adapter.getForeignObject(`system.adapter.${adapter.namespace}`, (err, config) => {
37
+ delete config.native.pass;
38
+ adapter.setForeignObject(config._id, config);
39
+ });
40
+ } else if (!adapter.config.password && adapter.config.pass) {
41
+ // migrate
42
+ adapter.getForeignObject('system.config', (err, systemConfig) => {
43
+ adapter.getForeignObject(`system.adapter.${adapter.namespace}`, (err, config) => {
44
+ if (systemConfig && systemConfig.native && systemConfig.native.secret) {
45
+ // noinspection JSUnresolvedVariable
46
+ config.native.password = decrypt(systemConfig.native.secret, adapter.config.pass);
47
+ } else {
48
+ // noinspection JSUnresolvedVariable
49
+ config.native.password = decrypt('Zgfr56gFe87jJOM', adapter.config.pass);
50
+ }
51
+ delete config.native.pass;
52
+ adapter.setForeignObject(config._id, config);
53
+ });
54
+ });
55
+ } else {
43
56
  main();
44
- });
57
+ }
45
58
  });
46
59
 
47
60
  adapter.on('unload', cb => {
@@ -53,7 +66,7 @@ function startAdapter(options) {
53
66
  }
54
67
  });
55
68
 
56
- // is called if a subscribed state changes
69
+ // called if the subscribed state changes itself
57
70
  adapter.on('stateChange', (id, state) => {
58
71
  adapter.log.debug(`stateChange ${id}: ${JSON.stringify(state)}`);
59
72
  // you can use the ack flag to detect if state is desired or acknowledged
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "iobroker.sonoff",
3
3
  "description": "The adapter allows to send and receive MQTT messages from ioBroker and to be a broker.",
4
- "version": "2.5.7",
4
+ "version": "3.1.0",
5
5
  "author": "bluefox <dogafox@gmail.com>",
6
6
  "homepage": "https://github.com/ioBroker/ioBroker.sonoff",
7
7
  "repository": {
@@ -17,18 +17,17 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "mqtt-connection": "^4.1.0",
20
- "@iobroker/adapter-core": "^2.6.8"
20
+ "@iobroker/adapter-core": "^3.1.4"
21
21
  },
22
22
  "devDependencies": {
23
- "@alcalzone/release-script": "^3.6.0",
24
- "@alcalzone/release-script-plugin-iobroker": "^3.6.0",
25
- "@alcalzone/release-script-plugin-license": "^3.5.9",
26
- "@iobroker/legacy-testing": "^0.3.6",
27
- "axios": "^1.4.0",
28
- "mqtt": "^4.3.7",
29
- "gulp": "^4.0.2",
30
- "mocha": "^10.2.0",
31
- "chai": "^4.3.7"
23
+ "@alcalzone/release-script": "^3.7.0",
24
+ "@alcalzone/release-script-plugin-iobroker": "^3.7.0",
25
+ "@alcalzone/release-script-plugin-license": "^3.7.0",
26
+ "@iobroker/adapter-dev": "^1.3.0",
27
+ "@iobroker/legacy-testing": "^1.0.12",
28
+ "mqtt": "^4.3.8",
29
+ "mocha": "^10.4.0",
30
+ "chai": "^4.4.1"
32
31
  },
33
32
  "bugs": {
34
33
  "url": "https://github.com/ioBroker/ioBroker.sonoff/issues"
@@ -47,10 +46,11 @@
47
46
  "release-patch": "release-script patch --yes",
48
47
  "release-minor": "release-script minor --yes",
49
48
  "release-major": "release-script major --yes",
50
- "update-packages": "ncu --upgrade"
49
+ "update-packages": "ncu --upgrade",
50
+ "translate": "translate-adapter"
51
51
  },
52
52
  "engines": {
53
- "node": ">=4.0.0"
53
+ "node": ">=18.0.0"
54
54
  },
55
55
  "license": "MIT"
56
56
  }