Skip to content

Commit

Permalink
[lgwebos] Ignore power off command when the TV is already off (openha…
Browse files Browse the repository at this point in the history
…b#7300)

* [lgwebos] Ignore power off command when the TV is already off

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Hans-Reiner Hoffmann <[email protected]>
  • Loading branch information
lolodomo authored and Hans-Reiner committed Apr 11, 2020
1 parent cdbdd2e commit b0643c2
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
public class PowerControlPower extends BaseChannelHandler<CommandConfirmation> {
private final Logger logger = LoggerFactory.getLogger(PowerControlPower.class);

private boolean powerOn;

@Override
public void onReceiveCommand(String channelId, LGWebOSHandler handler, Command command) {
if (RefreshType.REFRESH == command) {
Expand All @@ -49,7 +51,11 @@ public void onReceiveCommand(String channelId, LGWebOSHandler handler, Command c
*/
handler.postUpdate(channelId, OnOffType.OFF);
} else if (OnOffType.OFF == command) {
handler.getSocket().powerOff(getDefaultResponseListener());
if (powerOn) {
handler.getSocket().powerOff(getDefaultResponseListener());
} else {
logger.debug("Received OFF - Ignored as the TV is already off.");
}
} else {
logger.info("Only accept OnOffType, RefreshType. Type was {}.", command.getClass());
}
Expand All @@ -58,11 +64,13 @@ public void onReceiveCommand(String channelId, LGWebOSHandler handler, Command c

@Override
public void onDeviceReady(String channelId, LGWebOSHandler handler) {
powerOn = true;
handler.postUpdate(channelId, OnOffType.ON);
}

@Override
public void onDeviceRemoved(String channelId, LGWebOSHandler handler) {
powerOn = false;
handler.postUpdate(channelId, OnOffType.OFF);
}
}

0 comments on commit b0643c2

Please sign in to comment.