[remoteopenhab] Add all default translations to properties file (#11373)

Allows translating the remote openHAB binding strings with Crowdin.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-11-12 22:00:31 +01:00 committed by GitHub
parent 5c8e2a2bbf
commit 43b8aadf13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 181 additions and 58 deletions

View File

@ -33,6 +33,8 @@ import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.remoteopenhab.internal.handler.RemoteopenhabBridgeHandler;
import org.openhab.binding.remoteopenhab.internal.handler.RemoteopenhabThingHandler;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.i18n.LocaleProvider;
import org.openhab.core.i18n.TranslationProvider;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
@ -77,6 +79,8 @@ public class RemoteopenhabHandlerFactory extends BaseThingHandlerFactory {
private final RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider;
private final RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider;
private final Gson jsonParser;
private final TranslationProvider i18nProvider;
private final LocaleProvider localeProvider;
private HttpClient httpClientTrustingCert;
@ -85,7 +89,8 @@ public class RemoteopenhabHandlerFactory extends BaseThingHandlerFactory {
final @Reference ClientBuilder clientBuilder, final @Reference SseEventSourceFactory eventSourceFactory,
final @Reference RemoteopenhabChannelTypeProvider channelTypeProvider,
final @Reference RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider,
final @Reference RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider) {
final @Reference RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider,
final @Reference TranslationProvider i18nProvider, final @Reference LocaleProvider localeProvider) {
this.httpClient = httpClientFactory.getCommonHttpClient();
this.httpClientTrustingCert = httpClientFactory.createHttpClient(RemoteopenhabBindingConstants.BINDING_ID);
this.clientBuilder = clientBuilder;
@ -94,6 +99,8 @@ public class RemoteopenhabHandlerFactory extends BaseThingHandlerFactory {
this.stateDescriptionProvider = stateDescriptionProvider;
this.commandDescriptionProvider = commandDescriptionProvider;
this.jsonParser = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
this.i18nProvider = i18nProvider;
this.localeProvider = localeProvider;
try {
SSLContext sslContext = SSLContext.getInstance("SSL");
@ -200,7 +207,7 @@ public class RemoteopenhabHandlerFactory extends BaseThingHandlerFactory {
if (thingTypeUID.equals(RemoteopenhabBindingConstants.BRIDGE_TYPE_SERVER)) {
return new RemoteopenhabBridgeHandler((Bridge) thing, httpClient, httpClientTrustingCert, clientBuilder,
eventSourceFactory, channelTypeProvider, stateDescriptionProvider, commandDescriptionProvider,
jsonParser);
jsonParser, i18nProvider, localeProvider);
} else if (RemoteopenhabBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
return new RemoteopenhabThingHandler(thing);
}

View File

@ -88,11 +88,10 @@ public class RemoteopenhabDiscoveryParticipant implements MDNSDiscoveryParticipa
String restPath = service.getPropertyString("uri");
ThingUID thingUID = getThingUID(service);
if (thingUID != null && ip != null && restPath != null) {
String label = "openHAB server";
logger.debug("Create a DiscoveryResult for remote openHAB server {} with IP {}", thingUID, ip);
Map<String, Object> properties = Map.of(HOST, ip, REST_PATH, restPath);
result = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withRepresentationProperty(HOST)
.withLabel(label).build();
.withLabel("@text/discovery.server.label").build();
}
return result;
}

View File

@ -93,7 +93,7 @@ public class RemoteopenhabDiscoveryService extends AbstractDiscoveryService
createDiscoveryResult(thing, bridgeUID);
}
} catch (RemoteopenhabException e) {
logger.debug("{}", e.getMessage());
logger.debug("Scan for remote things failed", e);
}
}
}

View File

@ -14,6 +14,7 @@ package org.openhab.binding.remoteopenhab.internal.exceptions;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.i18n.AbstractI18nException;
/**
* Exceptions thrown by this binding.
@ -22,17 +23,17 @@ import org.eclipse.jdt.annotation.Nullable;
*/
@NonNullByDefault
@SuppressWarnings("serial")
public class RemoteopenhabException extends Exception {
public class RemoteopenhabException extends AbstractI18nException {
public RemoteopenhabException(@Nullable String message) {
super(message);
}
public RemoteopenhabException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
public RemoteopenhabException(@Nullable Throwable cause) {
public RemoteopenhabException(Throwable cause) {
super(cause);
}
public RemoteopenhabException(String message, @Nullable Object @Nullable... msgParams) {
super(message, msgParams);
}
public RemoteopenhabException(String message, Throwable cause, @Nullable Object @Nullable... msgParams) {
super(message, cause, msgParams);
}
}

View File

@ -45,6 +45,8 @@ import org.openhab.binding.remoteopenhab.internal.exceptions.RemoteopenhabExcept
import org.openhab.binding.remoteopenhab.internal.listener.RemoteopenhabItemsDataListener;
import org.openhab.binding.remoteopenhab.internal.listener.RemoteopenhabStreamingDataListener;
import org.openhab.binding.remoteopenhab.internal.rest.RemoteopenhabRestClient;
import org.openhab.core.i18n.LocaleProvider;
import org.openhab.core.i18n.TranslationProvider;
import org.openhab.core.library.CoreItemFactory;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
@ -79,6 +81,8 @@ import org.openhab.core.types.StateDescriptionFragmentBuilder;
import org.openhab.core.types.StateOption;
import org.openhab.core.types.TypeParser;
import org.openhab.core.types.UnDefType;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.jaxrs.client.SseEventSourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -106,6 +110,9 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
private final RemoteopenhabChannelTypeProvider channelTypeProvider;
private final RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider;
private final RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider;
private final TranslationProvider i18nProvider;
private final LocaleProvider localeProvider;
private final Bundle bundle;
private final Object updateThingLock = new Object();
@ -120,13 +127,18 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
ClientBuilder clientBuilder, SseEventSourceFactory eventSourceFactory,
RemoteopenhabChannelTypeProvider channelTypeProvider,
RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider,
RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider, final Gson jsonParser) {
RemoteopenhabCommandDescriptionOptionProvider commandDescriptionProvider, final Gson jsonParser,
final TranslationProvider i18nProvider, final LocaleProvider localeProvider) {
super(bridge);
this.httpClientTrustingCert = httpClientTrustingCert;
this.channelTypeProvider = channelTypeProvider;
this.stateDescriptionProvider = stateDescriptionProvider;
this.commandDescriptionProvider = commandDescriptionProvider;
this.restClient = new RemoteopenhabRestClient(httpClient, clientBuilder, eventSourceFactory, jsonParser);
this.i18nProvider = i18nProvider;
this.localeProvider = localeProvider;
this.bundle = FrameworkUtil.getBundle(this.getClass());
this.restClient = new RemoteopenhabRestClient(httpClient, clientBuilder, eventSourceFactory, jsonParser,
i18nProvider);
}
@Override
@ -138,13 +150,13 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
String host = config.host.trim();
if (host.length() == 0) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Undefined server address setting in the thing configuration");
"@text/offline.config-error-undefined-host");
return;
}
String path = config.restPath.trim();
if (path.length() == 0 || !path.startsWith("/")) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Invalid REST API path setting in the thing configuration");
"@text/offline.config-error-invalid-rest-path");
return;
}
URL url;
@ -152,7 +164,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
url = new URL(config.useHttps ? "https" : "http", host, config.port, path);
} catch (MalformedURLException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Invalid REST URL built from the settings in the thing configuration");
"@text/offline.config-error-invalid-rest-url");
return;
}
@ -201,7 +213,8 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
channelUID.getId());
}
} catch (RemoteopenhabException e) {
logger.debug("{}", e.getMessage());
logger.debug("Handling command for channel {} failed: {}", channelUID.getId(),
e.getMessage(bundle, i18nProvider));
}
}
@ -235,12 +248,18 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
ChannelType channelType = channelTypeProvider.getChannelType(itemType, readOnly, pattern);
String label;
String description;
String defaultValue;
if (channelType == null) {
channelTypeUID = channelTypeProvider.buildNewChannelTypeUID(itemType);
logger.trace("Create the channel type {} for item type {} ({} and with pattern {})",
channelTypeUID, itemType, readOnly ? "read only" : "read write", pattern);
label = String.format("Remote %s Item", itemType);
description = String.format("An item of type %s from the remote server.", itemType);
defaultValue = String.format("Remote %s Item", itemType);
label = i18nProvider.getText(bundle, "channel-type.label", defaultValue,
localeProvider.getLocale(), itemType);
label = label != null && !label.isBlank() ? label : defaultValue;
description = i18nProvider.getText(bundle, "channel-type.description", defaultValue,
localeProvider.getLocale(), itemType);
description = description != null && !description.isBlank() ? description : defaultValue;
StateDescriptionFragmentBuilder stateDescriptionBuilder = StateDescriptionFragmentBuilder
.create().withReadOnly(readOnly);
if (!pattern.isEmpty()) {
@ -257,8 +276,13 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
}
ChannelUID channelUID = new ChannelUID(getThing().getUID(), item.name);
logger.trace("Create the channel {} of type {}", channelUID, channelTypeUID);
label = "Item " + item.name;
description = String.format("Item %s from the remote server.", item.name);
defaultValue = String.format("Item %s", item.name);
label = i18nProvider.getText(bundle, "channel.label", defaultValue, localeProvider.getLocale(),
item.name);
label = label != null && !label.isBlank() ? label : defaultValue;
description = i18nProvider.getText(bundle, "channel.description", defaultValue,
localeProvider.getLocale(), item.name);
description = description != null && !description.isBlank() ? description : defaultValue;
channels.add(ChannelBuilder.create(channelUID, itemType).withType(channelTypeUID)
.withKind(ChannelKind.STATE).withLabel(label).withDescription(description).build());
}
@ -356,7 +380,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
restClient.tryApi();
if (restClient.getRestApiVersion() == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"OH 1.x server not supported by the binding");
"@text/offline.config-error-unsupported-server");
} else if (getThing().getStatus() != ThingStatus.ONLINE) {
List<RemoteopenhabItem> items = restClient.getRemoteItems("name,type,groupType,state,stateDescription");
@ -370,8 +394,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
restartStreamingUpdates();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,
"Dynamic creation of the channels for the remote server items failed");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/offline.error-channels-creation");
stopStreamingUpdates();
}
} else if (restartSse) {
@ -379,8 +402,9 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
restartStreamingUpdates();
}
} catch (RemoteopenhabException e) {
logger.debug("{}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
logger.debug("checkConnection for thing {} failed: {}", getThing().getUID(),
e.getMessage(bundle, i18nProvider), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getRawMessage());
stopStreamingUpdates();
}
}
@ -454,12 +478,15 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
@Override
public void onDisconnected() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Disconected from the remote server");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error-disconnected");
}
@Override
public void onError(String message) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, message);
logger.debug("onError: {}", message);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error-receiving-events");
}
@Override

View File

@ -97,7 +97,7 @@ public class RemoteopenhabThingHandler extends BaseThingHandler implements Remot
String uid = getConfigThingUID();
if (uid.length() == 0) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Undefined thing UID setting in the thing configuration");
"@text/offline.config-error-undefined-thing-uid");
} else {
RemoteopenhabRestClient client = ((RemoteopenhabBridgeHandler) bridgeHandler).gestRestClient();
client.addThingsDataListener(this);
@ -114,8 +114,7 @@ public class RemoteopenhabThingHandler extends BaseThingHandler implements Remot
updateThingStatus(uid, statusInfo);
}
} catch (RemoteopenhabException e) {
logger.debug("{}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getRawMessage());
}
});
}

View File

@ -62,7 +62,10 @@ import org.openhab.binding.remoteopenhab.internal.exceptions.RemoteopenhabExcept
import org.openhab.binding.remoteopenhab.internal.listener.RemoteopenhabItemsDataListener;
import org.openhab.binding.remoteopenhab.internal.listener.RemoteopenhabStreamingDataListener;
import org.openhab.binding.remoteopenhab.internal.listener.RemoteopenhabThingsDataListener;
import org.openhab.core.i18n.TranslationProvider;
import org.openhab.core.types.Command;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.jaxrs.client.SseEventSourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -86,6 +89,8 @@ public class RemoteopenhabRestClient {
private final ClientBuilder clientBuilder;
private final SseEventSourceFactory eventSourceFactory;
private final Gson jsonParser;
private final TranslationProvider i18nProvider;
private final Bundle bundle;
private final Object startStopLock = new Object();
private final List<RemoteopenhabStreamingDataListener> listeners = new CopyOnWriteArrayList<>();
@ -108,11 +113,14 @@ public class RemoteopenhabRestClient {
private long lastEventTimestamp;
public RemoteopenhabRestClient(final HttpClient httpClient, final ClientBuilder clientBuilder,
final SseEventSourceFactory eventSourceFactory, final Gson jsonParser) {
final SseEventSourceFactory eventSourceFactory, final Gson jsonParser,
final TranslationProvider i18nProvider) {
this.httpClient = httpClient;
this.clientBuilder = clientBuilder;
this.eventSourceFactory = eventSourceFactory;
this.jsonParser = jsonParser;
this.i18nProvider = i18nProvider;
this.bundle = FrameworkUtil.getBundle(this.getClass());
this.accessToken = "";
this.credentialToken = "";
}
@ -124,7 +132,7 @@ public class RemoteopenhabRestClient {
public String getRestUrl() throws RemoteopenhabException {
String url = restUrl;
if (url == null) {
throw new RemoteopenhabException("REST client not correctly setup");
throw new RemoteopenhabException("@text/exception.rest-client-not-setup");
}
return url;
}
@ -153,7 +161,7 @@ public class RemoteopenhabRestClient {
try {
String jsonResponse = executeGetUrl(getRestUrl(), "application/json", false, false);
if (jsonResponse.isEmpty()) {
throw new RemoteopenhabException("JSON response is empty");
throw new RemoteopenhabException("@text/exception.json-response-empty");
}
RemoteopenhabRestApi restApi = jsonParser.fromJson(jsonResponse, RemoteopenhabRestApi.class);
restApiVersion = restApi.version;
@ -168,7 +176,7 @@ public class RemoteopenhabRestClient {
topicNamespace = restApi.runtimeInfo != null ? "openhab" : "smarthome";
logger.debug("topic namespace = {}", topicNamespace);
} catch (RemoteopenhabException | JsonSyntaxException e) {
throw new RemoteopenhabException("Failed to execute the root REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/exception.root-rest-api-failed", e);
}
}
@ -181,12 +189,11 @@ public class RemoteopenhabRestClient {
boolean asyncReading = fields == null || Arrays.asList(fields.split(",")).contains("state");
String jsonResponse = executeGetUrl(url, "application/json", false, asyncReading);
if (jsonResponse.isEmpty()) {
throw new RemoteopenhabException("JSON response is empty");
throw new RemoteopenhabException("@text/exception.json-response-empty");
}
return Arrays.asList(jsonParser.fromJson(jsonResponse, RemoteopenhabItem[].class));
} catch (RemoteopenhabException | JsonSyntaxException e) {
throw new RemoteopenhabException(
"Failed to get the list of remote items using the items REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/exception.get-list-items-api-failed", e);
}
}
@ -195,8 +202,7 @@ public class RemoteopenhabRestClient {
String url = String.format("%s/%s/state", getRestApiUrl("items"), itemName);
return executeGetUrl(url, "text/plain", false, true);
} catch (RemoteopenhabException e) {
throw new RemoteopenhabException("Failed to get the state of remote item " + itemName
+ " using the items REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/get-item-state-api-failed", e, itemName);
}
}
@ -206,8 +212,7 @@ public class RemoteopenhabRestClient {
executeUrl(HttpMethod.POST, url, "application/json", command.toFullString(), "text/plain", false, false,
true);
} catch (RemoteopenhabException e) {
throw new RemoteopenhabException("Failed to send command to the remote item " + itemName
+ " using the items REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/exception.send-item-command-api-failed", e, itemName);
}
}
@ -215,12 +220,11 @@ public class RemoteopenhabRestClient {
try {
String jsonResponse = executeGetUrl(getRestApiUrl("things"), "application/json", true, false);
if (jsonResponse.isEmpty()) {
throw new RemoteopenhabException("JSON response is empty");
throw new RemoteopenhabException("@text/exception.json-response-empty");
}
return Arrays.asList(jsonParser.fromJson(jsonResponse, RemoteopenhabThing[].class));
} catch (RemoteopenhabException | JsonSyntaxException e) {
throw new RemoteopenhabException(
"Failed to get the list of remote things using the things REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/exception.get-list-things-api-failed", e);
}
}
@ -229,12 +233,11 @@ public class RemoteopenhabRestClient {
String url = String.format("%s/%s", getRestApiUrl("things"), uid);
String jsonResponse = executeGetUrl(url, "application/json", true, false);
if (jsonResponse.isEmpty()) {
throw new RemoteopenhabException("JSON response is empty");
throw new RemoteopenhabException("@text/exception.json-response-empty");
}
return Objects.requireNonNull(jsonParser.fromJson(jsonResponse, RemoteopenhabThing.class));
} catch (RemoteopenhabException | JsonSyntaxException e) {
throw new RemoteopenhabException(
"Failed to get the remote thing " + uid + " using the things REST API: " + e.getMessage(), e);
throw new RemoteopenhabException("@text/exception.get-thing-api-failed", e, uid);
}
}
@ -330,7 +333,7 @@ public class RemoteopenhabRestClient {
"%s?topics=%s/items/*/*,%s/things/*/*,%s/channels/*/triggered,openhab/channels/*/descriptionchanged",
getRestApiUrl("events"), getTopicNamespace(), getTopicNamespace(), getTopicNamespace());
} catch (RemoteopenhabException e) {
logger.debug("{}", e.getMessage());
logger.debug("reopenEventSource failed: {}", e.getMessage(bundle, i18nProvider));
return;
}
@ -536,7 +539,7 @@ public class RemoteopenhabRestClient {
int expectedNbParts = "GroupItemStateChangedEvent".equals(eventType) ? 5 : 4;
if (parts.length != expectedNbParts || !getTopicNamespace().equals(parts[0]) || !"items".equals(parts[1])
|| !finalPart.equals(parts[parts.length - 1])) {
throw new RemoteopenhabException("Invalid event topic " + topic + " for event type " + eventType);
throw new RemoteopenhabException("@text/exception.invalid-event-topic", topic, eventType);
}
return parts[2];
}
@ -547,7 +550,7 @@ public class RemoteopenhabRestClient {
int expectedNbParts = 4;
if (parts.length != expectedNbParts || !getTopicNamespace().equals(parts[0]) || !"things".equals(parts[1])
|| !finalPart.equals(parts[parts.length - 1])) {
throw new RemoteopenhabException("Invalid event topic " + topic + " for event type " + eventType);
throw new RemoteopenhabException("@text/exception.invalid-event-topic", topic, eventType);
}
return parts[2];
}
@ -595,7 +598,7 @@ public class RemoteopenhabRestClient {
if (statusCode != HttpStatus.OK_200) {
response.abort(new Exception(response.getReason()));
String statusLine = statusCode + " " + response.getReason();
throw new RemoteopenhabException("HTTP call failed: " + statusLine);
throw new RemoteopenhabException("@text/exception.http-call-failed", statusLine);
}
ByteArrayOutputStream responseContent = new ByteArrayOutputStream();
try (InputStream input = listener.getInputStream()) {
@ -613,11 +616,11 @@ public class RemoteopenhabRestClient {
provideAccessToken, asyncReading, retryIfEOF);
} else {
String statusLine = statusCode + " " + response.getReason();
throw new RemoteopenhabException("HTTP call failed: " + statusLine);
throw new RemoteopenhabException("@text/exception.http-call-failed", statusLine);
}
} else if (statusCode >= HttpStatus.BAD_REQUEST_400) {
String statusLine = statusCode + " " + response.getReason();
throw new RemoteopenhabException("HTTP call failed: " + statusLine);
throw new RemoteopenhabException("@text/exception.http-call-failed", statusLine);
}
String encoding = response.getEncoding() != null ? response.getEncoding().replaceAll("\"", "").trim()
: StandardCharsets.UTF_8.name();

View File

@ -0,0 +1,87 @@
# binding
binding.remoteopenhab.name = Remote openHAB Binding
binding.remoteopenhab.description = The Remote openHAB binding allows to communicate with remote openHAB servers.
# thing types
thing-type.remoteopenhab.server.label = Remote openHAB Server
thing-type.remoteopenhab.server.description = A remote openHAB server. You will find one channel for each item defined in the remote server.
thing-type.remoteopenhab.thing.label = Remote Thing
thing-type.remoteopenhab.thing.description = A thing from the remote openHAB server. You will find one channel for each trigger channel from the remote thing (state channels from the remote thing will be ignored).
# thing type configuration
thing-type.config.remoteopenhab.server.accessibilityInterval.label = Accessibility Interval
thing-type.config.remoteopenhab.server.accessibilityInterval.description = Minutes between checking the remote server accessibility. 0 to disable the check. Default is 3.
thing-type.config.remoteopenhab.server.aliveInterval.label = Alive Interval
thing-type.config.remoteopenhab.server.aliveInterval.description = Number of last minutes to consider when monitoring the receipt of events from the remote server. If an event is received during this interval, the remote server is considered alive and its accessibility will not be verified. Use 0 to disable this feature. Default is 5.
thing-type.config.remoteopenhab.server.authenticateAnyway.label = Authenticate Anyway
thing-type.config.remoteopenhab.server.authenticateAnyway.description = Set it to true in case you want to pass authentication information even when the communicate with the remote openHAB server is not secured (only HTTP). This is of course not recommended especially if your connection is over the Internet. Default is false.
thing-type.config.remoteopenhab.server.host.label = Server Address
thing-type.config.remoteopenhab.server.host.description = The host name or IP address of the remote openHAB server.
thing-type.config.remoteopenhab.server.password.label = Password
thing-type.config.remoteopenhab.server.password.description = The password to use when the remote openHAB server is setup to require basic authorization to run its REST API.
thing-type.config.remoteopenhab.server.port.label = Server HTTP Port
thing-type.config.remoteopenhab.server.port.description = The HTTP port to use to communicate with the remote openHAB server.
thing-type.config.remoteopenhab.server.restartIfNoActivity.label = Restart if no Activity
thing-type.config.remoteopenhab.server.restartIfNoActivity.description = Set it to true if you want to restart the connection (SSE) to the remote server when no events are received in the monitored interval. It is not necessary if the goal is to properly handle a short network outage (few seconds). This can be useful if you want to deal with a long network outage. Do not enable it if you remote server does not send events during the monitored interval under normal conditions, it will cause frequent restart of the connection and potential loss of events. Default is false.
thing-type.config.remoteopenhab.server.restPath.label = REST API Path
thing-type.config.remoteopenhab.server.restPath.description = The subpath of the REST API on the remote openHAB server.
thing-type.config.remoteopenhab.server.token.label = Token
thing-type.config.remoteopenhab.server.token.description = The token to use when the remote openHAB server is setup to require authorization to run its REST API.
thing-type.config.remoteopenhab.server.trustedCertificate.label = Trust SSL Certificate
thing-type.config.remoteopenhab.server.trustedCertificate.description = Set it to true in case you want to use HTTPS even without a valid SSL certificate provided by your remote server.
thing-type.config.remoteopenhab.server.useHttps.label = Use HTTPS
thing-type.config.remoteopenhab.server.useHttps.description = Set it to true in case you want to use HTTPS to communicate with the remote openHAB server. Default is false.
thing-type.config.remoteopenhab.server.username.label = Username
thing-type.config.remoteopenhab.server.username.description = The username to use when the remote openHAB server is setup to require basic authorization to run its REST API.
thing-type.config.remoteopenhab.thing.buildTriggerChannels.label = Automatic Trigger Channels Building
thing-type.config.remoteopenhab.thing.buildTriggerChannels.description = If set to true, a trigger channel will be automatically created and linked to each trigger channel from the remote thing.
thing-type.config.remoteopenhab.thing.thingUID.label = Remote Thing UID
thing-type.config.remoteopenhab.thing.thingUID.description = The thing UID in the remote openHAB server.
# channel types
channel-type.remoteopenhab.trigger.label = Trigger Channel
# channel type configuration
channel-type.config.remoteopenhab.trigger.channelUID.label = Remote Channel UID
channel-type.config.remoteopenhab.trigger.channelUID.description = The channel UID in the remote openHAB server.
# Thing status descriptions
offline.config-error-undefined-host = Undefined server address setting in the thing configuration
offline.config-error-invalid-rest-path = Invalid REST API path setting in the thing configuration
offline.config-error-invalid-rest-url = Invalid REST URL built from the settings in the thing configuration
offline.config-error-unsupported-server = OH 1.x server not supported by the binding
offline.config-error-undefined-thing-uid = Undefined thing UID setting in the thing configuration
offline.error-channels-creation = Dynamic creation of the channels for the remote server items failed
offline.comm-error-disconnected = Disconected from the remote server
offline.comm-error-receiving-events = Error occurred while receiving events
# Discovery result
discovery.server.label = openHAB server
# Exceptions
exception.rest-client-not-setup = REST client not correctly setup
exception.json-response-empty = JSON response is empty
exception.root-rest-api-failed = Failed to execute the root REST API
exception.get-list-items-api-failed = Failed to get the list of remote items using the items REST API
exception.get-item-state-api-failed = Failed to get the state of remote item {0} using the items REST API
exception.send-item-command-api-failed = Failed to send command to the remote item {0} using the items REST API
exception.get-list-things-api-failed = Failed to get the list of remote things using the things REST API
exception.get-thing-api-failed = Failed to get the remote thing {0} using the things REST API
exception.invalid-event-topic = Invalid event topic {0} for event type {1}
exception.http-call-failed = HTTP call failed: {0}
# Other texts
channel-type.label = Remote {0} Item
channel-type.description = An item of type {0} from the remote server.
channel.label = Item {0}
channel.description = Item {0} from the remote server.