]> git.basschouten.com Git - openhab-addons.git/commitdiff
Use device.Id instead of device.DiscoveryId to fix playsound (#16846)
authorSimon Spielmann <simon.spielmann@gmx.de>
Sun, 9 Jun 2024 18:58:58 +0000 (20:58 +0200)
committerGitHub <noreply@github.com>
Sun, 9 Jun 2024 18:58:58 +0000 (20:58 +0200)
Signed-off-by: Simon Spielmann <simon.spielmann@gmx.de>
bundles/org.openhab.binding.icloud/src/main/java/org/openhab/binding/icloud/internal/handler/ICloudDeviceHandler.java

index 87b0960804d59e2507323e42a619feddc6ddc6d8..358a9ade30c0b37663bfa1304da7b4d717a82ce7 100644 (file)
@@ -62,6 +62,8 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
 
     private @Nullable String deviceId;
 
+    private @Nullable ICloudDeviceInformation deviceInformationRecord;
+
     public ICloudDeviceHandler(Thing thing) {
         super(thing);
     }
@@ -70,6 +72,7 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
     public void deviceInformationUpdate(List<ICloudDeviceInformation> deviceInformationList) {
         ICloudDeviceInformation deviceInformationRecord = getDeviceInformationRecord(deviceInformationList);
         if (deviceInformationRecord != null) {
+            this.deviceInformationRecord = deviceInformationRecord;
             if (deviceInformationRecord.getDeviceStatus() == 200) {
                 updateStatus(ONLINE);
             } else {
@@ -137,12 +140,18 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
         if (channelId.equals(FIND_MY_PHONE)) {
             if (command == OnOffType.ON) {
                 try {
-                    final String deviceId = this.deviceId;
-                    if (deviceId == null) {
-                        this.logger.debug("Can't send Find My Device request, because deviceId is null!");
+
+                    if (deviceInformationRecord == null) {
+                        this.logger
+                                .debug("Can't send Find My Device request, because deviceInformationRecord is null!");
                         return;
                     }
-                    bridgeHandler.findMyDevice(deviceId);
+                    if (deviceInformationRecord.getId() == null) {
+                        this.logger.debug(
+                                "Can't send Find My Device request, because deviceInformationRecord.getId() is null!");
+                        return;
+                    }
+                    bridgeHandler.findMyDevice(deviceInformationRecord.getId());
                 } catch (IOException | InterruptedException e) {
                     this.logger.warn("Unable to execute find my device request", e);
                 }
@@ -183,7 +192,6 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
     private @Nullable ICloudDeviceInformation getDeviceInformationRecord(
             List<ICloudDeviceInformation> deviceInformationList) {
         this.logger.debug("Device: [{}]", this.deviceId);
-
         for (ICloudDeviceInformation deviceInformationRecord : deviceInformationList) {
             String currentId = deviceInformationRecord.getDeviceDiscoveryId();
             if (currentId == null || currentId.isBlank()) {