iobroker.yamaha 0.5.0 → 0.5.3

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.
@@ -50,7 +50,7 @@ jobs:
50
50
  runs-on: ${{ matrix.os }}
51
51
  strategy:
52
52
  matrix:
53
- node-version: [12.x, 14.x, 16.x]
53
+ node-version: [12.x, 14.x, 16.x, 18.x]
54
54
  os: [ubuntu-latest, windows-latest, macos-latest]
55
55
 
56
56
  steps:
package/README.md CHANGED
@@ -43,6 +43,16 @@ You have to enable "network standby" function in the configuration of your recei
43
43
 
44
44
 
45
45
  ## Changelog
46
+ ### 0.5.3 (2022-06-17)
47
+ * (Apollon77) Fix crash cases reported by Sentry
48
+
49
+ ### 0.5.2 (2022-04-23)
50
+ * (Apollon77) Fix crash cases reported by Sentry
51
+
52
+ ### 0.5.1 (2022-03-29)
53
+ * (Apollon77) Fix crash cases reported by Sentry
54
+ * (Sneak-L8) fix type of pureDirect
55
+
46
56
  ### 0.5.0 (2022-03-08)
47
57
  * IMPORTANT: js-controller 2.0 is needed at least
48
58
  * (Apollon77) Add Sentry for crash reporting
package/io-package.json CHANGED
@@ -1,8 +1,44 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "yamaha",
4
- "version": "0.5.0",
4
+ "version": "0.5.3",
5
5
  "news": {
6
+ "0.5.3": {
7
+ "en": "Fix crash cases reported by Sentry",
8
+ "de": "Reparieren Crashfälle gemeldet von Sentry",
9
+ "ru": "Исправление случаев аварии, описанных Sentry",
10
+ "pt": "Corrigir casos de acidente relatados por Sentry",
11
+ "nl": "Vertaling:",
12
+ "fr": "Troubles de crash signalés par Sentry",
13
+ "it": "Correzione dei casi di crash segnalati da Sentry",
14
+ "es": "Casos de accidente fijo reportados por Sentry",
15
+ "pl": "Sprawy katastrofy Fix podane przez Sentry’a",
16
+ "zh-cn": "Sentry所报告的六例事故"
17
+ },
18
+ "0.5.2": {
19
+ "en": "Fix crash cases reported by Sentry",
20
+ "de": "Von Sentry gemeldete Absturzfälle beheben",
21
+ "ru": "Исправить случаи сбоев, о которых сообщил Sentry",
22
+ "pt": "Corrigir casos de travamento relatados pelo Sentinela",
23
+ "nl": "Herstel crashgevallen gemeld door Sentry",
24
+ "fr": "Correction des cas de plantage signalés par Sentry",
25
+ "it": "Risolvi i casi di crash segnalati da Sentry",
26
+ "es": "Solucionar casos de fallas informados por Sentry",
27
+ "pl": "Napraw przypadki awarii zgłoszone przez Sentry",
28
+ "zh-cn": "修复 Sentry 报告的崩溃案例"
29
+ },
30
+ "0.5.1": {
31
+ "en": "Fix crash cases reported by Sentry\nfix type of pureDirect",
32
+ "de": "Von Sentry gemeldete Absturzfälle beheben\nfixer Typ von pureDirect",
33
+ "ru": "Исправить случаи сбоев, о которых сообщил Sentry\nисправить тип pureDirect",
34
+ "pt": "Corrigir casos de travamento relatados pelo Sentinela\ncorrigir tipo de pureDirect",
35
+ "nl": "Herstel crashgevallen gemeld door Sentry\nfix type pureDirect",
36
+ "fr": "Correction des cas de plantage signalés par Sentry\ncorrection du type de pureDirect",
37
+ "it": "Risolvi i casi di crash segnalati da Sentry\ncorreggere il tipo di pureDirect",
38
+ "es": "Solucionar casos de fallas informados por Sentry\ncorregir el tipo de pureDirect",
39
+ "pl": "Napraw przypadki awarii zgłoszone przez Sentry\nnapraw typ pureDirect",
40
+ "zh-cn": "修复 Sentry 报告的崩溃案例\n修复 pureDirect 的类型"
41
+ },
6
42
  "0.5.0": {
7
43
  "en": "IMPORTANT: js-controller 2.0 is needed at least\nAdd Sentry for crash reporting",
8
44
  "de": "WICHTIG: js-controller 2.0 wird mindestens benötigt\nFügen Sie Sentry für Absturzberichte hinzu",
@@ -50,42 +86,6 @@
50
86
  "es": "Se corrigió el bloqueo en lib / soef.js (Garfonso) \n meta información actualizada. (Garfonso)",
51
87
  "pl": "naprawiono awarię w lib / soef.js (Garfonso) \naktualizowano meta informacje. (Garfonso)",
52
88
  "zh-cn": "修复了lib / soef.js(Garfonso)\n更新的元信息中的崩溃。 (加方索)"
53
- },
54
- "0.3.19": {
55
- "en": "Changelog added to readme",
56
- "de": "Changelog der readme hinzugefügt",
57
- "ru": "Список изменений добавлен в readme",
58
- "pt": "Changelog adicionado ao leia-me",
59
- "nl": "Changelog toegevoegd aan readme",
60
- "fr": "Changelog ajouté au fichier readme",
61
- "it": "Changelog aggiunto al readme",
62
- "es": "Registro de cambios agregado a Léame",
63
- "pl": "Dziennik zmian dodany do readme",
64
- "zh-cn": "更改日志添加到自述文件"
65
- },
66
- "0.3.18": {
67
- "en": "Update utils.js and usage, CI Testing and deps (Apollon77)",
68
- "de": "utils.js und Benutzung erneuert, CI Testing (Apollon77)",
69
- "ru": "Обновите utils.js и использование, тестирование CI и deps (Apollon77)",
70
- "pt": "Atualize utils.js e uso, teste de CI e deps (Apollon77)",
71
- "nl": "Update utils.js en gebruik, CI-testen en deps (Apollon77)",
72
- "fr": "Mise à jour utils.js et utilisation, CI Testing et deps (Apollon77)",
73
- "it": "Aggiorna utils.js e utilizzo, test CI e deps (Apollon77)",
74
- "es": "Actualice utils.js y uso, pruebas de CI y dependencias (Apollon77)",
75
- "pl": "Zaktualizuj utils.js i wykorzystanie, CI Testing i deps (Apollon77)",
76
- "zh-cn": "更新 utils.js 和用法、CI 测试和 deps (Apollon77)"
77
- },
78
- "0.3.17": {
79
- "en": "update basic package-file testing (Apollon77)",
80
- "de": "Erweiterung der Tests (Apollon77)",
81
- "ru": "обновить базовое тестирование файла пакета (Apollon77)",
82
- "pt": "atualizar o teste básico de arquivo de pacote (Apollon77)",
83
- "nl": "update basispakketbestand testen (Apollon77)",
84
- "fr": "mise à jour des tests de base du fichier de package (Apollon77)",
85
- "it": "aggiornare il test di base del file di pacchetto (Apollon77)",
86
- "es": "actualizar las pruebas básicas de archivos de paquetes (Apollon77)",
87
- "pl": "aktualizacja podstawowego testowania plików pakietu (Apollon77)",
88
- "zh-cn": "更新基本包文件测试(Apollon77)"
89
89
  }
90
90
  },
91
91
  "title": "Yamaha",
@@ -605,11 +605,11 @@
605
605
  "type": "state",
606
606
  "common": {
607
607
  "name": "pureDirect",
608
- "type": "boolean",
608
+ "type": "string",
609
609
  "role": "state",
610
610
  "read": true,
611
611
  "write": true,
612
- "def": false,
612
+ "def": "not available",
613
613
  "desc": "Pure Direct"
614
614
  },
615
615
  "native": {}
package/lib/soef.js CHANGED
@@ -304,7 +304,7 @@ var njs = {
304
304
 
305
305
  function deld() {
306
306
  if (d >= devices.length) {
307
- callback();
307
+ callback && callback();
308
308
  return;
309
309
  }
310
310
  var did = devices[d++]._id;
@@ -597,7 +597,7 @@ function Devices (_adapter, _callback) {
597
597
  list = that.list;
598
598
  that.list = {};
599
599
  }
600
- if (!list) return callback(-1);
600
+ if (!list) return callback && callback(-1);
601
601
  if (Array.isArray(list)) {
602
602
  for (var i=0; i<list.length; i++) {
603
603
  var objName = Object.keys( list[i] )[ 0 ];
@@ -665,7 +665,7 @@ function Devices (_adapter, _callback) {
665
665
 
666
666
  this.readAllExistingObjects = function (callback) {
667
667
  adapter.getForeignStates(adapter.namespace + '.*', {}, function(err, states) {
668
- if (err || !states) return callback(-1);
668
+ if (err || !states) return callback && callback(-1);
669
669
  var namespacelen = adapter.namespace.length + 1;
670
670
  for (var fullId in states) {
671
671
  var id = fullId.substr(namespacelen),
@@ -1013,14 +1013,14 @@ function checkIfUpdated(doUpdateCallback, callback) {
1013
1013
  if (typeof doUpdateCallback == 'function') {
1014
1014
  doUpdateCallback(prevVersion, aktVersion, function (err) {
1015
1015
  savePrevVersion();
1016
- callback();
1016
+ callback && callback();
1017
1017
  });
1018
1018
  return;
1019
1019
  } else {
1020
1020
  savePrevVersion();
1021
1021
  }
1022
1022
  }
1023
- callback();
1023
+ callback && callback();
1024
1024
  });
1025
1025
  }
1026
1026
 
@@ -1063,7 +1063,7 @@ function _main (_adapter, options, callback ) {
1063
1063
 
1064
1064
  switchToDebug();
1065
1065
  _devices.init(_adapter, function(err) {
1066
- callback();
1066
+ callback && callback();
1067
1067
  });
1068
1068
  };
1069
1069
  exports.main = _main;
@@ -1093,9 +1093,9 @@ exports.Adapter = function (_args) {
1093
1093
  if (!options.unload) {
1094
1094
  options.unload = function (callback) {
1095
1095
  try {
1096
- fns.onUnload ? onUnload(calback) : callback();
1096
+ fns.onUnload ? onUnload(callback) : callback && callback();
1097
1097
  } catch (e) {
1098
- callback();
1098
+ callback && callback();
1099
1099
  }
1100
1100
  }
1101
1101
  }
@@ -1147,7 +1147,7 @@ function changeAdapterConfig (_adapter, changeCallback, doneCallback) {
1147
1147
  if (!err && obj && !obj.native) obj['native'] = {};
1148
1148
  if (!err && obj && changeCallback(obj.native) !== false) {
1149
1149
  _adapter.setForeignObject(obj._id, obj, {}, function (err, s_obj) {
1150
- _adapter.log.info("soef.changeAdapterConfig: changed");
1150
+ _adapter.log.debug("soef.changeAdapterConfig: changed");
1151
1151
  //_adapter.config = obj.native; //?!? nrmalisieren fehlt dann!!
1152
1152
  //_adapter.normalizeConfig ...
1153
1153
  if (doneCallback) doneCallback(err, obj);
package/main.js CHANGED
@@ -79,7 +79,7 @@ if (!YAMAHA.prototype.sendCommand) {
79
79
 
80
80
  YAMAHA.prototype.sendCommand = function (command, zone) {
81
81
  zone = getZone(zone);
82
- var command = '<YAMAHA_AV cmd="PUT"><' + zone + '>' + command + '</' + zone + '></YAMAHA_AV>';
82
+ var command = `<YAMAHA_AV cmd="PUT"><${zone}>${command}</${zone}></YAMAHA_AV>`;
83
83
  return this.SendXMLToReceiver(command);
84
84
  };
85
85
 
@@ -97,7 +97,7 @@ if (!YAMAHA.prototype.sendCommand) {
97
97
  //var command = '<YAMAHA_AV cmd="PUT"><System><Misc><Remote_Signal><Receive><Code>' + code + '</Code></Receive></Remote_Signal></Misc></System></YAMAHA_AV>';
98
98
  //var command = '<YAMAHA_AV cmd="PUT"><System><Remote_Signal><Receive><Code>' + code + '</Code></Receive></Remote_Signal></System></YAMAHA_AV>';
99
99
 
100
- var command = '<YAMAHA_AV cmd="PUT"><System><Remote_Control><RC_Code>' + code + '</RC_Code></Remote_Control></System></YAMAHA_AV>';
100
+ var command = `<YAMAHA_AV cmd="PUT"><System><Remote_Control><RC_Code>${code}</RC_Code></Remote_Control></System></YAMAHA_AV>`;
101
101
  return this.SendXMLToReceiver(command);
102
102
  };
103
103
 
@@ -105,11 +105,11 @@ if (!YAMAHA.prototype.sendCommand) {
105
105
  return this.sendCommand('<Sound_Video><Pure_Direct><Mode>' + (bo ? 'On' : 'Off') + '</Mode></Pure_Direct></Sound_Video>');
106
106
  };
107
107
  YAMAHA.prototype.setHDMIOutput = function (no, bo) {
108
- return this.sendCommand('<Sound_Video><HDMI><Output><OUT_' + no + '>' + (bo ? 'On' : 'Off') + '</OUT_' + no + '></Output></HDMI></Sound_Video>', 'System');
108
+ return this.sendCommand(`<Sound_Video><HDMI><Output><OUT_${no}>${bo ? 'On' : 'Off'}</OUT_${no}></Output></HDMI></Sound_Video>`, 'System');
109
109
  };
110
110
  YAMAHA.prototype.scene = function (no) {
111
111
  adapter.setState('scene', '', true);
112
- return this.sendCommand('<Scene><Scene_Load>Scene ' + no + '</Scene_Load></Scene>');
112
+ return this.sendCommand(`<Scene><Scene_Load>Scene ${no}</Scene_Load></Scene>`);
113
113
  };
114
114
  YAMAHA.prototype.power = function (bo, zone) {
115
115
  return this.sendCommand('<Power_Control><Power>' + (bo ? 'On' : 'Standby') + '</Power></Power_Control>', zone);
@@ -124,7 +124,7 @@ if (!YAMAHA.prototype.sendCommand) {
124
124
  else if (val < 90) val = '60 min';
125
125
  else if (val < 120) val = '90 min';
126
126
  else val = '120 min';
127
- return this.sendCommand('<Power_Control><Sleep>' + val + '</Sleep></Power_Control>', zone);
127
+ return this.sendCommand(`<Power_Control><Sleep>${val}</Sleep></Power_Control>`, zone);
128
128
  };
129
129
 
130
130
  }
@@ -132,7 +132,7 @@ if (!YAMAHA.prototype.sendCommand) {
132
132
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
133
133
 
134
134
  YAMAHA.prototype.setSurround = function (val) {
135
- return this.sendCommand('<Surround><Program_Sel><Current><Sound_Program>' + val + '</Sound_Program></Current></Program_Sel></Surround>', zone);
135
+ return this.sendCommand(`<Surround><Program_Sel><Current><Sound_Program>${val}</Sound_Program></Current></Program_Sel></Surround>`, zone);
136
136
  };
137
137
 
138
138
  YAMAHA.prototype.YPAOVolume = function(bo){
@@ -162,7 +162,7 @@ YAMAHA.prototype.toggleMute = function () {
162
162
  if (obj && typeof obj.val == 'boolean') {
163
163
  this.setMute(! obj.val);
164
164
  } else {
165
- adapter.log.warn("unknown mute value: " + obj.val);
165
+ adapter.log.warn(`unknown mute value: ${obj.val}`);
166
166
  }
167
167
  };
168
168
 
@@ -269,13 +269,13 @@ var defaultParams = {
269
269
  return (this.val === 'true') || !!(this.val >> 0);
270
270
  },
271
271
  get szVal() {
272
- return this.val.toString ();
272
+ return this.val === null ? '': this.val.toString();
273
273
  },
274
274
  get zone() {
275
275
  return zone;
276
276
  },
277
277
  result: function(idx) {
278
- return this [idx] !== undefined ? this [idx] : idx;
278
+ return this [idx] !== undefined ? this[idx] : idx;
279
279
  }
280
280
  };
281
281
 
@@ -288,7 +288,7 @@ YAMAHA.prototype.execCommand = function (id, val) {
288
288
  var p = defaultParams;
289
289
  p.val = val;
290
290
 
291
- adapter.log.debug('execCommand: id=' + id + ' val=' + val);
291
+ adapter.log.debug(`execCommand: id=${id} val=${val}`);
292
292
  var commandName = ar[2];
293
293
 
294
294
  switch(commandName) {
@@ -311,7 +311,7 @@ YAMAHA.prototype.execCommand = function (id, val) {
311
311
  case 'raw': cmd = p.szVal; break;
312
312
  default:
313
313
  var szVal = p.szVal;
314
- if (ar[4] === 'VOL' && szVal !== '?' && szVal.indexOf('.') < 0 && szVal.length < 4) szVal = szVal + '.0';
314
+ if (ar[4] === 'VOL' && szVal !== '?' && szVal.indexOf('.') < 0 && szVal.length < 4) szVal = `${szVal}.0`;
315
315
  cmd = soef.sprintf('@%s:%s=%s', ar[3], ar[4], szVal);
316
316
  break;
317
317
  }
@@ -331,12 +331,20 @@ YAMAHA.prototype.execCommand = function (id, val) {
331
331
  if (p.bo) refreshStates();
332
332
  break;
333
333
  case "command":
334
+ if (typeof val !== 'string') {
335
+ adapter.log.warn(`command: val ${val}is not a string`);
336
+ return;
337
+ }
334
338
  var a = p.val.split(' ');
335
- this.execCommand(adapter.namespace + "." + "commands" + "." + a[0], a.length > 1 ? a[1] : false);
339
+ this.execCommand(`${adapter.namespace}.commands.${a[0]}`, a.length > 1 ? a[1] : false);
336
340
  break;
337
341
  case "xmlCommand":
342
+ if (typeof val !== 'string') {
343
+ adapter.log.warn(`xmlCommand: val ${val}is not a string`);
344
+ return;
345
+ }
338
346
  val = val.replace(/\[/g, "<").replace(/]/g, ">");
339
- var command = '<YAMAHA_AV cmd="PUT">' + val + '</YAMAHA_AV>';
347
+ var command = `<YAMAHA_AV cmd="PUT">${val}</YAMAHA_AV>`;
340
348
  return this.SendXMLToReceiver(command);
341
349
  case "zone":
342
350
  zone = val;
@@ -352,14 +360,12 @@ YAMAHA.prototype.execCommand = function (id, val) {
352
360
  if (cmd === undefined)
353
361
  return;
354
362
  if (cmd.length > 0) {
355
- adapter.log.info("command: " + cmd[0] + " type: " + typeof this[cmd[0]]);
356
363
  if (! (typeof this[cmd[0]] === "function")) {
357
- adapter.log.info("Command " + cmd[0] + " not avaialable at the moment: " + typeof this[cmd[0]]);
364
+ adapter.log.info(`Command ${cmd[0]} not available at the moment: ${typeof this[cmd[0]]}`);
358
365
  return;
359
366
  }
360
367
  }
361
368
  if (cmd.length === 1) {
362
- adapter.log.info("command: " + cmd[0]);
363
369
  this [cmd[0]] ();
364
370
  } else if (cmd.length === 2) {
365
371
  this [cmd[0]] (p.result(cmd[1]));
@@ -413,7 +419,7 @@ function callWithCatch(origPromise, onSucess, onError){
413
419
  onConnectionTimeout();
414
420
  }
415
421
  if (errorCount++ === 0) {
416
- adapter.log.error('Can not connect to yamaha receiver at ' + adapter.config.ip + ' ' + error.message);
422
+ adapter.log.error(`Can not connect to yamaha receiver at ${adapter.config.ip} ${error.message}`);
417
423
  }
418
424
  safeCallback(onError);
419
425
  });
@@ -615,11 +621,11 @@ function runRealtimeFunction() {
615
621
  y5.onData = function(data) {
616
622
  setOnline(true);
617
623
  data = data.toString().replace(/^@|\r|\n/g, '');
618
- adapter.log.debug('Rawdata: ' + data);
624
+ adapter.log.debug(`Rawdata: ${data}`);
619
625
  var ar = data.split('@');
620
626
  ar.forEach(function (v) {
621
627
  dev.setChannel();
622
- dev.set('raw', '@' + v);
628
+ dev.set('raw', `@${v}`);
623
629
  handleRealtimeEvent(v);
624
630
  //var a = /^@(.*):(.*)=(.*)/.exec(v);
625
631
  var a = /(.*):(.*)=(.*)/.exec(v);
@@ -665,10 +671,11 @@ function normalizeConfig() {
665
671
 
666
672
 
667
673
  function setPossibleStates(id, objarr, options, cb) {
668
- if (options === undefined) options = {};
669
674
  if (typeof options === 'function') {
670
675
  cb = options;
671
676
  options = {};
677
+ } else if (options === undefined) {
678
+ options = {};
672
679
  }
673
680
  adapter.getObject(id, function(err, obj) {
674
681
  if (err || !obj) return;
@@ -694,7 +701,7 @@ function setPossibleStates(id, objarr, options, cb) {
694
701
  }
695
702
 
696
703
  function loadDesc() {
697
- var url = 'http://' + adapter.config.ip + '/YamahaRemoteControl/desc.xml';
704
+ var url = `http://${adapter.config.ip}/YamahaRemoteControl/desc.xml`;
698
705
  soef.getHttpData(url, {xml2json2: true }, function(err, data) {
699
706
  if (err || !data) return;
700
707
  var soundPrograms = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.yamaha",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "description": "ioBroker Yamaha Adapter",
5
5
  "author": {
6
6
  "name": "soef",
@@ -39,27 +39,27 @@
39
39
  "yamaha-nodejs-soef": "^0.7.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@alcalzone/release-script": "^3.5.6",
43
- "@alcalzone/release-script-plugin-iobroker": "^3.5.6",
44
- "@alcalzone/release-script-plugin-license": "^3.5.3",
45
- "@iobroker/testing": "^2.5.6",
46
- "@types/chai": "^4.3.0",
42
+ "@alcalzone/release-script": "^3.5.9",
43
+ "@alcalzone/release-script-plugin-iobroker": "^3.5.9",
44
+ "@alcalzone/release-script-plugin-license": "^3.5.9",
45
+ "@iobroker/testing": "^3.0.2",
46
+ "@types/chai": "^4.3.1",
47
47
  "@types/chai-as-promised": "^7.1.5",
48
48
  "@types/gulp": "^4.0.9",
49
- "@types/mocha": "^9.1.0",
50
- "@types/node": "^17.0.21",
49
+ "@types/mocha": "^9.1.1",
50
+ "@types/node": "^18.0.0",
51
51
  "@types/proxyquire": "^1.3.28",
52
52
  "@types/sinon": "^10.0.11",
53
53
  "@types/sinon-chai": "^3.2.8",
54
- "axios": "^0.26.0",
54
+ "axios": "^0.27.2",
55
55
  "chai": "^4.3.6",
56
56
  "chai-as-promised": "^7.1.1",
57
- "eslint": "^8.10.0",
57
+ "eslint": "^8.17.0",
58
58
  "gulp": "^4.0.2",
59
- "mocha": "^9.2.1",
59
+ "mocha": "^9.2.2",
60
60
  "proxyquire": "^2.1.3",
61
61
  "sinon-chai": "^3.7.0",
62
- "sinon": "^13.0.1"
62
+ "sinon": "^14.0.0"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",