Skip to content

Commit

Permalink
Use device.Id instead of device.DiscoveryId to fix playsound (openhab…
Browse files Browse the repository at this point in the history
…#16846)

Signed-off-by: Simon Spielmann <[email protected]>
  • Loading branch information
maihacke authored Jun 9, 2024
1 parent ed9fbf0 commit 866ea1b
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -70,6 +72,7 @@ public ICloudDeviceHandler(Thing thing) {
public void deviceInformationUpdate(List<ICloudDeviceInformation> deviceInformationList) {
ICloudDeviceInformation deviceInformationRecord = getDeviceInformationRecord(deviceInformationList);
if (deviceInformationRecord != null) {
this.deviceInformationRecord = deviceInformationRecord;
if (deviceInformationRecord.getDeviceStatus() == 200) {
updateStatus(ONLINE);
} else {
Expand Down Expand Up @@ -137,12 +140,18 @@ public void handleCommand(ChannelUID channelUID, Command command) {
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);
}
Expand Down Expand Up @@ -183,7 +192,6 @@ private void updateLocationRelatedStates(ICloudDeviceInformation deviceInformati
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()) {
Expand Down

0 comments on commit 866ea1b

Please sign in to comment.