homebridge-xbox-tv 2.11.0 → 2.11.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/package.json +1 -1
- package/src/xboxdevice.js +27 -23
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -274,7 +274,8 @@ class XboxDevice extends EventEmitter {
|
|
|
274
274
|
}
|
|
275
275
|
})
|
|
276
276
|
.on('stateChanged', (power, volume, mute, mediaState, titleId, reference) => {
|
|
277
|
-
const
|
|
277
|
+
const inputIdentifierR = this.inputsConfigured.findIndex(index => index.reference === reference) + 1 ?? 0;
|
|
278
|
+
const inputIdentifier = inputIdentifierR > 0 ? inputIdentifierR : this.inputsConfigured.findIndex(index => index.titleId === titleId) + 1;
|
|
278
279
|
|
|
279
280
|
//update characteristics
|
|
280
281
|
if (this.televisionService) {
|
|
@@ -282,10 +283,9 @@ class XboxDevice extends EventEmitter {
|
|
|
282
283
|
.updateCharacteristic(Characteristic.Active, power)
|
|
283
284
|
};
|
|
284
285
|
|
|
285
|
-
if (this.televisionService && inputIdentifier
|
|
286
|
+
if (this.televisionService && inputIdentifier > 0) {
|
|
286
287
|
this.televisionService
|
|
287
288
|
.updateCharacteristic(Characteristic.ActiveIdentifier, inputIdentifier);
|
|
288
|
-
this.inputIdentifier = inputIdentifier;
|
|
289
289
|
};
|
|
290
290
|
|
|
291
291
|
if (this.speakerService) {
|
|
@@ -309,37 +309,40 @@ class XboxDevice extends EventEmitter {
|
|
|
309
309
|
.updateCharacteristic(Characteristic.ContactSensorState, power)
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
if (this.sensorInputService && inputIdentifier
|
|
312
|
+
if (this.sensorInputService && inputIdentifier > 0) {
|
|
313
313
|
const state = power ? (this.inputIdentifier !== inputIdentifier) : false;
|
|
314
314
|
this.sensorInputService
|
|
315
315
|
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
316
316
|
this.sensorInputState = state;
|
|
317
|
-
this.inputIdentifier = inputIdentifier;
|
|
318
317
|
}
|
|
319
318
|
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
this.sensorScreenSaverService
|
|
323
|
-
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
324
|
-
this.sensorScreenSaverState = state;
|
|
325
|
-
}
|
|
319
|
+
if (reference !== undefined) {
|
|
320
|
+
this.reference = reference;
|
|
326
321
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
322
|
+
if (this.sensorScreenSaverService) {
|
|
323
|
+
const state = power ? (reference === 'Xbox.IdleScreen_8wekyb3d8bbwe!Xbox.IdleScreen.Application') : false;
|
|
324
|
+
this.sensorScreenSaverService
|
|
325
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
326
|
+
this.sensorScreenSaverState = state;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (this.sensorInputsServices) {
|
|
330
|
+
const servicesCount = this.sensorInputsServices.length;
|
|
331
|
+
for (let i = 0; i < servicesCount; i++) {
|
|
332
|
+
const state = power ? (this.sensorInputs[i].reference === reference) : false;
|
|
333
|
+
const displayType = this.sensorInputs[i].displayType;
|
|
334
|
+
const characteristicType = [Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
|
|
335
|
+
this.sensorInputsServices[i]
|
|
336
|
+
.updateCharacteristic(characteristicType, state);
|
|
337
|
+
}
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
340
|
|
|
341
|
+
this.inputIdentifier = inputIdentifier > 0 ? inputIdentifier : this.inputIdentifier;
|
|
338
342
|
this.power = power;
|
|
339
343
|
this.volume = volume;
|
|
340
344
|
this.mute = mute;
|
|
341
345
|
this.mediaState = mediaState;
|
|
342
|
-
this.reference = reference;
|
|
343
346
|
|
|
344
347
|
const obj = {
|
|
345
348
|
'power': power,
|
|
@@ -500,9 +503,10 @@ class XboxDevice extends EventEmitter {
|
|
|
500
503
|
})
|
|
501
504
|
.onSet(async (inputIdentifier) => {
|
|
502
505
|
try {
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
const
|
|
506
|
+
const identifier = inputIdentifier - 1;
|
|
507
|
+
const inputOneStoreProductId = this.inputsConfigured[identifier].oneStoreProductId;
|
|
508
|
+
const inputReference = this.inputsConfigured[identifier].reference;
|
|
509
|
+
const inputName = this.inputsConfigured[identifier].name;
|
|
506
510
|
|
|
507
511
|
let channelName;
|
|
508
512
|
let command;
|