mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-31 13:34:22 +02:00
[squeezebox] Add I18N support for Thing status descriptions (#18344)
* Add I18N support for thing status descriptions Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
+14
-7
@@ -165,12 +165,13 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
|
|||||||
if (bridgeStatus == ThingStatus.OFFLINE) {
|
if (bridgeStatus == ThingStatus.OFFLINE) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
|
||||||
} else if (!this.connected) {
|
} else if (!this.connected) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE);
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
} else if (bridgeStatus == ThingStatus.ONLINE && getThing().getStatus() != ThingStatus.ONLINE) {
|
} else if (bridgeStatus == ThingStatus.ONLINE && getThing().getStatus() != ThingStatus.ONLINE) {
|
||||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Bridge not found");
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
|
"@text/offline.conf-error.bridge-not-found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,18 +486,24 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
|
|||||||
// Only get the image if this is my PlayerHandler instance
|
// Only get the image if this is my PlayerHandler instance
|
||||||
if (isMe(mac)) {
|
if (isMe(mac)) {
|
||||||
if (url != null && !url.isEmpty()) {
|
if (url != null && !url.isEmpty()) {
|
||||||
String sanitizedUrl = sanitizeUrl(url);
|
|
||||||
RawType image = IMAGE_CACHE.putIfAbsentAndGet(url, () -> {
|
RawType image = IMAGE_CACHE.putIfAbsentAndGet(url, () -> {
|
||||||
logger.debug("Trying to download the content of URL {}", sanitizedUrl);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Trying to download the content of URL {}", sanitizeUrl(url));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return HttpUtil.downloadImage(url);
|
return HttpUtil.downloadImage(url);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.debug("IllegalArgumentException when downloading image from {}", sanitizedUrl, e);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("IllegalArgumentException when downloading image from {}", sanitizeUrl(url),
|
||||||
|
e);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
logger.debug("Failed to download the content of URL {}", sanitizedUrl);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Failed to download the content of URL {}", sanitizeUrl(url));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return image;
|
return image;
|
||||||
|
|||||||
+12
-8
@@ -389,7 +389,8 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
this.password = config.password;
|
this.password = config.password;
|
||||||
|
|
||||||
if (host.isEmpty()) {
|
if (host.isEmpty()) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "host is not set");
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
|
||||||
|
"@text/offline.conf-error.host-not-set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create URL for jsonrpc interface
|
// Create URL for jsonrpc interface
|
||||||
@@ -486,7 +487,6 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (!terminate) {
|
if (!terminate) {
|
||||||
logger.warn("failed to read line from squeeze server socket: {}", e.getMessage());
|
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
||||||
scheduleReconnect();
|
scheduleReconnect();
|
||||||
}
|
}
|
||||||
@@ -503,9 +503,8 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
// check for end of stream from readLine
|
// check for end of stream from readLine
|
||||||
if (endOfStream && !terminate) {
|
if (endOfStream && !terminate) {
|
||||||
logger.info("end of stream received from socket during readLine");
|
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
"end of stream on socket read");
|
"@text/offline.comm-error.end-of-stream");
|
||||||
scheduleReconnect();
|
scheduleReconnect();
|
||||||
}
|
}
|
||||||
if (requestFavoritesJob != null && !requestFavoritesJob.isDone()) {
|
if (requestFavoritesJob != null && !requestFavoritesJob.isDone()) {
|
||||||
@@ -648,8 +647,9 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.trace("Unhandled mixer message type '{}'", Arrays.toString(messageParts));
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("Unhandled mixer message type '{}'", Arrays.toString(messageParts));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +666,9 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
} else if ("disconnect".equals(action) || "forget".equals(action)) {
|
} else if ("disconnect".equals(action) || "forget".equals(action)) {
|
||||||
connected = false;
|
connected = false;
|
||||||
} else {
|
} else {
|
||||||
logger.trace("Unhandled client message type '{}'", Arrays.toString(messageParts));
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("Unhandled client message type '{}'", Arrays.toString(messageParts));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,7 +878,9 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Added so that actions (such as delete, index, jump, open) are not treated as "play"
|
// Added so that actions (such as delete, index, jump, open) are not treated as "play"
|
||||||
logger.trace("Unhandled playlist message type '{}'", Arrays.toString(messageParts));
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("Unhandled playlist message type '{}'", Arrays.toString(messageParts));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String value = mode;
|
final String value = mode;
|
||||||
|
|||||||
+6
@@ -111,3 +111,9 @@ channel-type.squeezebox.year.description = Release year of the current song
|
|||||||
|
|
||||||
channel-type.config.squeezebox.favoritesList.quoteList.label = Quote Favorites
|
channel-type.config.squeezebox.favoritesList.quoteList.label = Quote Favorites
|
||||||
channel-type.config.squeezebox.favoritesList.quoteList.description = Wrap the right hand side of the favorites in quotes
|
channel-type.config.squeezebox.favoritesList.quoteList.description = Wrap the right hand side of the favorites in quotes
|
||||||
|
|
||||||
|
# thing status descriptions
|
||||||
|
|
||||||
|
offline.conf-error.bridge-not-found = Bridge not found
|
||||||
|
offline.conf-error.host-not-set = host is not set
|
||||||
|
offline.comm-error.end-of-stream = end of stream on socket read
|
||||||
|
|||||||
Reference in New Issue
Block a user