Skip to content

Commit 866ea1b

Browse files
authored
Use device.Id instead of device.DiscoveryId to fix playsound (openhab#16846)
Signed-off-by: Simon Spielmann <[email protected]>
1 parent ed9fbf0 commit 866ea1b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bundles/org.openhab.binding.icloud/src/main/java/org/openhab/binding/icloud/internal/handler/ICloudDeviceHandler.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
6262

6363
private @Nullable String deviceId;
6464

65+
private @Nullable ICloudDeviceInformation deviceInformationRecord;
66+
6567
public ICloudDeviceHandler(Thing thing) {
6668
super(thing);
6769
}
@@ -70,6 +72,7 @@ public ICloudDeviceHandler(Thing thing) {
7072
public void deviceInformationUpdate(List<ICloudDeviceInformation> deviceInformationList) {
7173
ICloudDeviceInformation deviceInformationRecord = getDeviceInformationRecord(deviceInformationList);
7274
if (deviceInformationRecord != null) {
75+
this.deviceInformationRecord = deviceInformationRecord;
7376
if (deviceInformationRecord.getDeviceStatus() == 200) {
7477
updateStatus(ONLINE);
7578
} else {
@@ -137,12 +140,18 @@ public void handleCommand(ChannelUID channelUID, Command command) {
137140
if (channelId.equals(FIND_MY_PHONE)) {
138141
if (command == OnOffType.ON) {
139142
try {
140-
final String deviceId = this.deviceId;
141-
if (deviceId == null) {
142-
this.logger.debug("Can't send Find My Device request, because deviceId is null!");
143+
144+
if (deviceInformationRecord == null) {
145+
this.logger
146+
.debug("Can't send Find My Device request, because deviceInformationRecord is null!");
143147
return;
144148
}
145-
bridgeHandler.findMyDevice(deviceId);
149+
if (deviceInformationRecord.getId() == null) {
150+
this.logger.debug(
151+
"Can't send Find My Device request, because deviceInformationRecord.getId() is null!");
152+
return;
153+
}
154+
bridgeHandler.findMyDevice(deviceInformationRecord.getId());
146155
} catch (IOException | InterruptedException e) {
147156
this.logger.warn("Unable to execute find my device request", e);
148157
}
@@ -183,7 +192,6 @@ private void updateLocationRelatedStates(ICloudDeviceInformation deviceInformati
183192
private @Nullable ICloudDeviceInformation getDeviceInformationRecord(
184193
List<ICloudDeviceInformation> deviceInformationList) {
185194
this.logger.debug("Device: [{}]", this.deviceId);
186-
187195
for (ICloudDeviceInformation deviceInformationRecord : deviceInformationList) {
188196
String currentId = deviceInformationRecord.getDeviceDiscoveryId();
189197
if (currentId == null || currentId.isBlank()) {

0 commit comments

Comments
 (0)