diff --git a/extensions/binding/org.eclipse.smarthome.binding.sonos/ESH-INF/config/config.xml b/extensions/binding/org.eclipse.smarthome.binding.sonos/ESH-INF/config/config.xml index d1999f29d0f..36b8915c711 100644 --- a/extensions/binding/org.eclipse.smarthome.binding.sonos/ESH-INF/config/config.xml +++ b/extensions/binding/org.eclipse.smarthome.binding.sonos/ESH-INF/config/config.xml @@ -9,11 +9,11 @@ The UDN identifies the Zone Player. true - + - Specifies the amount of time for which the notification sound will be played - 40 - true + Specifies the amount of time in seconds for which the notification sound will be played + second + 20 diff --git a/extensions/binding/org.eclipse.smarthome.binding.sonos/src/main/java/org/eclipse/smarthome/binding/sonos/handler/ZonePlayerHandler.java b/extensions/binding/org.eclipse.smarthome.binding.sonos/src/main/java/org/eclipse/smarthome/binding/sonos/handler/ZonePlayerHandler.java index b07651235b3..e6a4002283a 100644 --- a/extensions/binding/org.eclipse.smarthome.binding.sonos/src/main/java/org/eclipse/smarthome/binding/sonos/handler/ZonePlayerHandler.java +++ b/extensions/binding/org.eclipse.smarthome.binding.sonos/src/main/java/org/eclipse/smarthome/binding/sonos/handler/ZonePlayerHandler.java @@ -37,7 +37,6 @@ import org.eclipse.smarthome.binding.sonos.internal.SonosXMLParser; import org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup; import org.eclipse.smarthome.binding.sonos.internal.SonosZonePlayerState; -import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.discovery.DiscoveryServiceRegistry; import org.eclipse.smarthome.core.library.types.DecimalType; import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; @@ -101,12 +100,12 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici private static final int SOCKET_TIMEOUT = 5000; /** - * Default notification timeout + * Default notification timeout (in seconds) */ - private static final Integer DEFAULT_NOTIFICATION_TIMEOUT = 40000; - + private static final Integer DEFAULT_NOTIFICATION_TIMEOUT = 20; + /** - * configurable notification timeout + * configurable notification timeout (in seconds) */ private Integer notificationTimeout = null; @@ -212,15 +211,12 @@ public void initialize() { if (getUDN() != null) { onUpdate(); - - if (getConfigAs(ZonePlayerConfiguration.class).notificationTimeout == null) { - Configuration c = editConfiguration(); - c.put(ZonePlayerConfiguration.NOTIFICATION_TIMEOUT, DEFAULT_NOTIFICATION_TIMEOUT); - updateConfiguration(c); - } - + this.notificationTimeout = getConfigAs(ZonePlayerConfiguration.class).notificationTimeout; - + if (this.notificationTimeout == null) { + this.notificationTimeout = DEFAULT_NOTIFICATION_TIMEOUT; + } + super.initialize(); } else { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR); @@ -2388,7 +2384,7 @@ private void waitForFinishedNotification() { // check Sonos state events to determine the end of the notification sound String notificationTitle = stateMap.get("CurrentTitle"); long playstart = System.currentTimeMillis(); - while (System.currentTimeMillis() - playstart < this.notificationTimeout.longValue()) { + while (System.currentTimeMillis() - playstart < this.notificationTimeout.longValue() * 1000) { try { Thread.sleep(50); if (!notificationTitle.equals(stateMap.get("CurrentTitle")) @@ -2407,7 +2403,7 @@ private void waitForTransportState(String state) { while (!stateMap.get("TransportState").equals(state)) { try { Thread.sleep(50); - if (System.currentTimeMillis() - start > this.notificationTimeout.longValue()) { + if (System.currentTimeMillis() - start > this.notificationTimeout.longValue() * 1000) { break; } } catch (InterruptedException e) { @@ -2423,7 +2419,7 @@ private void waitForNotTransportState(String state) { while (stateMap.get("TransportState").equals(state)) { try { Thread.sleep(50); - if (System.currentTimeMillis() - start > this.notificationTimeout.longValue()) { + if (System.currentTimeMillis() - start > this.notificationTimeout.longValue() * 1000) { break; } } catch (InterruptedException e) {