homebridge-denon-tv 4.0.2-beta.76 → 4.0.2-beta.78
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/package.json +2 -2
- package/src/denon.js +9 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Denon TV",
|
|
3
3
|
"name": "homebridge-denon-tv",
|
|
4
|
-
"version": "4.0.2-beta.
|
|
4
|
+
"version": "4.0.2-beta.78",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Denon/Marantz AV Receivers.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"axios": "^1.3.4",
|
|
33
33
|
"xml2js": "^0.4.23",
|
|
34
34
|
"net": "^1.0.2",
|
|
35
|
-
"
|
|
35
|
+
"readline": "^1.3.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"homebridge",
|
package/src/denon.js
CHANGED
|
@@ -9,16 +9,16 @@ const CONSTANS = require('./constans.json');
|
|
|
9
9
|
class DENON extends EventEmitter {
|
|
10
10
|
constructor(config) {
|
|
11
11
|
super();
|
|
12
|
-
|
|
12
|
+
const host = config.host;
|
|
13
13
|
const port = config.port;
|
|
14
|
-
|
|
14
|
+
const supportOldAvr = config.supportOldAvr;
|
|
15
15
|
const zoneControl = config.zoneControl;
|
|
16
16
|
const debugLog = config.debugLog;
|
|
17
17
|
const disableLogConnectError = config.disableLogConnectError;
|
|
18
18
|
const mqttEnabled = config.mqttEnabled;
|
|
19
19
|
this.refreshInterval = config.refreshInterval;
|
|
20
20
|
|
|
21
|
-
const baseUrl = (`http://${
|
|
21
|
+
const baseUrl = (`http://${host}:${port}`);
|
|
22
22
|
this.axiosInstance = axios.create({
|
|
23
23
|
method: 'GET',
|
|
24
24
|
baseURL: baseUrl,
|
|
@@ -48,7 +48,7 @@ class DENON extends EventEmitter {
|
|
|
48
48
|
input: process.stdin,
|
|
49
49
|
output: process.stdout
|
|
50
50
|
});
|
|
51
|
-
this.
|
|
51
|
+
this.telnetClient = net.createConnection({ host: host, port: 23 }, () => {
|
|
52
52
|
this.emit('debug', `AVR Connected.`);
|
|
53
53
|
this.telnetClientConnected = true;
|
|
54
54
|
});
|
|
@@ -61,16 +61,17 @@ class DENON extends EventEmitter {
|
|
|
61
61
|
this.telnetClientConnected = false;
|
|
62
62
|
});
|
|
63
63
|
rl.on('line', (input) => {
|
|
64
|
+
this.emit('debug', `AVR rl write: ${input}.`);
|
|
64
65
|
this.telnetClient.write(`CLIENT: ${input}`);
|
|
65
66
|
});
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
this.on('checkDeviceInfo', async () => {
|
|
69
70
|
try {
|
|
70
|
-
const deviceUrl =
|
|
71
|
+
const deviceUrl = supportOldAvr ? CONSTANS.ApiUrls.MainZone : CONSTANS.ApiUrls.DeviceInfo;
|
|
71
72
|
const deviceInfo = await this.axiosInstance(deviceUrl);
|
|
72
73
|
const parseDeviceInfo = await parseString(deviceInfo.data);
|
|
73
|
-
const devInfo =
|
|
74
|
+
const devInfo = supportOldAvr ? parseDeviceInfo.item : parseDeviceInfo.Device_Info;
|
|
74
75
|
const debug = debugLog ? this.emit('debug', `Info: ${JSON.stringify(devInfo, null, 2)}`) : false;
|
|
75
76
|
|
|
76
77
|
//device info
|
|
@@ -82,7 +83,7 @@ class DENON extends EventEmitter {
|
|
|
82
83
|
const categoryName = deviceInfoKeys.includes('CategoryName') ? devInfo.ProductCategory[0] : 'Unknown';
|
|
83
84
|
const manualModelName = deviceInfoKeys.includes('ManualModelName') ? devInfo.ManualModelName[0] : 'Unknown';
|
|
84
85
|
const modelName = deviceInfoKeys.includes('ModelName') ? devInfo.ModelName[0] : 'AV Receiver';
|
|
85
|
-
const serialNumber = deviceInfoKeys.includes('MacAddress') ? devInfo.MacAddress[0] :
|
|
86
|
+
const serialNumber = deviceInfoKeys.includes('MacAddress') ? devInfo.MacAddress[0] : supportOldAvr ? `1234567654321` : false;
|
|
86
87
|
const firmwareRevision = deviceInfoKeys.includes('UpgradeVersion') ? devInfo.UpgradeVersion[0] : '00';
|
|
87
88
|
const zones = deviceInfoKeys.includes('DeviceZones') ? parseInt(devInfo.DeviceZones[0]) : 1;
|
|
88
89
|
|
|
@@ -279,7 +280,7 @@ class DENON extends EventEmitter {
|
|
|
279
280
|
return;
|
|
280
281
|
};
|
|
281
282
|
|
|
282
|
-
const sendCommand = this.
|
|
283
|
+
const sendCommand = this.telnetClientConnected ? this.telnetClient.write(command) : await this.axiosInstance(CONSTANS.ApiUrls.iPhoneDirect + command);
|
|
283
284
|
resolve();
|
|
284
285
|
} catch (error) {
|
|
285
286
|
reject(error);
|