Skip to content

Commit

Permalink
[hue] Catch exception of 'AllGroup' does not exist (openhab#9502)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp authored and thinkingstone committed Nov 7, 2021
1 parent 85da3a4 commit 35e8e9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.binding.hue.internal;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -425,8 +426,6 @@ public CompletableFuture<Result> updateSensorConfig(FullSensor sensor, ConfigUpd
* @return all lights pseudo group
*/
public Group getAllGroup() {
requireAuthentication();

return new Group();
}

Expand All @@ -448,14 +447,21 @@ public List<FullGroup> getGroups() throws IOException, ApiException {

if (groupMap.get("0") == null) {
// Group 0 is not returned, we create it as in fact it exists
groupList.add(getGroup(new Group()));
try {
groupList.add(getGroup(getAllGroup()));
} catch (FileNotFoundException e) {
// We need a special exception handling here to further support deCONZ REST API. On deCONZ group "0" may
// not exist and the APIs will return a different HTTP status code if requesting a non existing group
// (Hue: 200, deCONZ: 404).
// see https://github.com/openhab/openhab-addons/issues/9175
logger.debug("Cannot find AllGroup with id \"0\" on Hue Bridge. Skipping it.");
}
}

for (String id : groupMap.keySet()) {
FullGroup group = groupMap.get(id);
groupMap.forEach((id, group) -> {
group.setId(id);
groupList.add(group);
}
});

return groupList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void run() {
}
} catch (ApiException | IOException e) {
if (hueBridge != null && lastBridgeConnectionState) {
logger.debug("Connection to Hue Bridge {} lost.", hueBridge.getIPAddress());
logger.debug("Connection to Hue Bridge {} lost: {}", hueBridge.getIPAddress(), e.getMessage(), e);
lastBridgeConnectionState = false;
onConnectionLost();
}
Expand Down

0 comments on commit 35e8e9a

Please sign in to comment.