Skip to content

Commit

Permalink
[chromecast] Fix STOP command
Browse files Browse the repository at this point in the history
Fixes openhab#14516

Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
lsiepel authored and austvik committed Mar 27, 2024
1 parent d2f84a8 commit efb25d8
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,18 @@ public void handleRefresh() {

public void handleCloseApp(final Command command) {
if (command == OnOffType.ON) {
closeApp(MEDIA_PLAYER);
Application app;
try {
app = chromeCast.getRunningApp();
} catch (final IOException e) {
logger.info("{} command failed: {}", command, e.getMessage());
statusUpdater.updateStatus(ThingStatus.OFFLINE, COMMUNICATION_ERROR, e.getMessage());
return;
}

if (app != null) {
closeApp(app.id);
}
}
}

Expand Down Expand Up @@ -250,13 +261,13 @@ public void closeApp(@Nullable String appId) {
try {
if (chromeCast.isAppRunning(appId)) {
Application app = chromeCast.getRunningApp();
if (app.id.equals(appId) && app.sessionId.equals(statusUpdater.getAppSessionId())) {
if (app.id.equals(appId)) {
chromeCast.stopApp();
logger.debug("Application closed: {}", appId);
}
}
} catch (final IOException e) {
logger.debug("Failed stopping media player app: {} with message: {}", appId, e.getMessage());
logger.debug("Failed stopping app: {} with message: {}", appId, e.getMessage());
}
}

Expand Down

0 comments on commit efb25d8

Please sign in to comment.