homebridge-xbox-tv 3.7.5 → 3.7.6
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/index.js +23 -22
- package/package.json +1 -1
- package/src/xboxdevice.js +7 -13
package/index.js
CHANGED
|
@@ -47,7 +47,8 @@ class XboxPlatform {
|
|
|
47
47
|
const disableLogSuccess = device.disableLogSuccess || false;
|
|
48
48
|
const disableLogWarn = device.disableLogWarn || false;
|
|
49
49
|
const disableLogError = device.disableLogError || false;
|
|
50
|
-
|
|
50
|
+
if (enableDebugMode) log.info(`Device: ${host} ${deviceName}, did finish launching.`);
|
|
51
|
+
|
|
51
52
|
const config = {
|
|
52
53
|
...device,
|
|
53
54
|
xboxLiveId: 'removed',
|
|
@@ -58,7 +59,7 @@ class XboxPlatform {
|
|
|
58
59
|
passwd: 'removed'
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
if (enableDebugMode) log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}.`);
|
|
62
63
|
|
|
63
64
|
//check files exists, if not then create it
|
|
64
65
|
const postFix = host.split('.').join('');
|
|
@@ -84,58 +85,58 @@ class XboxPlatform {
|
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
} catch (error) {
|
|
87
|
-
|
|
88
|
+
if (!disableLogError) log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}.`);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
//xbox device
|
|
92
93
|
try {
|
|
93
94
|
const xboxDevice = new XboxDevice(api, device, authTokenFile, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile)
|
|
94
|
-
.on('publishAccessory', (accessory) => {
|
|
95
|
-
api.publishExternalAccessories(PluginName, [accessory]);
|
|
96
|
-
const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
97
|
-
})
|
|
98
95
|
.on('devInfo', (devInfo) => {
|
|
99
|
-
|
|
96
|
+
if (!disableLogDeviceInfo) log.info(devInfo);
|
|
100
97
|
})
|
|
101
98
|
.on('success', (success) => {
|
|
102
|
-
|
|
99
|
+
if (!disableLogSuccess) log.success(`Device: ${host} ${deviceName}, ${success}.`);
|
|
103
100
|
})
|
|
104
101
|
.on('info', (info) => {
|
|
105
|
-
|
|
102
|
+
if (!disableLogInfo) log.info(`Device: ${host} ${deviceName}, ${info}.`);
|
|
106
103
|
})
|
|
107
104
|
.on('debug', (debug) => {
|
|
108
|
-
|
|
105
|
+
if (enableDebugMode) log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
109
106
|
})
|
|
110
107
|
.on('warn', (warn) => {
|
|
111
|
-
|
|
108
|
+
if (!disableLogWarn) log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
|
|
112
109
|
})
|
|
113
110
|
.on('error', (error) => {
|
|
114
|
-
|
|
111
|
+
if (!disableLogError) log.error(`Device: ${host} ${deviceName}, ${error}.`);
|
|
115
112
|
});
|
|
116
113
|
|
|
117
114
|
//create impulse generator
|
|
118
115
|
const impulseGenerator = new ImpulseGenerator();
|
|
119
116
|
impulseGenerator.on('start', async () => {
|
|
120
117
|
try {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
const accessory = await xboxDevice.start();
|
|
119
|
+
if (accessory) {
|
|
120
|
+
api.publishExternalAccessories(PluginName, [accessory]);
|
|
121
|
+
if (!disableLogSuccess) log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
122
|
+
|
|
123
|
+
await impulseGenerator.stop();
|
|
124
|
+
await xboxDevice.startImpulseGenerator();
|
|
125
|
+
}
|
|
126
126
|
} catch (error) {
|
|
127
|
-
|
|
127
|
+
if (!disableLogError) log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
128
128
|
}
|
|
129
129
|
}).on('state', (state) => {
|
|
130
|
-
|
|
130
|
+
if (enableDebugMode) state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
//start impulse generator
|
|
134
134
|
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
135
135
|
} catch (error) {
|
|
136
|
-
|
|
136
|
+
if (!disableLogError) log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
|
|
139
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
139
140
|
}
|
|
140
141
|
});
|
|
141
142
|
}
|
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -107,7 +107,6 @@ class XboxDevice extends EventEmitter {
|
|
|
107
107
|
this.sensorsInputsServices = [];
|
|
108
108
|
this.buttonsServices = [];
|
|
109
109
|
this.inputIdentifier = 1;
|
|
110
|
-
this.startPrepareAccessory = true;
|
|
111
110
|
this.power = false;
|
|
112
111
|
this.volume = 0;
|
|
113
112
|
this.mute = false;
|
|
@@ -1075,10 +1074,10 @@ class XboxDevice extends EventEmitter {
|
|
|
1075
1074
|
this.emit('error', error);
|
|
1076
1075
|
})
|
|
1077
1076
|
.on('restFul', (path, data) => {
|
|
1078
|
-
|
|
1077
|
+
if (this.restFulConnected) this.restFul1.update(path, data);
|
|
1079
1078
|
})
|
|
1080
1079
|
.on('mqtt', (topic, message) => {
|
|
1081
|
-
|
|
1080
|
+
if (this.mqttConnected) this.mqtt1.emit('publish', topic, message);
|
|
1082
1081
|
});
|
|
1083
1082
|
|
|
1084
1083
|
//check authorization
|
|
@@ -1228,10 +1227,10 @@ class XboxDevice extends EventEmitter {
|
|
|
1228
1227
|
this.emit('error', error);
|
|
1229
1228
|
})
|
|
1230
1229
|
.on('restFul', (path, data) => {
|
|
1231
|
-
|
|
1230
|
+
if (this.restFulConnected) this.restFul1.update(path, data);
|
|
1232
1231
|
})
|
|
1233
1232
|
.on('mqtt', (topic, message) => {
|
|
1234
|
-
|
|
1233
|
+
if (this.mqttConnected) this.mqtt1.emit('publish', topic, message);
|
|
1235
1234
|
});
|
|
1236
1235
|
|
|
1237
1236
|
//connect to local api
|
|
@@ -1241,19 +1240,14 @@ class XboxDevice extends EventEmitter {
|
|
|
1241
1240
|
}
|
|
1242
1241
|
|
|
1243
1242
|
//start external integrations
|
|
1244
|
-
|
|
1243
|
+
if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
|
|
1245
1244
|
|
|
1246
1245
|
//prepare data for accessory
|
|
1247
1246
|
await this.prepareDataForAccessory();
|
|
1248
1247
|
|
|
1249
1248
|
//prepare accessory
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
this.emit('publishAccessory', accessory);
|
|
1253
|
-
this.startPrepareAccessory = false;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
return true;
|
|
1249
|
+
const accessory = await this.prepareAccessory();
|
|
1250
|
+
return accessory;
|
|
1257
1251
|
} catch (error) {
|
|
1258
1252
|
throw new Error(`Start error: ${error}`);
|
|
1259
1253
|
}
|