homebridge-lgwebos-tv 4.3.0 → 4.3.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/lgwebossocket.js +10 -14
package/package.json
CHANGED
package/src/lgwebossocket.js
CHANGED
|
@@ -2,7 +2,7 @@ import WebSocket from 'ws';
|
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
4
4
|
import Functions from './functions.js';
|
|
5
|
-
import { ApiUrls,
|
|
5
|
+
import { ApiUrls, PairingOld, PairingNew } from './constants.js';
|
|
6
6
|
|
|
7
7
|
class LgWebOsSocket extends EventEmitter {
|
|
8
8
|
constructor(config, keyFile, devInfoFile, inputsFile, channelsFile, restFulEnabled, mqttEnabled) {
|
|
@@ -139,11 +139,11 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
async registerToTv() {
|
|
142
|
+
async registerToTv(PairingData) {
|
|
143
143
|
try {
|
|
144
|
-
|
|
144
|
+
PairingData['client-key'] = this.pairingKey;
|
|
145
145
|
this.registerId = await this.getCid();
|
|
146
|
-
await this.send('register', undefined,
|
|
146
|
+
await this.send('register', undefined, PairingData, this.registerId);
|
|
147
147
|
return;
|
|
148
148
|
} catch (err) {
|
|
149
149
|
if (this.logError) this.emit('error', `Socket register error: ${err}`);
|
|
@@ -172,10 +172,9 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
172
172
|
|
|
173
173
|
async applySoftwareInfoFallback() {
|
|
174
174
|
// Called when getCurrentSWInformation returns 401 (webOS 26+).
|
|
175
|
-
// If the endpoint is blocked, the TV is new enough to be treated as the latest webOS.
|
|
176
175
|
this.tvInfo.webOS = 26.0;
|
|
177
176
|
this.tvInfo.productName = 'webOSTV 26.0';
|
|
178
|
-
this.tvInfo.firmwareRevision = this.tvInfo.firmwareRevision || '
|
|
177
|
+
this.tvInfo.firmwareRevision = this.tvInfo.firmwareRevision || '40.xx.xx';
|
|
179
178
|
// deviceId was already filled from serialNumber in the systemInfo handler
|
|
180
179
|
|
|
181
180
|
if (this.logDebug) this.emit('debug', `Software info fallback (webOS 26+): deviceId=${this.tvInfo.deviceId}, model=${this.tvInfo.modelName}`);
|
|
@@ -342,6 +341,7 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
342
341
|
this.socket = socket;
|
|
343
342
|
this.emit('success', `Socket Connect Success`);
|
|
344
343
|
this.socketConnected = true;
|
|
344
|
+
await this.getSystemInfo();
|
|
345
345
|
|
|
346
346
|
this.heartbeat = setInterval(() => {
|
|
347
347
|
if (socket.readyState === socket.OPEN) {
|
|
@@ -354,8 +354,7 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
354
354
|
if (this.logDebug) this.emit('debug', `Socket received heartbeat`);
|
|
355
355
|
if (!this.socketOpen) {
|
|
356
356
|
this.socketOpen = true;
|
|
357
|
-
await this.
|
|
358
|
-
await this.registerToTv();
|
|
357
|
+
await this.registerToTv(PairingOld);
|
|
359
358
|
}
|
|
360
359
|
})
|
|
361
360
|
.on('message', async (message) => {
|
|
@@ -380,12 +379,13 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
380
379
|
this.emit('success', 'Pairing key saved');
|
|
381
380
|
}
|
|
382
381
|
await this.getSpecjalizedSocket();
|
|
382
|
+
await this.getSoftwareInfo();
|
|
383
383
|
break;
|
|
384
384
|
}
|
|
385
385
|
case 'error':
|
|
386
|
-
if (this.
|
|
386
|
+
if (this.logDebug) this.emit('debug', `Register to TV error: ${stringifyMessage}, trying new pairing method`);
|
|
387
387
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
388
|
-
await this.registerToTv();
|
|
388
|
+
await this.registerToTv(PairingNew);
|
|
389
389
|
break;
|
|
390
390
|
default:
|
|
391
391
|
if (this.logDebug) this.emit('debug', `Register to TV unknown message, type: ${messageType}, id: ${messageId}, data: ${stringifyMessage}`);
|
|
@@ -436,9 +436,7 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
436
436
|
if (this.logDebug) this.emit('debug', `System info: ${stringifyMessage}`);
|
|
437
437
|
this.tvInfo.modelName = messageData.modelName ?? 'LG TV';
|
|
438
438
|
// webOS 26+: getSystemInfo returns serialNumber instead of deviceId;
|
|
439
|
-
// store it now so the softwareInfo fallback has real data
|
|
440
439
|
this.tvInfo.deviceId = messageData.deviceId ?? messageData.serialNumber ?? this.tvInfo.deviceId;
|
|
441
|
-
await this.getSoftwareInfo();
|
|
442
440
|
if (this.restFulEnabled) this.emit('restFul', 'systeminfo', messageData);
|
|
443
441
|
if (this.mqttEnabled) this.emit('mqtt', 'System info', messageData);
|
|
444
442
|
break;
|
|
@@ -467,8 +465,6 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
467
465
|
case 'error':
|
|
468
466
|
// webOS 26+ blocks getCurrentSWInformation with 401 insufficient permissions.
|
|
469
467
|
// Fall back to data already harvested from getSystemInfo and derive
|
|
470
|
-
// the webOS version from the model name (e.g. C31 → 2023 → webOS 23,
|
|
471
|
-
// but firmware 40.x is shipped with webOS 26 via the Re:New program).
|
|
472
468
|
if (this.logDebug) this.emit('debug', `Software info blocked (likely webOS 26+ 401), applying fallback: ${stringifyMessage}`);
|
|
473
469
|
await this.applySoftwareInfoFallback();
|
|
474
470
|
break;
|