From 53b236e991b1f11ea6c65aaac1f8ee97a642a035 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Fri, 28 Jun 2024 19:51:14 +0200 Subject: [PATCH] cleanup --- config.schema.json | 58 ++++++++++++++++++++++---------------------- package.json | 2 +- src/lgwebossocket.js | 12 ++++++--- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/config.schema.json b/config.schema.json index dcbb0f4..266dcb2 100644 --- a/config.schema.json +++ b/config.schema.json @@ -1000,7 +1000,7 @@ } ], "description": "Here select what a volume control mode You want to use. If select *None/Disabled* only hardware buttons in RC app can be used to control volume.", - "required": true + "required": false }, "soundModeControl": { "title": "Sound Modes", @@ -1245,32 +1245,11 @@ "description": "This enable access to the service menu from input list.", "required": false }, - "ezAdjustMenu": { - "title": "EZ Adjust Menu", - "type": "boolean", - "default": false, - "description": "This enable access to the ez adjust menu from input list.", - "required": false - }, - "enableDebugMode": { - "title": "Debug", - "type": "boolean", - "default": false, - "description": "This enable debug mode.", - "required": false - }, - "disableLogInfo": { - "title": "Disable Log Info", - "type": "boolean", - "default": false, - "description": "This disable logging values and states on every it change.", - "required": false - }, - "disableLogDeviceInfo": { - "title": "Disable Log Device Info", + "sslWebSocket": { + "title": "SSL WebSocket", "type": "boolean", "default": false, - "description": "This disable log device info by every connections device to the network.", + "description": "This enable SSL WebSocket, support TV with new firmware.", "required": false }, "disableTvService": { @@ -1280,11 +1259,11 @@ "description": "This disable TV service and prevent display double services if TV already support HomeKit native.", "required": false }, - "sslWebSocket": { - "title": "SSL WebSocket", + "ezAdjustMenu": { + "title": "EZ Adjust Menu", "type": "boolean", "default": false, - "description": "This enable SSL WebSocket, support TV with new firmware.", + "description": "This enable access to the ez adjust menu from input list.", "required": false }, "infoButtonCommand": { @@ -1342,7 +1321,28 @@ } ], "description": "Here select the function of info button in RC.", - "required": true + "required": false + }, + "enableDebugMode": { + "title": "Debug", + "type": "boolean", + "default": false, + "description": "This enable debug mode.", + "required": false + }, + "disableLogInfo": { + "title": "Disable Log Info", + "type": "boolean", + "default": false, + "description": "This disable logging values and states on every it change.", + "required": false + }, + "disableLogDeviceInfo": { + "title": "Disable Log Device Info", + "type": "boolean", + "default": false, + "description": "This disable log device info by every connections device to the network.", + "required": false }, "enableRestFul": { "title": "Enable", diff --git a/package.json b/package.json index f9322a2..103fad6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "LG webOS TV", "name": "homebridge-lgwebos-tv", - "version": "2.19.8", + "version": "2.19.10", "description": "Homebridge plugin to control LG webOS TV.", "license": "MIT", "author": "grzegorz914", diff --git a/src/lgwebossocket.js b/src/lgwebossocket.js index 29e18ff..a9a8d17 100644 --- a/src/lgwebossocket.js +++ b/src/lgwebossocket.js @@ -120,12 +120,14 @@ class LgWebOsSocket extends EventEmitter { }; //Request specjalized socket - await new Promise(resolve => setTimeout(resolve, 2000)); + await new Promise(resolve => setTimeout(resolve, 1500)); + this.specjalizedSockedId = await this.getCid(); try { - this.specjalizedSockedId = await this.getCid(); await this.send('request', CONSTANTS.ApiUrls.SocketUrl, undefined, this.specjalizedSockedId); } catch (error) { - this.emit('error', `Request specjalized socket error: ${error}`); + this.emit('error', `Request specjalized socket error: ${error}.`); + await new Promise(resolve => setTimeout(resolve, 5000)); + await this.send('request', CONSTANTS.ApiUrls.SocketUrl, undefined, this.specjalizedSockedId); }; break; case 'error': @@ -160,9 +162,11 @@ class LgWebOsSocket extends EventEmitter { } catch (error) { this.emit('error', `Request system info error: ${error}`); }; - }).on('error', (error) => { + }).on('error', async (error) => { const debug = debugLog ? this.emit('debug', `Specjalized socket connect error: ${error}.`) : false; specializedSocket.emit('disconnect'); + await new Promise(resolve => setTimeout(resolve, 5000)); + await this.send('request', CONSTANTS.ApiUrls.SocketUrl, undefined, this.specjalizedSockedId); }).on('disconnect', () => { const message = this.specjalizedSocketConnected ? this.emit('message', 'Specjalized socket disconnected.') : false; this.specjalizedSocketConnected = false;