Skip to content

Commit

Permalink
[lgwebos] Fix initialize and dispose (openhab#7301)
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored and andrewfg committed Aug 31, 2020
1 parent b291bbf commit 5ae6411
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private LGWebOSConfiguration getLGWebOSConfig() {

@Override
public void initialize() {
logger.debug("Initializing handler for thing {}", getThing().getUID());
LGWebOSConfiguration c = getLGWebOSConfig();
logger.trace("Handler initialized with config {}", c);
String host = c.getHost();
Expand All @@ -135,11 +136,14 @@ public void initialize() {
s.setListener(this);
socket = s;

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "TV is off");

startReconnectJob();
}

@Override
public void dispose() {
logger.debug("Disposing handler for thing {}", getThing().getUID());
stopKeepAliveJob();
stopReconnectJob();

Expand All @@ -149,6 +153,7 @@ public void dispose() {
scheduler.execute(() -> s.disconnect()); // dispose should be none-blocking
}
socket = null;
config = null; // ensure config gets actually refreshed during re-initialization
super.dispose();
}

Expand Down

0 comments on commit 5ae6411

Please sign in to comment.