From 69a755ea31ebe6dac60b4a9bb4d78a373027b100 Mon Sep 17 00:00:00 2001 From: Karel Goderis Date: Sat, 7 Feb 2015 11:32:06 +0100 Subject: [PATCH 1/2] Fix bug in playLineIn() Signed-off-by: Karel Goderis --- .../openhab/binding/sonos/handler/ZonePlayerHandler.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java index 3469bd9858b9c..49aa210177734 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java @@ -1241,11 +1241,8 @@ public void playLineIn(Command command) { if (command != null && command instanceof StringType) { String remotePlayerName = command.toString(); - - Thing coordinatorThing = thingRegistry.get(new ThingUID( - ZONEPLAYER_THING_TYPE_UID, getCoordinator())); - ZonePlayerHandler coordinatorHandler = (ZonePlayerHandler) coordinatorThing - .getHandler(); + String coordinatorUDN = getCoordinator(); + ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinatorUDN); ZonePlayerHandler remoteHandler = getHandlerByName(remotePlayerName); // stop whatever is currently playing From b490af240e5a07d10091e075e7c4c70963996f5e Mon Sep 17 00:00:00 2001 From: Karel Goderis Date: Sat, 7 Feb 2015 11:33:23 +0100 Subject: [PATCH 2/2] Improve error handling in playLineIn() Signed-off-by: Karel Goderis --- .../sonos/handler/ZonePlayerHandler.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java index 49aa210177734..843d7ee66572f 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java @@ -1245,18 +1245,21 @@ public void playLineIn(Command command) { ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinatorUDN); ZonePlayerHandler remoteHandler = getHandlerByName(remotePlayerName); - // stop whatever is currently playing - coordinatorHandler.stop(); + if(coordinatorHandler!=null && remoteHandler!=null) { - // set the URI - coordinatorHandler.setCurrentURI("x-rincon-stream:" - + remoteHandler.getConfig().get(UDN), ""); + // stop whatever is currently playing + coordinatorHandler.stop(); - // take the system off mute - coordinatorHandler.setMute(OnOffType.OFF); + // set the URI + coordinatorHandler.setCurrentURI("x-rincon-stream:" + + remoteHandler.getConfig().get(UDN), ""); - // start jammin' - coordinatorHandler.play(); + // take the system off mute + coordinatorHandler.setMute(OnOffType.OFF); + + // start jammin' + coordinatorHandler.play(); + } } }