[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:
parent
12183f1c46
commit
fea317a675
|
@ -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);
|
||||||
|
|
|
@ -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");
|
||||||
|
|
Loading…
Reference in New Issue