From 0c398fa8c23d75543714840656c159fea25ba962 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Sat, 6 Aug 2022 22:54:10 +0200 Subject: [PATCH] fix #124 --- CHANGELOG.md | 4 ++++ package-lock.json | 5 +++-- package.json | 2 +- src/lgwebos.js | 9 +++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4720438..471441d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [1.11.9] - (06.08.2022) +## Changes +- fix [#124](https://github.com/grzegorz914/homebridge-lgwebos-tv/issues/124) + ## [1.11.8] - (23.07.2022) ## Changes - refactor information service diff --git a/package-lock.json b/package-lock.json index 3cfb9cc..f053594 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "homebridge-lgwebos-tv", - "version": "1.11.6", + "version": "1.11.9", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.11.6", + "name": "homebridge-lgwebos-tv", + "version": "1.11.9", "license": "MIT", "dependencies": { "@mi-sec/wol": ">=1.0.13", diff --git a/package.json b/package.json index dd1d008..504c8e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "LG webOS TV", "name": "homebridge-lgwebos-tv", - "version": "1.11.8", + "version": "1.11.9", "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control LG webOS TV.", "license": "MIT", "author": "grzegorz914", diff --git a/src/lgwebos.js b/src/lgwebos.js index 66294ee..51f1aaa 100644 --- a/src/lgwebos.js +++ b/src/lgwebos.js @@ -56,6 +56,9 @@ class LGTV extends EventEmitter { }) .on('connect', (connection) => { this.connection = connection; + this.isConnected = true; + this.register(); + this.connection.on('error', (error) => { this.emit('error', `Connect to TV error: ${error}`); }) @@ -78,7 +81,7 @@ class LGTV extends EventEmitter { Object.keys(this.callbacks).forEach((cid) => { delete this.callbacks[cid]; }); - this.emit('powerState', this.isConnected, this.power, false, false); + this.emit('powerState', false, false, false, false); this.emit('audioState', 0, true, ''); this.emit('disconnect', 'Disconnected.'); @@ -86,8 +89,6 @@ class LGTV extends EventEmitter { this.connect(); }, 5000); }); - this.isConnected = true; - this.register(); }); this.connect(); }; @@ -270,7 +271,7 @@ class LGTV extends EventEmitter { this.emit('error', `Audio state error: ${error}, ${response.errorCode}`) } const volume = response.volume; - const mute = (response.mute == true); + const mute = this.power ? (response.mute == true) : true; const audioOutput = response.scenario; this.emit('audioState', volume, mute, audioOutput); const mqtt = this.mqttEnabled ? this.emit('mqtt', 'Audio State', JSON.stringify(response, null, 2)) : false;