homebridge-denon-tv 5.2.2 → 5.3.0-beta.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/CHANGELOG.md CHANGED
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
  - after update to 4.7.x buttons, sensors, volume display type need to be configure again using config UI
12
12
  - after update to 3.15.x need remove the accessory frome Home app and add it again
13
13
 
14
+ ## [5.2.3] - (19.12.2024)
15
+
16
+ ## Changes
17
+
18
+ - bump dependencies
19
+ - cleanup
20
+
14
21
  ## [5.2.0] - (01.12.2024)
15
22
 
16
23
  ## Changes
@@ -6561,32 +6561,41 @@
6561
6561
  "description": "Here set the background data refresh interval.",
6562
6562
  "required": false
6563
6563
  },
6564
- "enableDebugMode": {
6565
- "title": "Debug",
6564
+ "disableLogDeviceInfo": {
6565
+ "title": "Disable Log Device Info",
6566
6566
  "type": "boolean",
6567
6567
  "default": false,
6568
- "description": "This enable debug mode.",
6568
+ "description": "This disable logging device info by every connections device to the network.",
6569
6569
  "required": false
6570
6570
  },
6571
6571
  "disableLogInfo": {
6572
6572
  "title": "Disable Log Info",
6573
6573
  "type": "boolean",
6574
6574
  "default": false,
6575
- "description": "This disable logging values and states on every it change.",
6576
6575
  "required": false
6577
6576
  },
6578
- "disableLogDeviceInfo": {
6579
- "title": "Disable Log Device Info",
6577
+ "disableLogSuccess": {
6578
+ "title": "Disable Log Success",
6579
+ "type": "boolean",
6580
+ "default": false,
6581
+ "required": false
6582
+ },
6583
+ "disableLogWarn": {
6584
+ "title": "Disable Log Warn",
6585
+ "type": "boolean",
6586
+ "default": false,
6587
+ "required": false
6588
+ },
6589
+ "disableLogError": {
6590
+ "title": "Disable Log Error",
6580
6591
  "type": "boolean",
6581
6592
  "default": false,
6582
- "description": "This disable log device info by every connections device to the network.",
6583
6593
  "required": false
6584
6594
  },
6585
- "disableLogConnectError": {
6586
- "title": "Disable Log Connect Error",
6595
+ "enableDebugMode": {
6596
+ "title": "Enable Log Debug",
6587
6597
  "type": "boolean",
6588
6598
  "default": false,
6589
- "description": "This disable logging device connect error.",
6590
6599
  "required": false
6591
6600
  },
6592
6601
  "restFul": {
@@ -6941,12 +6950,14 @@
6941
6950
  },
6942
6951
  {
6943
6952
  "key": "devices[]",
6944
- "title": "System",
6953
+ "title": "Log",
6945
6954
  "items": [
6946
- "devices[].enableDebugMode",
6947
- "devices[].disableLogInfo",
6948
6955
  "devices[].disableLogDeviceInfo",
6949
- "devices[].disableLogConnectError"
6956
+ "devices[].disableLogInfo",
6957
+ "devices[].disableLogSuccess",
6958
+ "devices[].disableLogWarn",
6959
+ "devices[].disableLogError",
6960
+ "devices[].enableDebugMode"
6950
6961
  ]
6951
6962
  },
6952
6963
  {
package/index.js CHANGED
@@ -11,7 +11,7 @@ class DenonPlatform {
11
11
  constructor(log, config, api) {
12
12
  // only load if configured
13
13
  if (!config || !Array.isArray(config.devices)) {
14
- log.warn(`No configuration found for ${PluginName}`);
14
+ log.warn(`No configuration found for ${PluginName}.`);
15
15
  return;
16
16
  }
17
17
  this.accessories = [];
@@ -21,7 +21,7 @@ class DenonPlatform {
21
21
  try {
22
22
  mkdirSync(prefDir, { recursive: true });
23
23
  } catch (error) {
24
- log.error(`Prepare directory error: ${error.message ?? error}`);
24
+ log.error(`Prepare directory error: ${error}.`);
25
25
  return;
26
26
  }
27
27
 
@@ -36,9 +36,13 @@ class DenonPlatform {
36
36
  return;
37
37
  }
38
38
 
39
- //debug config
39
+ //log config
40
40
  const enableDebugMode = device.enableDebugMode || false;
41
- const disableLogConnectError = device.disableLogConnectError || false;
41
+ const disableLogDeviceInfo = device.disableLogDeviceInfo || false;
42
+ const disableLogInfo = device.disableLogInfo || false;
43
+ const disableLogSuccess = device.disableLogSuccess || false;
44
+ const disableLogWarn = device.disableLogWarn || false;
45
+ const disableLogError = device.disableLogError || false;
42
46
  const debug = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`) : false;
43
47
  const config = {
44
48
  ...device,
@@ -47,7 +51,7 @@ class DenonPlatform {
47
51
  passwd: 'removed'
48
52
  }
49
53
  };
50
- const debug1 = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}`) : false;
54
+ const debug1 = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}.`);
51
55
 
52
56
  //zones
53
57
  const zoneControl = device.zoneControl;
@@ -75,7 +79,7 @@ class DenonPlatform {
75
79
  }
76
80
  });
77
81
  } catch (error) {
78
- log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
82
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}.`);
79
83
  return;
80
84
  }
81
85
 
@@ -86,44 +90,44 @@ class DenonPlatform {
86
90
  const mainZone = new MainZone(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
87
91
  mainZone.on('publishAccessory', (accessory) => {
88
92
  api.publishExternalAccessories(PluginName, [accessory]);
89
- log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
93
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
90
94
  })
91
95
  .on('devInfo', (devInfo) => {
92
- log.info(devInfo);
96
+ const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
93
97
  })
94
- .on('success', (message) => {
95
- log.success(`Device: ${host} ${deviceName}, ${message}`);
98
+ .on('success', (success) => {
99
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
96
100
  })
97
- .on('message', (message) => {
98
- log.info(`Device: ${host} ${deviceName}, ${message}`);
101
+ .on('info', (info) => {
102
+ const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
99
103
  })
100
104
  .on('debug', (debug) => {
101
- log.info(`Device: ${host} ${deviceName}, debug: ${debug}`);
105
+ const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
102
106
  })
103
107
  .on('warn', (warn) => {
104
- log.warn(`Device: ${host} ${deviceName}, ${warn}`);
108
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
105
109
  })
106
- .on('error', async (error) => {
107
- log.error(`Device: ${host} ${deviceName}, ${error}`);
110
+ .on('error', (error) => {
111
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
108
112
  });
109
113
 
110
114
  //create impulse generator
111
115
  const impulseGenerator = new ImpulseGenerator();
112
116
  impulseGenerator.on('start', async () => {
113
117
  try {
114
- await mainZone.start();
115
- impulseGenerator.stop();
118
+ const startDone = await mainZone.start();
119
+ const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
116
120
  } catch (error) {
117
- const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
121
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
118
122
  };
119
123
  }).on('state', (state) => {
120
- const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
124
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
121
125
  });
122
126
 
123
127
  //start impulse generator
124
128
  impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
125
129
  } catch (error) {
126
- log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}`);
130
+ throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
127
131
  }
128
132
  break;
129
133
  case 1: //zone 1
@@ -131,44 +135,44 @@ class DenonPlatform {
131
135
  const zone2 = new Zone2(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
132
136
  zone2.on('publishAccessory', (accessory) => {
133
137
  api.publishExternalAccessories(PluginName, [accessory]);
134
- log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
138
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
135
139
  })
136
140
  .on('devInfo', (devInfo) => {
137
- log(devInfo);
141
+ const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
138
142
  })
139
- .on('success', (message) => {
140
- log.success(`Device: ${host} ${deviceName}, ${message}`);
143
+ .on('success', (success) => {
144
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
141
145
  })
142
- .on('message', (message) => {
143
- log(`Device: ${host} ${deviceName}, ${message}`);
146
+ .on('info', (info) => {
147
+ const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
144
148
  })
145
149
  .on('debug', (debug) => {
146
- log(`Device: ${host} ${deviceName}, debug: ${debug}`);
150
+ const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
147
151
  })
148
152
  .on('warn', (warn) => {
149
- log.warn(`Device: ${host} ${deviceName}, ${warn}`);
153
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
150
154
  })
151
- .on('error', async (error) => {
152
- log.error(`Device: ${host} ${deviceName}, ${error}`);
155
+ .on('error', (error) => {
156
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
153
157
  });
154
158
 
155
159
  //create impulse generator
156
160
  const impulseGenerator = new ImpulseGenerator();
157
161
  impulseGenerator.on('start', async () => {
158
162
  try {
159
- await zone2.start();
160
- impulseGenerator.stop();
163
+ const startDone = await zone2.start();
164
+ const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
161
165
  } catch (error) {
162
- const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
166
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
163
167
  };
164
168
  }).on('state', (state) => {
165
- const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
169
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
166
170
  });
167
171
 
168
172
  //start impulse generator
169
173
  impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
170
174
  } catch (error) {
171
- log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}`);
175
+ throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
172
176
  }
173
177
  break;
174
178
  case 2: //zone 2
@@ -176,44 +180,44 @@ class DenonPlatform {
176
180
  const zone3 = new Zone3(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
177
181
  zone3.on('publishAccessory', (accessory) => {
178
182
  api.publishExternalAccessories(PluginName, [accessory]);
179
- log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
183
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
180
184
  })
181
185
  .on('devInfo', (devInfo) => {
182
- log.info(devInfo);
186
+ const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
183
187
  })
184
- .on('success', (message) => {
185
- log.success(`Device: ${host} ${deviceName}, ${message}`);
188
+ .on('success', (success) => {
189
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
186
190
  })
187
- .on('message', (message) => {
188
- log.info(`Device: ${host} ${deviceName}, ${message}`);
191
+ .on('info', (info) => {
192
+ const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
189
193
  })
190
194
  .on('debug', (debug) => {
191
- log.info(`Device: ${host} ${deviceName}, debug: ${debug}`);
195
+ const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
192
196
  })
193
197
  .on('warn', (warn) => {
194
- log.warn(`Device: ${host} ${deviceName}, ${warn}`);
198
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
195
199
  })
196
- .on('error', async (error) => {
197
- log.error(`Device: ${host} ${deviceName}, ${error}`);
200
+ .on('error', (error) => {
201
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
198
202
  });
199
203
 
200
204
  //create impulse generator
201
205
  const impulseGenerator = new ImpulseGenerator();
202
206
  impulseGenerator.on('start', async () => {
203
207
  try {
204
- await zone3.start();
205
- impulseGenerator.stop();
208
+ const startDone = await zone3.start();
209
+ const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
206
210
  } catch (error) {
207
- const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
211
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
208
212
  };
209
213
  }).on('state', (state) => {
210
- const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
214
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
211
215
  });
212
216
 
213
217
  //start impulse generator
214
218
  impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
215
219
  } catch (error) {
216
- log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}`);
220
+ throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
217
221
  }
218
222
  break;
219
223
  case 3: //surround
@@ -221,48 +225,48 @@ class DenonPlatform {
221
225
  const surround = new Surround(api, device, zoneControl, deviceName, host, port, generation, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile, refreshInterval);
222
226
  surround.on('publishAccessory', (accessory) => {
223
227
  api.publishExternalAccessories(PluginName, [accessory]);
224
- log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
228
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
225
229
  })
226
230
  .on('devInfo', (devInfo) => {
227
- log.info(devInfo);
231
+ const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
228
232
  })
229
- .on('success', (message) => {
230
- log.success(`Device: ${host} ${deviceName}, ${message}`);
233
+ .on('success', (success) => {
234
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
231
235
  })
232
- .on('message', (message) => {
233
- log.info(`Device: ${host} ${deviceName}, ${message}`);
236
+ .on('info', (info) => {
237
+ const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
234
238
  })
235
239
  .on('debug', (debug) => {
236
- log.info(`Device: ${host} ${deviceName}, debug: ${debug}`);
240
+ const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
237
241
  })
238
242
  .on('warn', (warn) => {
239
- log.warn(`Device: ${host} ${deviceName}, ${warn}`);
243
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
240
244
  })
241
- .on('error', async (error) => {
242
- log.error(`Device: ${host} ${deviceName}, ${error}`);
245
+ .on('error', (error) => {
246
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
243
247
  });
244
248
 
245
249
  //create impulse generator
246
250
  const impulseGenerator = new ImpulseGenerator();
247
251
  impulseGenerator.on('start', async () => {
248
252
  try {
249
- await surround.start();
250
- impulseGenerator.stop();
253
+ const startDone = await surround.start();
254
+ const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
251
255
  } catch (error) {
252
- const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
256
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
253
257
  };
254
258
  }).on('state', (state) => {
255
- const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
259
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
256
260
  });
257
261
 
258
262
  //start impulse generator
259
263
  impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
260
264
  } catch (error) {
261
- log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}`);
265
+ throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
262
266
  }
263
267
  break;
264
268
  default:
265
- log.warn(`Device: ${host} ${deviceName}, unknown zone: ${zoneControl}`);
269
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown zone: ${zoneControl}.`);
266
270
  break;
267
271
  }
268
272
  await new Promise(resolve => setTimeout(resolve, 500));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Denon TV",
3
3
  "name": "homebridge-denon-tv",
4
- "version": "5.2.2",
4
+ "version": "5.3.0-beta.0",
5
5
  "description": "Homebridge plugin to control Denon/Marantz AV Receivers.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -30,13 +30,13 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "engines": {
33
- "homebridge": "^1.6.0 || ^2.0.0-beta.0",
33
+ "homebridge": "^1.8.5 || ^2.0.0-beta.0",
34
34
  "node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "async-mqtt": "^2.6.3",
38
38
  "axios": "^1.7.9",
39
- "fast-xml-parser": "^4.5.0",
39
+ "fast-xml-parser": "^4.5.1",
40
40
  "express": "^4.21.2"
41
41
  },
42
42
  "keywords": [
package/src/denon.js CHANGED
@@ -22,7 +22,7 @@ class Denon extends EventEmitter {
22
22
  this.getInputsFromDevice = this.zone < 3 ? config.getInputsFromDevice : false;
23
23
  this.getFavoritesFromDevice = this.getInputsFromDevice ? config.getFavoritesFromDevice : false;
24
24
  this.getQuickSmartSelectFromDevice = this.getInputsFromDevice ? config.getQuickSmartSelectFromDevice : false;
25
- this.debugLog = config.debugLog;
25
+ this.enableDebugLog = config.enableDebugLog;
26
26
  this.deviceInfoUrl = [ApiUrls.DeviceInfoGen0, ApiUrls.DeviceInfoGen1, ApiUrls.DeviceInfoGen2][this.generation];
27
27
 
28
28
  const baseUrl = `http://${host}:${port}`;
@@ -79,10 +79,10 @@ class Denon extends EventEmitter {
79
79
  try {
80
80
  await this.checkState();
81
81
  } catch (error) {
82
- const logError = config.disableLogConnectError ? false : this.emit('error', `Impulse generator check state error: ${error.message || error}.`);
82
+ const logError = config.disableLogError ? false : this.emit('error', `Impulse generator error: ${error}`);
83
83
  };
84
84
  }).on('state', (state) => {
85
- const emitState = state ? this.emit('success', `Impulse generator started.`) : this.emit('warn', `Impulse generator stopped.`);
85
+ const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
86
86
  });
87
87
  };
88
88
 
@@ -92,7 +92,7 @@ class Denon extends EventEmitter {
92
92
  const deviceInfo = await this.axiosInstance(this.deviceInfoUrl);
93
93
  const parseData = this.parseString.parse(deviceInfo.data);
94
94
  const devInfo = [parseData.item, parseData.Device_Info, parseData.Device_Info][this.generation];
95
- const debug = this.debugLog ? this.emit('debug', `Connect data: ${JSON.stringify(devInfo, null, 2)}`) : false;
95
+ const debug = this.enableDebugLog ? this.emit('debug', `Connect data: ${JSON.stringify(devInfo, null, 2)}`) : false;
96
96
  this.devInfo = devInfo;
97
97
 
98
98
  //device info
@@ -201,8 +201,8 @@ class Denon extends EventEmitter {
201
201
 
202
202
  //check seriaql number
203
203
  if (!serialNumber) {
204
- this.emit('error', `Missing Serial Number.`);
205
- return;
204
+ this.emit('error', `Missing Serial Number`);
205
+ return false;
206
206
  }
207
207
 
208
208
  //save device info to the file
@@ -218,27 +218,21 @@ class Denon extends EventEmitter {
218
218
 
219
219
  //check inputs
220
220
  if (!inputsExist) {
221
- this.emit('warn', `Found: ${allInputs} inputs.`);
221
+ this.emit('warn', `Found: ${allInputs} inputs`);
222
222
  }
223
223
 
224
224
  //save inputs if exist
225
225
  const saveInputs = inputsExist ? await this.saveData(this.inputsFile, allInputs) : false;
226
226
 
227
227
  //connect to deice success
228
- this.emit('success', `Connect Success.`)
228
+ this.emit('success', `Connect Success`)
229
229
 
230
230
  //emit device info
231
231
  this.emit('deviceInfo', manufacturer, modelName, serialNumber, firmwareRevision, deviceZones, apiVersion, supportPictureMode);
232
232
 
233
- //start external integration
234
- this.emit('externalIntegration');
235
-
236
- //prepare accessory
237
- this.emit('prepareAccessory', allInputs);
238
-
239
233
  return true;
240
234
  } catch (error) {
241
- throw new Error(`Connect error: ${error.message || error}.`);
235
+ throw new Error(`Connect error: ${error}`);
242
236
 
243
237
  };
244
238
  };
@@ -250,7 +244,7 @@ class Denon extends EventEmitter {
250
244
  const deviceState = await this.axiosInstance(zoneStateUrl);
251
245
  const parseDeviceState = this.parseString.parse(deviceState.data);
252
246
  const devState = parseDeviceState.item;
253
- const debug = this.debugLog ? this.emit('debug', `State: ${JSON.stringify(devState, null, 2)}`) : false;
247
+ const debug = this.enableDebugLog ? this.emit('debug', `State: ${JSON.stringify(devState, null, 2)}`) : false;
254
248
 
255
249
  //get receiver status
256
250
  const statusKeys = Object.keys(devState);
@@ -264,7 +258,7 @@ class Denon extends EventEmitter {
264
258
  const checkPictureMode = this.supportPictureMode && power && this.zone === 0;
265
259
  const devicePictureMode = checkPictureMode ? await this.axiosInstancePost(ApiUrls.AppCommand, BodyXml.GetPictureMode) : false;
266
260
  const parseDevicePictureMode = checkPictureMode ? this.parseString.parse(devicePictureMode.data) : false;
267
- const debug1 = this.debugLog && checkPictureMode ? this.emit('debug', `Picture mode: ${JSON.stringify(parseDevicePictureMode, null, 2)}`) : false;
261
+ const debug1 = this.enableDebugLog && checkPictureMode ? this.emit('debug', `Picture mode: ${JSON.stringify(parseDevicePictureMode, null, 2)}`) : false;
268
262
  const pictureMode = checkPictureMode ? parseDevicePictureMode.rx.cmd.value : this.pictureMode;
269
263
 
270
264
  //get sound mode
@@ -272,14 +266,14 @@ class Denon extends EventEmitter {
272
266
  const checkSoundeMode = this.supportSoundMode && power && checkZone;
273
267
  const deviceSoundMode = checkSoundeMode ? await this.axiosInstancePost(ApiUrls.AppCommand, BodyXml.GetSurroundModeStatus) : false;
274
268
  const parseDeviceSoundMode = checkSoundeMode ? this.parseString.parse(deviceSoundMode.data) : false;
275
- const debug2 = this.debugLog && checkSoundeMode ? this.emit('debug', `Sound mode: ${JSON.stringify(parseDeviceSoundMode, null, 2)}`) : false;
269
+ const debug2 = this.enableDebugLog && checkSoundeMode ? this.emit('debug', `Sound mode: ${JSON.stringify(parseDeviceSoundMode, null, 2)}`) : false;
276
270
  const soundMode = checkSoundeMode ? SOUND_MODES_CONVERSION_KEYS.includes((parseDeviceSoundMode.rx.cmd.surround).replace(/[^a-zA-Z0-9]/g, '').toUpperCase()) ? SoundModeConversion[(parseDeviceSoundMode.rx.cmd.surround).replace(/[^a-zA-Z0-9]/g, '').toUpperCase()] : (parseDeviceSoundMode.rx.cmd.surround).replace(/[^a-zA-Z0-9]/g, '').toUpperCase() : this.soundMode;
277
271
 
278
272
  //get audyssey mode
279
273
  const checkAudysseyMode = false //power && zone === 0;
280
274
  const deviceAudysseyMode = checkAudysseyMode ? await this.axiosInstancePost(ApiUrls.AppCommand, BodyXml.GetAudyssey) : false;
281
275
  const parseDeviceAudysseyMode = checkAudysseyMode ? this.parseString.parse(deviceAudysseyMode.data) : false;
282
- const debug3 = this.debugLog && checkAudysseyMode ? this.emit('debug', `Audyssey mode: ${JSON.stringify(parseDeviceAudysseyMode, null, 2)}`) : false;
276
+ const debug3 = this.enableDebugLog && checkAudysseyMode ? this.emit('debug', `Audyssey mode: ${JSON.stringify(parseDeviceAudysseyMode, null, 2)}`) : false;
283
277
  const audysseyMode = checkAudysseyMode ? parseDeviceAudysseyMode.rx.cmd.value : this.audysseyMode;
284
278
 
285
279
  //select reference
@@ -316,7 +310,7 @@ class Denon extends EventEmitter {
316
310
 
317
311
  return true;
318
312
  } catch (error) {
319
- throw new Error(`Check state error: ${error.message || error}.`);
313
+ throw new Error(`Check state error: ${error}`);
320
314
  };
321
315
  };
322
316
 
@@ -446,11 +440,11 @@ class Denon extends EventEmitter {
446
440
  }
447
441
  allInputs.push(obj);
448
442
  }
449
- const debug = this.debugLog ? this.emit('message', `All Inputs: ${JSON.stringify(allInputs, null, 2)}`) : false;
443
+ const debug = this.enableDebugLog ? this.emit('info', `All Inputs: ${JSON.stringify(allInputs, null, 2)}`) : false;
450
444
 
451
445
  return allInputs;
452
446
  } catch (error) {
453
- throw new Error(`Get inputus error: ${error.message || error}`);
447
+ throw new Error(`Get inputus error: ${error}`);
454
448
  }
455
449
  };
456
450
 
@@ -458,10 +452,10 @@ class Denon extends EventEmitter {
458
452
  try {
459
453
  data = JSON.stringify(data, null, 2);
460
454
  await fsPromises.writeFile(path, data);
461
- const debug = this.debugLog ? this.emit('debug', `Saved data: ${data}`) : false;
455
+ const debug = this.enableDebugLog ? this.emit('debug', `Saved data: ${data}`) : false;
462
456
  return true;
463
457
  } catch (error) {
464
- throw new Error(`Save data error: ${error.message || error}`);
458
+ throw new Error(`Save data error: ${error}`);
465
459
  };
466
460
  };
467
461
 
@@ -471,7 +465,7 @@ class Denon extends EventEmitter {
471
465
  await this.axiosInstance(path);
472
466
  return true;
473
467
  } catch (error) {
474
- throw new Error(error);
468
+ throw new Error(`Send data error: ${error}`);
475
469
  };
476
470
  };
477
471
  };