homebridge-denon-tv 3.17.21 → 3.17.22-beta.2
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/README.md +4 -43
- package/index.js +20 -20
- package/package.json +1 -1
- package/src/denon.js +41 -42
package/README.md
CHANGED
|
@@ -23,21 +23,10 @@ This plugin is based upon the official documentation for communicating with and
|
|
|
23
23
|
| Package | Installation | Role | Required |
|
|
24
24
|
| --- | --- | --- | --- |
|
|
25
25
|
| [Homebridge](https://github.com/homebridge/homebridge) | [Homebridge Wiki](https://github.com/homebridge/homebridge/wiki) | HomeKit Bridge | Required |
|
|
26
|
-
| [Config UI X](https://github.com/oznu/homebridge-config-ui-x/wiki) | [Config UI X Wiki](https://github.com/oznu/homebridge-config-ui-x/wiki) | Web User Interface | Recommended |
|
|
27
|
-
| [Denon TV](https://www.npmjs.com/package/homebridge-denon-tv) |
|
|
26
|
+
| [Config UI X](https://github.com/oznu/homebridge-config-ui-x/wiki) | [Config UI X Wiki](https://github.com/oznu/homebridge-config-ui-x/wiki) | Homebridge Web User Interface | Recommended |
|
|
27
|
+
| [Denon TV](https://www.npmjs.com/package/homebridge-denon-tv) | [Plug-In Wiki](https://github.com/grzegorz914/homebridge-denon-tv/wiki) | Homebridge Plug-In | Required |
|
|
28
28
|
|
|
29
|
-
##
|
|
30
|
-
* For homebridge-denon-tv versions 3.6.0 and above the minimum required version of Homebridge is 1.3.x.
|
|
31
|
-
* If update to 3.15.0 need remove the accessory frome HomeKit app and add it again.
|
|
32
|
-
|
|
33
|
-
## Troubleshooting
|
|
34
|
-
* If for some reason the device is not displayed in HomeKit app try this procedure:
|
|
35
|
-
* Go to `./homebridge/persist` macOS or `/var/lib/homebridge/persist` for RPI.
|
|
36
|
-
* Remove `AccessoryInfo.xxx` file which contain Your device data: `{"displayName":"AV Receiver"}`.
|
|
37
|
-
* Next remove `IdentifierCashe.xxx` file with same name as `AccessoryInfo.xxx`.
|
|
38
|
-
* Restart Homebridge and try add it to the HomeKit app again.
|
|
39
|
-
|
|
40
|
-
## Features and How To Use Them
|
|
29
|
+
## About The Plugin
|
|
41
30
|
* Multi Zone control.
|
|
42
31
|
* Power ON/OFF short press tile in HomeKit app.
|
|
43
32
|
* RC/Media control is possible after you go to the RC app on iPhone/iPad.
|
|
@@ -48,7 +37,7 @@ This plugin is based upon the official documentation for communicating with and
|
|
|
48
37
|
* Digital Input Modes can be controlled by creating separate tile in the buttons section.
|
|
49
38
|
* Siri can be used for all functions, some times need create legacy buttons/switches/sensors.
|
|
50
39
|
* Automations can be used for all functions, some times need create legacy buttons/switches/sensors.
|
|
51
|
-
* MQTT
|
|
40
|
+
* MQTT publisch topic *Info*, *State* and *Sound Mode* as payload JSON data.
|
|
52
41
|
|
|
53
42
|
<p align="left">
|
|
54
43
|
<a href="https://github.com/grzegorz914/homebridge-denon-tv"><img src="https://raw.githubusercontent.com/grzegorz914/homebridge-denon-tv/main/graphics/homekit.png" width="382"></a>
|
|
@@ -288,31 +277,3 @@ This plugin is based upon the official documentation for communicating with and
|
|
|
288
277
|
]
|
|
289
278
|
}
|
|
290
279
|
```
|
|
291
|
-
|
|
292
|
-
### Adding to HomeKit
|
|
293
|
-
* Each accessory needs to be manually paired.
|
|
294
|
-
* Open the Home <img src='https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png' width='16.42px'> app on your device.
|
|
295
|
-
* Tap the Home tab, then tap <img src='https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png' width='16.42px'>.
|
|
296
|
-
* Tap *Add Accessory*, and select *I Don't Have a Code, Cannot Scan* or *More options*.
|
|
297
|
-
* Select Your accessory and press add anyway.
|
|
298
|
-
* Enter the PIN or scan the QR code, this can be found in Homebridge UI or Homebridge logs.
|
|
299
|
-
* Complete the accessory setup.
|
|
300
|
-
|
|
301
|
-
## Limitations
|
|
302
|
-
* That maximum Services for 1 accessory is 100. If Services > 100, accessory stop responding.
|
|
303
|
-
* To solve this problem the plugin counts the number of Services and not allow add more as 100.
|
|
304
|
-
* If You have configured more as 100 Services some inputs or buttons will not be available in the HomeKit app.
|
|
305
|
-
* The Services in this accessory are:
|
|
306
|
-
* Information.
|
|
307
|
-
* Speaker.
|
|
308
|
-
* Lightbulb.
|
|
309
|
-
* Fan.
|
|
310
|
-
* Television.
|
|
311
|
-
* Inputs, which may range from 6 to 100 as each input is 1 service.
|
|
312
|
-
* Buttons, which may range from 6 to 100 as each button is 1 service.
|
|
313
|
-
|
|
314
|
-
## [What's New](https://github.com/grzegorz914/homebridge-denon-tv/blob/main/CHANGELOG.md)
|
|
315
|
-
|
|
316
|
-
## Development
|
|
317
|
-
Please feel free to create a Pull request and help in development. It will be highly appreciated.
|
|
318
|
-
|
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const fsPromises = fs.promises;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const Mqtt = require('./src/mqtt.js');
|
|
6
|
+
const Denon = require('./src/denon.js');
|
|
7
7
|
|
|
8
8
|
const PLUGIN_NAME = 'homebridge-denon-tv';
|
|
9
9
|
const PLATFORM_NAME = 'DenonTv';
|
|
@@ -80,7 +80,7 @@ class denonTvDevice {
|
|
|
80
80
|
this.buttonsZone2 = config.buttonsZone2 || [];
|
|
81
81
|
this.buttonsZone3 = config.buttonsZone3 || [];
|
|
82
82
|
this.soundModes = config.surrounds || [];
|
|
83
|
-
this.
|
|
83
|
+
this.mqttEnabled = config.enableMqtt || false;
|
|
84
84
|
this.mqttHost = config.mqttHost;
|
|
85
85
|
this.mqttPort = config.mqttPort || 1883;
|
|
86
86
|
this.mqttPrefix = config.mqttPrefix;
|
|
@@ -165,8 +165,8 @@ class denonTvDevice {
|
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
//mqtt client
|
|
168
|
-
this.
|
|
169
|
-
enabled: this.
|
|
168
|
+
this.mqtt = new Mqtt({
|
|
169
|
+
enabled: this.mqttEnabled,
|
|
170
170
|
host: this.mqttHost,
|
|
171
171
|
port: this.mqttPort,
|
|
172
172
|
prefix: this.mqttPrefix,
|
|
@@ -177,7 +177,7 @@ class denonTvDevice {
|
|
|
177
177
|
debug: this.mqttDebug
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
this.
|
|
180
|
+
this.mqtt.on('connected', (message) => {
|
|
181
181
|
this.log(`Device: ${this.host} ${this.name}, ${message}`);
|
|
182
182
|
})
|
|
183
183
|
.on('error', (error) => {
|
|
@@ -194,28 +194,18 @@ class denonTvDevice {
|
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
//denon client
|
|
197
|
-
this.denon = new
|
|
197
|
+
this.denon = new Denon({
|
|
198
198
|
host: this.host,
|
|
199
199
|
port: this.port,
|
|
200
|
-
infoLog: this.disableLogInfo,
|
|
201
200
|
debugLog: this.enableDebugMode,
|
|
202
201
|
zoneControl: this.zoneControl,
|
|
203
202
|
devInfoFile: this.devInfoFile,
|
|
204
|
-
mqttEnabled: this.
|
|
203
|
+
mqttEnabled: this.mqttEnabled
|
|
205
204
|
});
|
|
206
205
|
|
|
207
206
|
this.denon.on('connected', (message) => {
|
|
208
207
|
this.log(`Device: ${this.host} ${this.name}, ${message}`);
|
|
209
208
|
})
|
|
210
|
-
.on('error', (error) => {
|
|
211
|
-
this.log.error(`Device: ${this.host} ${this.name}, ${error}`);
|
|
212
|
-
})
|
|
213
|
-
.on('debug', (message) => {
|
|
214
|
-
this.log(`Device: ${this.host} ${this.name}, debug: ${message}`);
|
|
215
|
-
})
|
|
216
|
-
.on('message', (message) => {
|
|
217
|
-
this.log(`Device: ${this.host} ${this.name}, ${message}`);
|
|
218
|
-
})
|
|
219
209
|
.on('deviceInfo', (manufacturer, modelName, serialNumber, firmwareRevision, zones, apiVersion) => {
|
|
220
210
|
if (!this.disableLogDeviceInfo) {
|
|
221
211
|
this.log('-------- %s --------', this.name);
|
|
@@ -295,8 +285,14 @@ class denonTvDevice {
|
|
|
295
285
|
this.prepareAccessory();
|
|
296
286
|
};
|
|
297
287
|
})
|
|
298
|
-
.on('
|
|
299
|
-
this.
|
|
288
|
+
.on('error', (error) => {
|
|
289
|
+
this.log.error(`Device: ${this.host} ${this.name}, ${error}`);
|
|
290
|
+
})
|
|
291
|
+
.on('debug', (message) => {
|
|
292
|
+
this.log(`Device: ${this.host} ${this.name}, debug: ${message}`);
|
|
293
|
+
})
|
|
294
|
+
.on('message', (message) => {
|
|
295
|
+
this.log(`Device: ${this.host} ${this.name}, ${message}`);
|
|
300
296
|
})
|
|
301
297
|
.on('disconnected', (message) => {
|
|
302
298
|
this.log(`Device: ${this.host} ${this.name}, ${message}`);
|
|
@@ -344,6 +340,7 @@ class denonTvDevice {
|
|
|
344
340
|
try {
|
|
345
341
|
const setPower = (state != this.power) ? await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + newState) : false;
|
|
346
342
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set Power state successful, state: %s', this.host, accessoryName, newState);
|
|
343
|
+
this.power = state;
|
|
347
344
|
} catch (error) {
|
|
348
345
|
this.log.error('Device: %s %s, can not set Power state. Might be due to a wrong settings in config, error: %s', this.host, accessoryName, error);
|
|
349
346
|
};
|
|
@@ -366,6 +363,7 @@ class denonTvDevice {
|
|
|
366
363
|
try {
|
|
367
364
|
const setInput = (inputReference != undefined) ? await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + inputRef) : false;
|
|
368
365
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set %s successful, name: %s, reference: %s', this.host, accessoryName, this.zoneControl <= 2 ? 'Input' : 'Sound Mode', inputName, inputRef);
|
|
366
|
+
this.inputIdentifier = inputIdentifier;
|
|
369
367
|
} catch (error) {
|
|
370
368
|
this.log.error('Device: %s %s, can not set %s. Might be due to a wrong settings in config, error: %s', this.host, accessoryName, this.zoneControl <= 2 ? 'Input' : 'Sound Mode', error);
|
|
371
369
|
};
|
|
@@ -596,6 +594,7 @@ class denonTvDevice {
|
|
|
596
594
|
try {
|
|
597
595
|
const setVolume = await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + zone + volume);
|
|
598
596
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Volume level successful, volume: %s dB', this.host, accessoryName, volume - 80);
|
|
597
|
+
this.volume = volume;
|
|
599
598
|
} catch (error) {
|
|
600
599
|
this.log.error('Device: %s %s, can not set new Volume level. Might be due to a wrong settings in config, error: %s', this.host, accessoryName, error);
|
|
601
600
|
};
|
|
@@ -614,6 +613,7 @@ class denonTvDevice {
|
|
|
614
613
|
try {
|
|
615
614
|
const toggleMute = (this.power && state != this.mute) ? await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + zone + newState) : false;
|
|
616
615
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Mute state successful, state: %s', this.host, accessoryName, state ? 'ON' : 'OFF');
|
|
616
|
+
this.mute = mute;
|
|
617
617
|
} catch (error) {
|
|
618
618
|
this.log.error('Device: %s %s, can not set new Mute state. Might be due to a wrong settings in config, error: %s', this.host, accessoryName, error);
|
|
619
619
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Denon TV",
|
|
3
3
|
"name": "homebridge-denon-tv",
|
|
4
|
-
"version": "3.17.
|
|
4
|
+
"version": "3.17.22-beta.2",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Denon/Marantz AV Receivers.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/denon.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const fsPromises = fs.promises;
|
|
4
|
-
const EventEmitter = require('events');
|
|
5
4
|
const axios = require('axios');
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const parseString = require('xml2js').parseStringPromise;
|
|
6
|
+
const EventEmitter = require('events');
|
|
8
7
|
const CONSTANS = require('./constans.json');
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
const SOUND_MODE_STATUS = `<?xml version="1.0" encoding="utf-8"?>
|
|
10
10
|
<tx>
|
|
11
11
|
<cmd id="1">${CONSTANS.BodyXml.GetSurroundModeStatus}</cmd>
|
|
12
12
|
</tx>`;
|
|
13
|
-
const
|
|
14
|
-
data:
|
|
13
|
+
const CONFIG_XML = {
|
|
14
|
+
data: SOUND_MODE_STATUS,
|
|
15
15
|
headers: {
|
|
16
16
|
'Content-Type': 'text/xml'
|
|
17
17
|
}
|
|
@@ -20,15 +20,14 @@ const configXml = {
|
|
|
20
20
|
class DENON extends EventEmitter {
|
|
21
21
|
constructor(config) {
|
|
22
22
|
super();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.mqttEnabled = config.mqttEnabled;
|
|
23
|
+
const host = config.host;
|
|
24
|
+
const port = config.port;
|
|
25
|
+
const debugLog = config.debugLog;
|
|
26
|
+
const zoneControl = config.zoneControl;
|
|
27
|
+
const devInfoFile = config.devInfoFile;
|
|
28
|
+
const mqttEnabled = config.mqttEnabled;
|
|
30
29
|
|
|
31
|
-
const baseUrl = (`http://${
|
|
30
|
+
const baseUrl = (`http://${host}:${port}`);
|
|
32
31
|
this.axiosInstance = axios.create({
|
|
33
32
|
method: 'GET',
|
|
34
33
|
baseURL: baseUrl,
|
|
@@ -60,27 +59,27 @@ class DENON extends EventEmitter {
|
|
|
60
59
|
.on('checkDeviceInfo', async () => {
|
|
61
60
|
try {
|
|
62
61
|
const deviceInfo = await this.axiosInstance(CONSTANS.ApiUrls.DeviceInfo);
|
|
63
|
-
const parseDeviceInfo = await
|
|
64
|
-
const devInfo =
|
|
65
|
-
const debug =
|
|
66
|
-
const writeDevInfo = (
|
|
67
|
-
this.devInfo = devInfo;
|
|
62
|
+
const parseDeviceInfo = await parseString(deviceInfo.data);
|
|
63
|
+
const devInfo = parseDeviceInfo.Device_Info;
|
|
64
|
+
const debug = debugLog ? this.emit('debug', `Info: ${JSON.stringify(devInfo, null, 2)}`) : false;
|
|
65
|
+
const writeDevInfo = (zoneControl == 0) ? await fsPromises.writeFile(devInfoFile, JSON.stringify(devInfo, null, 2)) : false;
|
|
68
66
|
|
|
69
67
|
let manufacturer = 'Denon/Marantz';
|
|
70
|
-
if (typeof
|
|
71
|
-
manufacturer = ['Denon', 'Marantz'][
|
|
68
|
+
if (typeof devInfo.BrandCode[0] !== 'undefined') {
|
|
69
|
+
manufacturer = ['Denon', 'Marantz'][devInfo.BrandCode[0]];
|
|
72
70
|
};
|
|
73
|
-
const modelName =
|
|
74
|
-
const serialNumber =
|
|
75
|
-
const firmwareRevision =
|
|
76
|
-
const zones =
|
|
77
|
-
const apiVersion =
|
|
71
|
+
const modelName = devInfo.ModelName[0];
|
|
72
|
+
const serialNumber = devInfo.MacAddress[0];
|
|
73
|
+
const firmwareRevision = devInfo.UpgradeVersion[0];
|
|
74
|
+
const zones = devInfo.DeviceZones[0];
|
|
75
|
+
const apiVersion = devInfo.CommApiVers[0];
|
|
76
|
+
this.devInfo = devInfo;
|
|
78
77
|
|
|
79
78
|
if (serialNumber != null && serialNumber != undefined) {
|
|
80
79
|
this.emit('deviceInfo', manufacturer, modelName, serialNumber, firmwareRevision, zones, apiVersion);
|
|
81
80
|
this.emit('connect');
|
|
82
81
|
} else {
|
|
83
|
-
const debug1 =
|
|
82
|
+
const debug1 = debugLog ? this.emit('debug', `Serial number unknown: ${serialNumber}, reconnect in 15s.`) : false;
|
|
84
83
|
this.checkDeviceInfo();
|
|
85
84
|
}
|
|
86
85
|
} catch (error) {
|
|
@@ -90,22 +89,23 @@ class DENON extends EventEmitter {
|
|
|
90
89
|
})
|
|
91
90
|
.on('checkState', async () => {
|
|
92
91
|
try {
|
|
93
|
-
const zoneUrl = [CONSTANS.ApiUrls.MainZoneStatusLite, CONSTANS.ApiUrls.Zone2StatusLite, CONSTANS.ApiUrls.Zone3StatusLite, CONSTANS.ApiUrls.SoundModeStatus][
|
|
92
|
+
const zoneUrl = [CONSTANS.ApiUrls.MainZoneStatusLite, CONSTANS.ApiUrls.Zone2StatusLite, CONSTANS.ApiUrls.Zone3StatusLite, CONSTANS.ApiUrls.SoundModeStatus][zoneControl];
|
|
94
93
|
const deviceState = await this.axiosInstance(zoneUrl);
|
|
95
|
-
const parseDeviceState = await
|
|
96
|
-
const
|
|
94
|
+
const parseDeviceState = await parseString(deviceState.data);
|
|
95
|
+
const devState = parseDeviceState.item;
|
|
96
|
+
const debug = debugLog ? this.emit('debug', `State: ${JSON.stringify(devState, null, 2)}`) : false;
|
|
97
97
|
|
|
98
|
-
const checkSoundMode = (
|
|
99
|
-
const deviceSoundMode = checkSoundMode ? await this.axiosInstancePost(CONSTANS.ApiUrls.AppCommand,
|
|
100
|
-
const parseDeviceSoundMode = checkSoundMode ? await
|
|
101
|
-
const debug1 = this.debugLog ? this.emit('debug', `Sound mode
|
|
98
|
+
const checkSoundMode = (zoneControl == 0 || zoneControl == 3)
|
|
99
|
+
const deviceSoundMode = checkSoundMode ? await this.axiosInstancePost(CONSTANS.ApiUrls.AppCommand, CONFIG_XML) : false;
|
|
100
|
+
const parseDeviceSoundMode = checkSoundMode ? await parseString(deviceSoundMode.data) : false;
|
|
101
|
+
const debug1 = this.debugLog ? this.emit('debug', `Sound mode: ${JSON.stringify(parseDeviceSoundMode, null, 2)}`) : false;
|
|
102
102
|
const soundMode = checkSoundMode ? CONSTANS.SoundMode[(parseDeviceSoundMode.rx.cmd[0].surround[0]).replace(/[^a-zA-Z0-9]/g, '').toUpperCase()] : this.soundMode;
|
|
103
103
|
|
|
104
|
-
const power = (
|
|
105
|
-
const reference = (
|
|
106
|
-
const volume = (parseFloat(
|
|
107
|
-
const mute = power ? (
|
|
108
|
-
if (this.checkStateOnFirstRun
|
|
104
|
+
const power = (devState.Power[0].value[0] == 'ON');
|
|
105
|
+
const reference = (zoneControl == 3) ? soundMode : (devState.InputFuncSelect[0].value[0] == 'Internet Radio') ? 'IRADIO' : (devState.InputFuncSelect[0].value[0] == 'AirPlay') ? 'NET' : devState.InputFuncSelect[0].value[0];
|
|
106
|
+
const volume = (parseFloat(devState.MasterVolume[0].value[0]) >= -79.5) ? parseInt(devState.MasterVolume[0].value[0]) + 80 : this.volume;
|
|
107
|
+
const mute = power ? (devState.Mute[0].value[0] == 'on') : true;
|
|
108
|
+
if (this.checkStateOnFirstRun || power != this.power || reference != this.reference || volume != this.volume || mute != this.mute || soundMode != this.soundMod) {
|
|
109
109
|
this.power = power;
|
|
110
110
|
this.reference = reference;
|
|
111
111
|
this.volume = volume;
|
|
@@ -114,8 +114,8 @@ class DENON extends EventEmitter {
|
|
|
114
114
|
this.checkStateOnFirstRun = false;
|
|
115
115
|
this.emit('stateChanged', power, reference, volume, mute, soundMode);
|
|
116
116
|
};
|
|
117
|
-
const mqtt =
|
|
118
|
-
const mqtt1 =
|
|
117
|
+
const mqtt = mqttEnabled ? this.emit('mqtt', 'Info', JSON.stringify(this.devInfo, null, 2)) : false;
|
|
118
|
+
const mqtt1 = mqttEnabled ? this.emit('mqtt', 'State', JSON.stringify(devState, null, 2)) : false;
|
|
119
119
|
const surroundMode = {
|
|
120
120
|
'surround': soundMode
|
|
121
121
|
}
|
|
@@ -148,7 +148,6 @@ class DENON extends EventEmitter {
|
|
|
148
148
|
return new Promise(async (resolve, reject) => {
|
|
149
149
|
try {
|
|
150
150
|
const sendCommand = await this.axiosInstance(apiUrl);
|
|
151
|
-
const info = this.infoLog ? false : this.emit('message', `Send command: ${apiUrl}`);
|
|
152
151
|
this.emit('checkState');
|
|
153
152
|
resolve(true);
|
|
154
153
|
} catch (error) {
|