]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tr064] fix fritz.box lookup (#9454)
authorJ-N-K <J-N-K@users.noreply.github.com>
Wed, 23 Dec 2020 03:19:37 +0000 (04:19 +0100)
committerGitHub <noreply@github.com>
Wed, 23 Dec 2020 03:19:37 +0000 (19:19 -0800)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/Tr064HandlerFactory.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/Tr064RootHandler.java

index d62acf3c8eec3e364c8cba7eee40c9530429e5cc..3e4338681c50061f3e7ad398a2bcc02e09a19b17 100644 (file)
@@ -65,7 +65,7 @@ public class Tr064HandlerFactory extends BaseThingHandlerFactory {
         this.channelTypeProvider = channelTypeProvider;
         this.phonebookProfileFactory = phonebookProfileFactory;
         // use an insecure client (i.e. without verifying the certificate)
-        this.httpClient = new HttpClient(new SslContextFactory(true));
+        this.httpClient = new HttpClient(new SslContextFactory.Client(true));
         try {
             this.httpClient.start();
         } catch (Exception e) {
index 5889f770d35af2b459329268943565506e64bd20..49969c0fc3148251d3c91a0256594f237bd2662a 100644 (file)
@@ -76,7 +76,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
 
     private @Nullable SCPDUtil scpdUtil;
     private SOAPConnector soapConnector;
-    private String endpointBaseURL = "http://fritz.box:49000";
+    private String endpointBaseURL = "";
 
     private final Map<ChannelUID, Tr064ChannelConfig> channels = new HashMap<>();
     // caching is used to prevent excessive calls to the same action
@@ -87,14 +87,19 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
     private @Nullable ScheduledFuture<?> pollFuture;
     private @Nullable ScheduledFuture<?> phonebookFuture;
 
+    private boolean communicationEstablished = false;
+
     Tr064RootHandler(Bridge bridge, HttpClient httpClient) {
         super(bridge);
         this.httpClient = httpClient;
-        soapConnector = new SOAPConnector(httpClient, endpointBaseURL);
+        this.soapConnector = new SOAPConnector(httpClient, endpointBaseURL);
     }
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
+        if (!communicationEstablished) {
+            logger.debug("Tried to process command, but thing is not yet ready: {} to {}", channelUID, command);
+        }
         Tr064ChannelConfig channelConfig = channels.get(channelUID);
         if (channelConfig == null) {
             logger.trace("Channel {} not supported.", channelUID);
@@ -157,6 +162,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
                 updateThing(thingBuilder.build());
             }
 
+            communicationEstablished = true;
             installPolling();
             updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
         }
@@ -172,6 +178,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
 
     @Override
     public void dispose() {
+        communicationEstablished = false;
         removeConnectScheduler();
         uninstallPolling();
         stateCache.clear();