fixes #17121 (BLU Gateway), #17120 (NPE in cover mode) (#17122)

Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Markus Michels 2024-07-25 09:20:08 +02:00 committed by Ciprian Pascu
parent a21ee9de6f
commit 16c2b2ef74
6 changed files with 9 additions and 6 deletions

View File

@ -14,6 +14,7 @@ package org.openhab.binding.shelly.internal.api;
import static org.openhab.binding.shelly.internal.util.ShellyUtils.getString;
import java.io.EOFException;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.NoRouteToHostException;
@ -115,7 +116,7 @@ public class ShellyApiException extends Exception {
Class<?> exType = getCauseClass();
return isUnknownHost() || isMalformedURL() || exType == ConnectException.class
|| exType == SocketException.class || exType == PortUnreachableException.class
|| exType == NoRouteToHostException.class;
|| exType == NoRouteToHostException.class || exType == EOFException.class;
}
public boolean isNoRouteToHost() {

View File

@ -407,7 +407,7 @@ public class ShellyDeviceProfile {
public static boolean isGeneration2(String thingType) {
return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro") || thingType.contains("mini")
|| thingType.startsWith("shellywall") || (thingType.startsWith("shelly") && thingType.contains("g3"))
|| isBluSeries(thingType);
|| isBluSeries(thingType) || thingType.startsWith(THING_TYPE_SHELLYBLUGW_STR);
}
public static boolean isBluSeries(String thingType) {

View File

@ -210,7 +210,7 @@ public class Shelly1CoapHandler implements Shelly1CoapListener {
response.getSourceContext().getPeerAddress(), response.getMID(), response.getPayloadString());
}
if (thingHandler.isStopping()) {
logger.debug("{}: Thing is shutting down, ignore CoIOT message", thingName);
logger.debug("{}: Thing is not yet initialized / shutting down, ignore CoIOT message", thingName);
return;
}

View File

@ -477,7 +477,7 @@ public class Shelly2ApiClient extends ShellyHttpClient {
}
private void fillRollerFavorites(ShellyDeviceProfile profile, Shelly2GetConfigResult dc) {
if (dc.sys.uiData.cover != null) {
if (dc.sys.uiData.cover != null && !dc.sys.uiData.cover.isEmpty()) {
String[] favorites = dc.sys.uiData.cover.split(",");
profile.settings.favorites = new ArrayList<>();
for (int i = 0; i < favorites.length; i++) {

View File

@ -1481,6 +1481,8 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
logger.debug("{}: Device profile re-initialized (thingType={})", thingName, thingType);
}
}
} catch (ShellyApiException | RuntimeException e) {
logger.debug("{}: Unable to initialize Device Profile", thingName, e);
} finally {
refreshSettings = false;
}

View File

@ -48,7 +48,7 @@ public class ShellyDeviceProfileTest {
Arguments.of(THING_TYPE_SHELLYBLUDW_STR, true, true), //
Arguments.of(THING_TYPE_SHELLYBLUMOTION_STR, true, true), //
Arguments.of(THING_TYPE_SHELLYBLUHT_STR, true, true), //
Arguments.of(THING_TYPE_SHELLYBLUGW_STR, false, false), //
Arguments.of(THING_TYPE_SHELLYBLUGW_STR, true, false), //
// Shelly Bulb
Arguments.of(THING_TYPE_SHELLYBULB_STR, false, false), //
// Generation 1