homebridge-denon-tv 5.3.2 → 5.3.3-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 +6 -0
- package/package.json +1 -1
- package/src/mainzone.js +226 -234
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,12 @@ 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.3.2] - (16.01.2025)
|
|
15
|
+
|
|
16
|
+
## Changes
|
|
17
|
+
|
|
18
|
+
- workaround for [#306](https://github.com/grzegorz914/homebridge-denon-tv/issues/306)
|
|
19
|
+
|
|
14
20
|
## [5.3.1] - (15.01.2025)
|
|
15
21
|
|
|
16
22
|
## Changes
|
package/package.json
CHANGED
package/src/mainzone.js
CHANGED
|
@@ -113,232 +113,6 @@ class MainZone extends EventEmitter {
|
|
|
113
113
|
this.inputsTargetVisibilityFile = inputsTargetVisibilityFile;
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
async start() {
|
|
117
|
-
try {
|
|
118
|
-
//denon client
|
|
119
|
-
this.denon = new Denon({
|
|
120
|
-
host: this.host,
|
|
121
|
-
port: this.port,
|
|
122
|
-
generation: this.generation,
|
|
123
|
-
zone: this.zone,
|
|
124
|
-
inputs: this.inputs,
|
|
125
|
-
devInfoFile: this.devInfoFile,
|
|
126
|
-
inputsFile: this.inputsFile,
|
|
127
|
-
getInputsFromDevice: this.getInputsFromDevice,
|
|
128
|
-
getFavoritesFromDevice: this.getFavoritesFromDevice,
|
|
129
|
-
getQuickSmartSelectFromDevice: this.getQuickSmartSelectFromDevice,
|
|
130
|
-
enableDebugLog: this.enableDebugMode,
|
|
131
|
-
disableLogError: this.disableLogError
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
this.denon.on('deviceInfo', (manufacturer, modelName, serialNumber, firmwareRevision, deviceZones, apiVersion, supportPictureMode) => {
|
|
135
|
-
this.emit('devInfo', `-------- ${this.name} --------`);
|
|
136
|
-
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
137
|
-
this.emit('devInfo', `Model: ${modelName}`);
|
|
138
|
-
this.emit('devInfo', `Zones: ${deviceZones}`);
|
|
139
|
-
this.emit('devInfo', `Control: Main Zone`);
|
|
140
|
-
this.emit('devInfo', `Firmware: ${firmwareRevision}`);
|
|
141
|
-
this.emit('devInfo', `Api version: ${apiVersion}`);
|
|
142
|
-
this.emit('devInfo', `Serialnr: ${serialNumber}`);
|
|
143
|
-
this.emit('devInfo', `----------------------------------`);
|
|
144
|
-
|
|
145
|
-
this.manufacturer = manufacturer;
|
|
146
|
-
this.modelName = modelName;
|
|
147
|
-
this.serialNumber = serialNumber;
|
|
148
|
-
this.firmwareRevision = firmwareRevision;
|
|
149
|
-
this.supportPictureMode = supportPictureMode;
|
|
150
|
-
})
|
|
151
|
-
.on('stateChanged', (power, reference, volume, volumeControlType, mute, pictureMode) => {
|
|
152
|
-
const input = this.inputsConfigured.find(input => input.reference === reference) ?? false;
|
|
153
|
-
const inputIdentifier = input ? input.identifier : this.inputIdentifier;
|
|
154
|
-
mute = power ? mute : true;
|
|
155
|
-
const pictureModeHomeKit = PictureModesConversionToHomeKit[pictureMode] ?? this.pictureMode;
|
|
156
|
-
|
|
157
|
-
if (this.televisionService) {
|
|
158
|
-
this.televisionService
|
|
159
|
-
.updateCharacteristic(Characteristic.Active, power ? 1 : 0)
|
|
160
|
-
.updateCharacteristic(Characteristic.ActiveIdentifier, inputIdentifier)
|
|
161
|
-
.updateCharacteristic(Characteristic.PictureMode, pictureModeHomeKit);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (this.speakerService) {
|
|
165
|
-
this.speakerService
|
|
166
|
-
.updateCharacteristic(Characteristic.Active, power ? 1 : 0)
|
|
167
|
-
.updateCharacteristic(Characteristic.Volume, volume)
|
|
168
|
-
.updateCharacteristic(Characteristic.Mute, mute);
|
|
169
|
-
|
|
170
|
-
if (this.volumeService) {
|
|
171
|
-
this.volumeService
|
|
172
|
-
.updateCharacteristic(Characteristic.Brightness, volume)
|
|
173
|
-
.updateCharacteristic(Characteristic.On, !mute);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (this.volumeServiceFan) {
|
|
177
|
-
this.volumeServiceFan
|
|
178
|
-
.updateCharacteristic(Characteristic.RotationSpeed, volume)
|
|
179
|
-
.updateCharacteristic(Characteristic.On, !mute);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
//sensors
|
|
184
|
-
if (this.sensorPowerService) {
|
|
185
|
-
this.sensorPowerService
|
|
186
|
-
.updateCharacteristic(Characteristic.ContactSensorState, power)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (volume !== this.volume) {
|
|
190
|
-
for (let i = 0; i < 2; i++) {
|
|
191
|
-
const state = power ? [true, false][i] : false;
|
|
192
|
-
if (this.sensorVolumeService) {
|
|
193
|
-
this.sensorVolumeService
|
|
194
|
-
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
195
|
-
this.sensorVolumeState = state;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (this.sensorMuteService) {
|
|
201
|
-
const state = power ? mute : false;
|
|
202
|
-
this.sensorMuteService
|
|
203
|
-
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (reference !== this.reference) {
|
|
207
|
-
for (let i = 0; i < 2; i++) {
|
|
208
|
-
const state = power ? [true, false][i] : false;
|
|
209
|
-
if (this.sensorInputService) {
|
|
210
|
-
this.sensorInputService
|
|
211
|
-
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
212
|
-
this.sensorInputState = state;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (this.sensorsInputsConfiguredCount > 0) {
|
|
218
|
-
for (let i = 0; i < this.sensorsInputsConfiguredCount; i++) {
|
|
219
|
-
const sensorInput = this.sensorsInputsConfigured[i];
|
|
220
|
-
const state = power ? sensorInput.reference === reference : false;
|
|
221
|
-
sensorInput.state = state;
|
|
222
|
-
if (this.sensorsInputsServices) {
|
|
223
|
-
const characteristicType = sensorInput.characteristicType;
|
|
224
|
-
this.sensorsInputsServices[i]
|
|
225
|
-
.updateCharacteristic(characteristicType, state);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
//buttons
|
|
231
|
-
if (this.buttonsConfiguredCount > 0) {
|
|
232
|
-
for (let i = 0; i < this.buttonsConfiguredCount; i++) {
|
|
233
|
-
const button = this.buttonsConfigured[i];
|
|
234
|
-
const state = this.power ? button.reference === reference : false;
|
|
235
|
-
button.state = state;
|
|
236
|
-
if (this.buttonsServices) {
|
|
237
|
-
this.buttonsServices[i]
|
|
238
|
-
.updateCharacteristic(Characteristic.On, state);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
this.inputIdentifier = inputIdentifier;
|
|
244
|
-
this.power = power;
|
|
245
|
-
this.reference = reference;
|
|
246
|
-
this.volume = volume;
|
|
247
|
-
this.mute = mute;
|
|
248
|
-
this.volumeControlType = volumeControlType;
|
|
249
|
-
this.pictureMode = pictureModeHomeKit;
|
|
250
|
-
|
|
251
|
-
if (!this.disableLogInfo) {
|
|
252
|
-
const name = input ? input.name : reference;
|
|
253
|
-
this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
|
|
254
|
-
this.emit('info', `Input Name: ${name}`);
|
|
255
|
-
this.emit('info', `Reference: ${reference}`);
|
|
256
|
-
this.emit('info', `Volume: ${volume - 80}dB`);
|
|
257
|
-
this.emit('info', `Mute: ${mute ? 'ON' : 'OFF'}`);
|
|
258
|
-
this.emit('info', `Volume Control Type: ${volumeControlType}`);
|
|
259
|
-
this.emit('info', `Picture Mode: ${PictureModesDenonNumber[pictureMode]}`);
|
|
260
|
-
};
|
|
261
|
-
})
|
|
262
|
-
.on('success', (success) => {
|
|
263
|
-
this.emit('success', success);
|
|
264
|
-
})
|
|
265
|
-
.on('info', (info) => {
|
|
266
|
-
this.emit('info', info);
|
|
267
|
-
})
|
|
268
|
-
.on('debug', (debug) => {
|
|
269
|
-
this.emit('debug', debug);
|
|
270
|
-
})
|
|
271
|
-
.on('warn', async (warn) => {
|
|
272
|
-
this.emit('warn', warn);
|
|
273
|
-
})
|
|
274
|
-
.on('error', async (error) => {
|
|
275
|
-
this.emit('error', error);
|
|
276
|
-
})
|
|
277
|
-
.on('restFul', (path, data) => {
|
|
278
|
-
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
279
|
-
})
|
|
280
|
-
.on('mqtt', (topic, message) => {
|
|
281
|
-
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
//connect to avr
|
|
285
|
-
const connect = await this.denon.connect();
|
|
286
|
-
if (!connect) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
//start external integrations
|
|
291
|
-
const startExternalIntegrations = this.restFul.enable || this.mqtt.enable ? await this.externalIntegrations() : false;
|
|
292
|
-
|
|
293
|
-
//prepare accessory
|
|
294
|
-
if (this.startPrepareAccessory) {
|
|
295
|
-
//prepare data for accessory
|
|
296
|
-
await this.prepareDataForAccessory();
|
|
297
|
-
|
|
298
|
-
//prepare accessory
|
|
299
|
-
const accessory = await this.prepareAccessory();
|
|
300
|
-
this.emit('publishAccessory', accessory);
|
|
301
|
-
this.startPrepareAccessory = false;
|
|
302
|
-
|
|
303
|
-
//start impulse generator
|
|
304
|
-
await this.denon.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return true;
|
|
308
|
-
} catch (error) {
|
|
309
|
-
throw new Error(`Start error: ${error}`);
|
|
310
|
-
};
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
async displayOrder() {
|
|
314
|
-
try {
|
|
315
|
-
switch (this.inputsDisplayOrder) {
|
|
316
|
-
case 0:
|
|
317
|
-
this.inputsConfigured.sort((a, b) => a.identifier - b.identifier);
|
|
318
|
-
break;
|
|
319
|
-
case 1:
|
|
320
|
-
this.inputsConfigured.sort((a, b) => a.name.localeCompare(b.name));
|
|
321
|
-
break;
|
|
322
|
-
case 2:
|
|
323
|
-
this.inputsConfigured.sort((a, b) => b.name.localeCompare(a.name));
|
|
324
|
-
break;
|
|
325
|
-
case 3:
|
|
326
|
-
this.inputsConfigured.sort((a, b) => a.reference.localeCompare(b.reference));
|
|
327
|
-
break;
|
|
328
|
-
case 4:
|
|
329
|
-
this.inputsConfigured.sort((a, b) => b.reference.localeCompare(a.reference));
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
const debug = !this.enableDebugMode ? false : this.emit('debug', `Inputs display order: ${JSON.stringify(this.inputsConfigured, null, 2)}`);
|
|
333
|
-
|
|
334
|
-
const displayOrder = this.inputsConfigured.map(input => input.identifier);
|
|
335
|
-
this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
|
|
336
|
-
return true;
|
|
337
|
-
} catch (error) {
|
|
338
|
-
throw new Error(`Display order error: ${error}`);
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
116
|
async saveData(path, data) {
|
|
343
117
|
try {
|
|
344
118
|
data = JSON.stringify(data, null, 2);
|
|
@@ -467,6 +241,35 @@ class MainZone extends EventEmitter {
|
|
|
467
241
|
};
|
|
468
242
|
}
|
|
469
243
|
|
|
244
|
+
async displayOrder() {
|
|
245
|
+
try {
|
|
246
|
+
switch (this.inputsDisplayOrder) {
|
|
247
|
+
case 0:
|
|
248
|
+
this.inputsConfigured.sort((a, b) => a.identifier - b.identifier);
|
|
249
|
+
break;
|
|
250
|
+
case 1:
|
|
251
|
+
this.inputsConfigured.sort((a, b) => a.name.localeCompare(b.name));
|
|
252
|
+
break;
|
|
253
|
+
case 2:
|
|
254
|
+
this.inputsConfigured.sort((a, b) => b.name.localeCompare(a.name));
|
|
255
|
+
break;
|
|
256
|
+
case 3:
|
|
257
|
+
this.inputsConfigured.sort((a, b) => a.reference.localeCompare(b.reference));
|
|
258
|
+
break;
|
|
259
|
+
case 4:
|
|
260
|
+
this.inputsConfigured.sort((a, b) => b.reference.localeCompare(a.reference));
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
const debug = !this.enableDebugMode ? false : this.emit('debug', `Inputs display order: ${JSON.stringify(this.inputsConfigured, null, 2)}`);
|
|
264
|
+
|
|
265
|
+
const displayOrder = this.inputsConfigured.map(input => input.identifier);
|
|
266
|
+
this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
|
|
267
|
+
return true;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
throw new Error(`Display order error: ${error}`);
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
470
273
|
async prepareDataForAccessory() {
|
|
471
274
|
try {
|
|
472
275
|
//read inputs file
|
|
@@ -817,10 +620,6 @@ class MainZone extends EventEmitter {
|
|
|
817
620
|
return input.name;
|
|
818
621
|
})
|
|
819
622
|
.onSet(async (value) => {
|
|
820
|
-
if (value === this.savedInputsNames[inputReference]) {
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
623
|
try {
|
|
825
624
|
input.name = value;
|
|
826
625
|
this.savedInputsNames[inputReference] = value;
|
|
@@ -841,10 +640,6 @@ class MainZone extends EventEmitter {
|
|
|
841
640
|
return input.visibility;
|
|
842
641
|
})
|
|
843
642
|
.onSet(async (state) => {
|
|
844
|
-
if (state === this.savedInputsTargetVisibility[inputReference]) {
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
643
|
try {
|
|
849
644
|
input.visibility = state;
|
|
850
645
|
this.savedInputsTargetVisibility[inputReference] = state;
|
|
@@ -1076,6 +871,203 @@ class MainZone extends EventEmitter {
|
|
|
1076
871
|
throw new Error(error)
|
|
1077
872
|
};
|
|
1078
873
|
}
|
|
874
|
+
|
|
875
|
+
//start
|
|
876
|
+
async start() {
|
|
877
|
+
try {
|
|
878
|
+
//denon client
|
|
879
|
+
this.denon = new Denon({
|
|
880
|
+
host: this.host,
|
|
881
|
+
port: this.port,
|
|
882
|
+
generation: this.generation,
|
|
883
|
+
zone: this.zone,
|
|
884
|
+
inputs: this.inputs,
|
|
885
|
+
devInfoFile: this.devInfoFile,
|
|
886
|
+
inputsFile: this.inputsFile,
|
|
887
|
+
getInputsFromDevice: this.getInputsFromDevice,
|
|
888
|
+
getFavoritesFromDevice: this.getFavoritesFromDevice,
|
|
889
|
+
getQuickSmartSelectFromDevice: this.getQuickSmartSelectFromDevice,
|
|
890
|
+
enableDebugLog: this.enableDebugMode,
|
|
891
|
+
disableLogError: this.disableLogError
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
this.denon.on('deviceInfo', (manufacturer, modelName, serialNumber, firmwareRevision, deviceZones, apiVersion, supportPictureMode) => {
|
|
895
|
+
this.emit('devInfo', `-------- ${this.name} --------`);
|
|
896
|
+
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
897
|
+
this.emit('devInfo', `Model: ${modelName}`);
|
|
898
|
+
this.emit('devInfo', `Zones: ${deviceZones}`);
|
|
899
|
+
this.emit('devInfo', `Control: Main Zone`);
|
|
900
|
+
this.emit('devInfo', `Firmware: ${firmwareRevision}`);
|
|
901
|
+
this.emit('devInfo', `Api version: ${apiVersion}`);
|
|
902
|
+
this.emit('devInfo', `Serialnr: ${serialNumber}`);
|
|
903
|
+
this.emit('devInfo', `----------------------------------`);
|
|
904
|
+
|
|
905
|
+
this.manufacturer = manufacturer;
|
|
906
|
+
this.modelName = modelName;
|
|
907
|
+
this.serialNumber = serialNumber;
|
|
908
|
+
this.firmwareRevision = firmwareRevision;
|
|
909
|
+
this.supportPictureMode = supportPictureMode;
|
|
910
|
+
})
|
|
911
|
+
.on('stateChanged', (power, reference, volume, volumeControlType, mute, pictureMode) => {
|
|
912
|
+
const input = this.inputsConfigured.find(input => input.reference === reference) ?? false;
|
|
913
|
+
const inputIdentifier = input ? input.identifier : this.inputIdentifier;
|
|
914
|
+
mute = power ? mute : true;
|
|
915
|
+
const pictureModeHomeKit = PictureModesConversionToHomeKit[pictureMode] ?? this.pictureMode;
|
|
916
|
+
|
|
917
|
+
if (this.televisionService) {
|
|
918
|
+
this.televisionService
|
|
919
|
+
.updateCharacteristic(Characteristic.Active, power ? 1 : 0)
|
|
920
|
+
.updateCharacteristic(Characteristic.ActiveIdentifier, inputIdentifier)
|
|
921
|
+
.updateCharacteristic(Characteristic.PictureMode, pictureModeHomeKit);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
if (this.speakerService) {
|
|
925
|
+
this.speakerService
|
|
926
|
+
.updateCharacteristic(Characteristic.Active, power ? 1 : 0)
|
|
927
|
+
.updateCharacteristic(Characteristic.Volume, volume)
|
|
928
|
+
.updateCharacteristic(Characteristic.Mute, mute);
|
|
929
|
+
|
|
930
|
+
if (this.volumeService) {
|
|
931
|
+
this.volumeService
|
|
932
|
+
.updateCharacteristic(Characteristic.Brightness, volume)
|
|
933
|
+
.updateCharacteristic(Characteristic.On, !mute);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
if (this.volumeServiceFan) {
|
|
937
|
+
this.volumeServiceFan
|
|
938
|
+
.updateCharacteristic(Characteristic.RotationSpeed, volume)
|
|
939
|
+
.updateCharacteristic(Characteristic.On, !mute);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
//sensors
|
|
944
|
+
if (this.sensorPowerService) {
|
|
945
|
+
this.sensorPowerService
|
|
946
|
+
.updateCharacteristic(Characteristic.ContactSensorState, power)
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
if (volume !== this.volume) {
|
|
950
|
+
for (let i = 0; i < 2; i++) {
|
|
951
|
+
const state = power ? [true, false][i] : false;
|
|
952
|
+
if (this.sensorVolumeService) {
|
|
953
|
+
this.sensorVolumeService
|
|
954
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
955
|
+
this.sensorVolumeState = state;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
if (this.sensorMuteService) {
|
|
961
|
+
const state = power ? mute : false;
|
|
962
|
+
this.sensorMuteService
|
|
963
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
if (reference !== this.reference) {
|
|
967
|
+
for (let i = 0; i < 2; i++) {
|
|
968
|
+
const state = power ? [true, false][i] : false;
|
|
969
|
+
if (this.sensorInputService) {
|
|
970
|
+
this.sensorInputService
|
|
971
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
972
|
+
this.sensorInputState = state;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
if (this.sensorsInputsConfiguredCount > 0) {
|
|
978
|
+
for (let i = 0; i < this.sensorsInputsConfiguredCount; i++) {
|
|
979
|
+
const sensorInput = this.sensorsInputsConfigured[i];
|
|
980
|
+
const state = power ? sensorInput.reference === reference : false;
|
|
981
|
+
sensorInput.state = state;
|
|
982
|
+
if (this.sensorsInputsServices) {
|
|
983
|
+
const characteristicType = sensorInput.characteristicType;
|
|
984
|
+
this.sensorsInputsServices[i]
|
|
985
|
+
.updateCharacteristic(characteristicType, state);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
//buttons
|
|
991
|
+
if (this.buttonsConfiguredCount > 0) {
|
|
992
|
+
for (let i = 0; i < this.buttonsConfiguredCount; i++) {
|
|
993
|
+
const button = this.buttonsConfigured[i];
|
|
994
|
+
const state = this.power ? button.reference === reference : false;
|
|
995
|
+
button.state = state;
|
|
996
|
+
if (this.buttonsServices) {
|
|
997
|
+
this.buttonsServices[i]
|
|
998
|
+
.updateCharacteristic(Characteristic.On, state);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
this.inputIdentifier = inputIdentifier;
|
|
1004
|
+
this.power = power;
|
|
1005
|
+
this.reference = reference;
|
|
1006
|
+
this.volume = volume;
|
|
1007
|
+
this.mute = mute;
|
|
1008
|
+
this.volumeControlType = volumeControlType;
|
|
1009
|
+
this.pictureMode = pictureModeHomeKit;
|
|
1010
|
+
|
|
1011
|
+
if (!this.disableLogInfo) {
|
|
1012
|
+
const name = input ? input.name : reference;
|
|
1013
|
+
this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
|
|
1014
|
+
this.emit('info', `Input Name: ${name}`);
|
|
1015
|
+
this.emit('info', `Reference: ${reference}`);
|
|
1016
|
+
this.emit('info', `Volume: ${volume - 80}dB`);
|
|
1017
|
+
this.emit('info', `Mute: ${mute ? 'ON' : 'OFF'}`);
|
|
1018
|
+
this.emit('info', `Volume Control Type: ${volumeControlType}`);
|
|
1019
|
+
this.emit('info', `Picture Mode: ${PictureModesDenonNumber[pictureMode]}`);
|
|
1020
|
+
};
|
|
1021
|
+
})
|
|
1022
|
+
.on('success', (success) => {
|
|
1023
|
+
this.emit('success', success);
|
|
1024
|
+
})
|
|
1025
|
+
.on('info', (info) => {
|
|
1026
|
+
this.emit('info', info);
|
|
1027
|
+
})
|
|
1028
|
+
.on('debug', (debug) => {
|
|
1029
|
+
this.emit('debug', debug);
|
|
1030
|
+
})
|
|
1031
|
+
.on('warn', async (warn) => {
|
|
1032
|
+
this.emit('warn', warn);
|
|
1033
|
+
})
|
|
1034
|
+
.on('error', async (error) => {
|
|
1035
|
+
this.emit('error', error);
|
|
1036
|
+
})
|
|
1037
|
+
.on('restFul', (path, data) => {
|
|
1038
|
+
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
1039
|
+
})
|
|
1040
|
+
.on('mqtt', (topic, message) => {
|
|
1041
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
//connect to avr
|
|
1045
|
+
const connect = await this.denon.connect();
|
|
1046
|
+
if (!connect) {
|
|
1047
|
+
return false;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
//start external integrations
|
|
1051
|
+
const startExternalIntegrations = this.restFul.enable || this.mqtt.enable ? await this.externalIntegrations() : false;
|
|
1052
|
+
|
|
1053
|
+
//prepare data for accessory
|
|
1054
|
+
await this.prepareDataForAccessory();
|
|
1055
|
+
|
|
1056
|
+
//prepare accessory
|
|
1057
|
+
if (this.startPrepareAccessory) {
|
|
1058
|
+
const accessory = await this.prepareAccessory();
|
|
1059
|
+
this.emit('publishAccessory', accessory);
|
|
1060
|
+
this.startPrepareAccessory = false;
|
|
1061
|
+
|
|
1062
|
+
//start impulse generator
|
|
1063
|
+
await this.denon.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
return true;
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
throw new Error(`Start error: ${error}`);
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1079
1071
|
};
|
|
1080
1072
|
|
|
1081
1073
|
export default MainZone;
|