]> git.basschouten.com Git - openhab-addons.git/commitdiff
[plugwiseha] Fix bug introduced with #12349 (#12366)
authorlsiepel <leosiepel@gmail.com>
Fri, 25 Feb 2022 12:33:58 +0000 (13:33 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Feb 2022 12:33:58 +0000 (13:33 +0100)
* Fix bug introduced with #12349

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.plugwiseha/src/main/java/org/openhab/binding/plugwiseha/internal/api/model/dto/ActuatorFunctionalities.java
bundles/org.openhab.binding.plugwiseha/src/main/java/org/openhab/binding/plugwiseha/internal/api/model/dto/ActuatorFunctionality.java
bundles/org.openhab.binding.plugwiseha/src/main/java/org/openhab/binding/plugwiseha/internal/api/model/dto/Location.java
bundles/org.openhab.binding.plugwiseha/src/main/java/org/openhab/binding/plugwiseha/internal/handler/PlugwiseHABridgeHandler.java
bundles/org.openhab.binding.plugwiseha/src/main/java/org/openhab/binding/plugwiseha/internal/handler/PlugwiseHAZoneHandler.java

index 4d4ec3081adfaa96d7517b1d6126b6d40b374279..623954de8b6e295b045ac5c1c714b076f87c0371 100644 (file)
@@ -35,8 +35,12 @@ public class ActuatorFunctionalities extends PlugwiseHACollection<ActuatorFuncti
                 .map(Boolean::parseBoolean);
     }
 
-    public Optional<String> getRegulationControl() {
-        return this.getFunctionalityThermostat().flatMap(ActuatorFunctionality::getRegulationControl);
+    public String getRegulationControl() {
+        ActuatorFunctionality functionality = this.getFunctionalityThermostat().orElse(null);
+        if (functionality != null) {
+            return functionality.getRegulationControl();
+        }
+        return null;
     }
 
     public Optional<Boolean> getCoolingAllowed() {
index d42ff7ddef0f59ae6696937dc57c52f58dafb1cb..e25288ccd0d7a55dcd38919f69411265c8c7fb1b 100644 (file)
@@ -81,8 +81,8 @@ public class ActuatorFunctionality extends PlugwiseBaseModel implements Plugwise
         return updatedDate;
     }
 
-    public Optional<String> getRegulationControl() {
-        return Optional.ofNullable(regulationControl);
+    public String getRegulationControl() {
+        return regulationControl;
     }
 
     public Optional<String> getCoolingAllowed() {
index 521849dc412358e71533d2a7274429dd6b98ac76..6e6673e1f53bb2b68d8b80319ec8b5e796b3ee47 100644 (file)
@@ -109,8 +109,11 @@ public class Location extends PlugwiseBaseModel implements PlugwiseComparableDat
         return this.actuatorFunctionalities.getCoolingAllowed();
     }
 
-    public Optional<String> getRegulationControl() {
-        return this.actuatorFunctionalities.getRegulationControl();
+    public String getRegulationControl() {
+        if (this.actuatorFunctionalities != null) {
+            return this.actuatorFunctionalities.getRegulationControl();
+        }
+        return null;
     }
 
     public int applianceCount() {
index 0be22adccaa34b313e8e25fc2587599be7e61df2..b657b149dd588ed6bc2c9dbadc8e32d1a6e20700 100644 (file)
@@ -175,12 +175,16 @@ public class PlugwiseHABridgeHandler extends BaseBridgeHandler {
         } catch (PlugwiseHAUnauthorizedException | PlugwiseHANotAuthorizedException e) {
             updateStatus(OFFLINE, CONFIGURATION_ERROR, STATUS_DESCRIPTION_INVALID_CREDENTIALS);
         } catch (PlugwiseHACommunicationException e) {
+            this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
             updateStatus(OFFLINE, COMMUNICATION_ERROR, STATUS_DESCRIPTION_COMMUNICATION_ERROR);
         } catch (PlugwiseHATimeoutException e) {
+            this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
             updateStatus(OFFLINE, COMMUNICATION_ERROR, STATUS_DESCRIPTION_TIMEOUT);
         } catch (PlugwiseHAException e) {
+            this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
             updateStatus(OFFLINE, COMMUNICATION_ERROR, e.getMessage());
         } catch (RuntimeException e) {
+            this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
             updateStatus(OFFLINE, COMMUNICATION_ERROR, e.getMessage());
         }
     }
index 658cf016737a6ea79a02e031d2e0aa0a066520c6..593bce38a25a519284e6d42cbf4bf9895336bb33 100644 (file)
@@ -224,7 +224,10 @@ public class PlugwiseHAZoneHandler extends PlugwiseHABaseHandler<Location, Plugw
                 }
                 break;
             case ZONE_REGULATION_CHANNEL:
-                state = new StringType(entity.getRegulationControl().orElse(null));
+                String value = entity.getRegulationControl();
+                if (value != null) {
+                    state = new StringType(entity.getRegulationControl());
+                }
                 break;
             case ZONE_TEMPERATURE_CHANNEL:
                 if (entity.getTemperature().isPresent()) {