[remoteopenhab] Reduced response size from REST API items (#9284)

Related to #9281

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2020-12-07 23:38:29 +01:00 committed by GitHub
parent 12183f1c46
commit fea317a675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -324,7 +324,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"OH 1.x server not supported by the binding"); "OH 1.x server not supported by the binding");
} else if (getThing().getStatus() != ThingStatus.ONLINE) { } else if (getThing().getStatus() != ThingStatus.ONLINE) {
List<RemoteopenhabItem> items = restClient.getRemoteItems(); List<RemoteopenhabItem> items = restClient.getRemoteItems("name,type,groupType,state,stateDescription");
createChannels(items, true); createChannels(items, true);
setStateOptions(items); setStateOptions(items);

View File

@ -149,9 +149,12 @@ public class RemoteopenhabRestClient {
} }
} }
public List<RemoteopenhabItem> getRemoteItems() throws RemoteopenhabException { public List<RemoteopenhabItem> getRemoteItems(@Nullable String fields) throws RemoteopenhabException {
try { try {
String url = String.format("%s?recursive=false", getRestApiUrl("items")); String url = String.format("%s?recursive=false", getRestApiUrl("items"));
if (fields != null) {
url += "&fields=" + fields;
}
String jsonResponse = executeUrl(HttpMethod.GET, url, "application/json", null, null); String jsonResponse = executeUrl(HttpMethod.GET, url, "application/json", null, null);
if (jsonResponse.isEmpty()) { if (jsonResponse.isEmpty()) {
throw new RemoteopenhabException("JSON response is empty"); throw new RemoteopenhabException("JSON response is empty");