]> git.basschouten.com Git - openhab-addons.git/commitdiff
fixes #17121 (BLU Gateway), #17120 (NPE in cover mode) (#17122)
authorMarkus Michels <markus7017@gmail.com>
Thu, 25 Jul 2024 07:20:08 +0000 (09:20 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Jul 2024 07:20:08 +0000 (09:20 +0200)
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyApiException.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiClient.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfileTest.java

index 747676006528e59c7d8aeadc51b57030c9e6d9d6..50ceb22c4ed40d19b1370b6e69740294eb44d87e 100644 (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() {
index 8af0c403428e2da282cb5ebc443e525c9a8bf8bf..0e211e4a92d3e7feef42314ef384e1fa71527845 100644 (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) {
index d3fe61dc63f5d9841e49e5abbac5ace46db7f4fd..dcfe5ff28e7c882cf82f804f9a725d6fc934cc52 100644 (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;
             }
 
index de9d40755b36f5294deb8dd426d80fd19340b464..79aec4d3791aab516a3a6cffa76748180a04be5c 100644 (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++) {
index 44c9e7c9cc5c178613c3cc24717353319b2953eb..f395142067a2f176a1b477c5a446b08d099c3fb1 100755 (executable)
@@ -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;
         }
index 6d640bf483f55fe4a6d6658b6623375e48398d3b..41bd102d2ebe5297e1fd03b8cdb4f4feabe70b8d 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.jupiter.params.provider.MethodSource;
 
 /**
  * Tests for {@link ShellyDeviceProfile}.
- * 
+ *
  * @author Jacob Laursen - Initial contribution
  */
 @NonNullByDefault
@@ -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