]> git.basschouten.com Git - openhab-addons.git/commitdiff
Handling null WifiInformation (#16700)
authorGaël L'hopital <gael@lhopital.org>
Sun, 28 Apr 2024 23:32:55 +0000 (01:32 +0200)
committerGitHub <noreply@github.com>
Sun, 28 Apr 2024 23:32:55 +0000 (01:32 +0200)
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/APManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/WifiStationHandler.java

index 6fa4c1a3f09fb7c2e96121102ffaa295d82790df..aa371888c50332758e091bc25444915c1c34685c 100644 (file)
@@ -46,14 +46,16 @@ public class APManager extends ListableRest<APManager.WifiAp, APManager.APRespon
             long txBytes, // transmitted bytes (from Freebox to station)
             long txRate, // reception data rate (in bytes/s)
             long rxRate, // transmission data rate (in bytes/s)
-            WifiInformation wifiInformation) {
+            @Nullable WifiInformation wifiInformation) {
 
-        public int getSignal() {
-            return wifiInformation.signal();
+        public int getRSSI() {
+            WifiInformation local = wifiInformation;
+            return local != null ? local.signal : 1;
         }
 
         public @Nullable String getSsid() {
-            return wifiInformation().ssid();
+            WifiInformation local = wifiInformation;
+            return local != null ? local.ssid : null;
         }
     }
 
index ce5b25773d19b7d469ae41d2f4fdd8cbcfa0f488..02595ddd177765aa7e639b38d0bbc5e098d056f1 100644 (file)
@@ -73,7 +73,7 @@ public class WifiStationHandler extends HostHandler {
             LanAccessPoint lanAp = wifiHost.get().accessPoint();
             if (lanAp != null) {
                 updateChannelString(GROUP_WIFI, WIFI_HOST, "%s-%s".formatted(lanAp.type(), lanAp.uid()));
-                updateWifiStationChannels(lanAp.getSignal(), lanAp.getSsid(), lanAp.rxRate(), lanAp.txRate());
+                updateWifiStationChannels(lanAp.getRSSI(), lanAp.getSsid(), lanAp.rxRate(), lanAp.txRate());
                 return;
             }
         }