]> git.basschouten.com Git - openhab-addons.git/commitdiff
[remoteopenhab] Reduced response size from REST API items (#9284)
authorlolodomo <lg.hc@free.fr>
Mon, 7 Dec 2020 22:38:29 +0000 (23:38 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Dec 2020 22:38:29 +0000 (14:38 -0800)
Related to #9281

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/handler/RemoteopenhabBridgeHandler.java
bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/rest/RemoteopenhabRestClient.java

index b6324ca66c7b9a0303a803efa17bfafe4026b093..93ec8bfd490be4a0e3fc46f336fefd8f5837ce11 100644 (file)
@@ -324,7 +324,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                         "OH 1.x server not supported by the binding");
             } else if (getThing().getStatus() != ThingStatus.ONLINE) {
-                List<RemoteopenhabItem> items = restClient.getRemoteItems();
+                List<RemoteopenhabItem> items = restClient.getRemoteItems("name,type,groupType,state,stateDescription");
 
                 createChannels(items, true);
                 setStateOptions(items);
index 85c4da437766f0740529127214132618ab769bf8..84ded57155eaff8da49bf7b505e3223d2e232cb9 100644 (file)
@@ -149,9 +149,12 @@ public class RemoteopenhabRestClient {
         }
     }
 
-    public List<RemoteopenhabItem> getRemoteItems() throws RemoteopenhabException {
+    public List<RemoteopenhabItem> getRemoteItems(@Nullable String fields) throws RemoteopenhabException {
         try {
             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);
             if (jsonResponse.isEmpty()) {
                 throw new RemoteopenhabException("JSON response is empty");