Skip to content

Commit

Permalink
fix #124
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Aug 6, 2022
1 parent 6569ffa commit 0c398fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 5 additions & 4 deletions src/lgwebos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
})
Expand All @@ -78,16 +81,14 @@ 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.');

setTimeout(() => {
this.connect();
}, 5000);
});
this.isConnected = true;
this.register();
});
this.connect();
};
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0c398fa

Please sign in to comment.