homebridge-xbox-tv 3.7.7-beta.0 → 3.7.7
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 +20 -29
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -42,11 +42,14 @@ class XboxPlatform {
|
|
|
42
42
|
|
|
43
43
|
//log config
|
|
44
44
|
const enableDebugMode = device.enableDebugMode || false;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const logLevel = {
|
|
46
|
+
debug: enableDebugMode,
|
|
47
|
+
info: !device.disableLogInfo,
|
|
48
|
+
success: !device.disableLogSuccess,
|
|
49
|
+
warn: !device.disableLogWarn,
|
|
50
|
+
error: !device.disableLogError,
|
|
51
|
+
devInfo: !device.disableLogDeviceInfo,
|
|
52
|
+
};
|
|
50
53
|
if (enableDebugMode) log.info(`Device: ${host} ${deviceName}, did finish launching.`);
|
|
51
54
|
|
|
52
55
|
const config = {
|
|
@@ -85,31 +88,19 @@ class XboxPlatform {
|
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
} catch (error) {
|
|
88
|
-
if (
|
|
91
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}.`);
|
|
89
92
|
return;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
//xbox device
|
|
93
96
|
try {
|
|
94
97
|
const xboxDevice = new XboxDevice(api, device, authTokenFile, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile)
|
|
95
|
-
.on('devInfo', (
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
.on('
|
|
99
|
-
|
|
100
|
-
})
|
|
101
|
-
.on('info', (info) => {
|
|
102
|
-
if (!disableLogInfo) log.info(`Device: ${host} ${deviceName}, ${info}.`);
|
|
103
|
-
})
|
|
104
|
-
.on('debug', (debug) => {
|
|
105
|
-
if (enableDebugMode) log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
106
|
-
})
|
|
107
|
-
.on('warn', (warn) => {
|
|
108
|
-
if (!disableLogWarn) log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
|
|
109
|
-
})
|
|
110
|
-
.on('error', (error) => {
|
|
111
|
-
if (!disableLogError) log.error(`Device: ${host} ${deviceName}, ${error}.`);
|
|
112
|
-
});
|
|
98
|
+
.on('devInfo', (info) => logLevel.devInfo && log.info(info))
|
|
99
|
+
.on('success', (msg) => logLevel.success && log.success(`Device: ${host} ${deviceName}, ${msg}`))
|
|
100
|
+
.on('info', (msg) => logLevel.info && log.info(`Device: ${host} ${deviceName}, ${msg}`))
|
|
101
|
+
.on('debug', (msg) => logLevel.debug && log.info(`Device: ${host} ${deviceName}, debug: ${msg}`))
|
|
102
|
+
.on('warn', (msg) => logLevel.warn && log.warn(`Device: ${host} ${deviceName}, ${msg}`))
|
|
103
|
+
.on('error', (msg) => logLevel.error && log.error(`Device: ${host} ${deviceName}, ${msg}`));
|
|
113
104
|
|
|
114
105
|
//create impulse generator
|
|
115
106
|
const impulseGenerator = new ImpulseGenerator();
|
|
@@ -118,24 +109,24 @@ class XboxPlatform {
|
|
|
118
109
|
const accessory = await xboxDevice.start();
|
|
119
110
|
if (accessory) {
|
|
120
111
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
121
|
-
if (
|
|
112
|
+
if (logLevel.success) log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
122
113
|
|
|
123
114
|
await impulseGenerator.stop();
|
|
124
115
|
await xboxDevice.startImpulseGenerator();
|
|
125
116
|
}
|
|
126
117
|
} catch (error) {
|
|
127
|
-
if (
|
|
118
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
128
119
|
}
|
|
129
120
|
}).on('state', (state) => {
|
|
130
|
-
if (
|
|
121
|
+
if (logLevel.debug) state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
|
|
131
122
|
});
|
|
132
123
|
|
|
133
124
|
//start impulse generator
|
|
134
125
|
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
135
126
|
} catch (error) {
|
|
136
|
-
if (
|
|
127
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
137
128
|
}
|
|
138
|
-
|
|
129
|
+
|
|
139
130
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
140
131
|
}
|
|
141
132
|
});
|