[hue] Catch exception of 'AllGroup' does not exist (#9502)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
ca64d1124a
commit
750ea5fd2d
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.hue.internal;
|
package org.openhab.binding.hue.internal;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -425,8 +426,6 @@ public class HueBridge {
|
|||||||
* @return all lights pseudo group
|
* @return all lights pseudo group
|
||||||
*/
|
*/
|
||||||
public Group getAllGroup() {
|
public Group getAllGroup() {
|
||||||
requireAuthentication();
|
|
||||||
|
|
||||||
return new Group();
|
return new Group();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,14 +447,21 @@ public class HueBridge {
|
|||||||
|
|
||||||
if (groupMap.get("0") == null) {
|
if (groupMap.get("0") == null) {
|
||||||
// Group 0 is not returned, we create it as in fact it exists
|
// 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()) {
|
groupMap.forEach((id, group) -> {
|
||||||
FullGroup group = groupMap.get(id);
|
|
||||||
group.setId(id);
|
group.setId(id);
|
||||||
groupList.add(group);
|
groupList.add(group);
|
||||||
}
|
});
|
||||||
|
|
||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@ public class HueBridgeHandler extends ConfigStatusBridgeHandler implements HueCl
|
|||||||
}
|
}
|
||||||
} catch (ApiException | IOException e) {
|
} catch (ApiException | IOException e) {
|
||||||
if (hueBridge != null && lastBridgeConnectionState) {
|
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;
|
lastBridgeConnectionState = false;
|
||||||
onConnectionLost();
|
onConnectionLost();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user