Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iCloud] Fix existing things stopped working and re-appeared as new in the inbox #14661

Merged
merged 7 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ public void deviceInformationUpdate(List<ICloudDeviceInformation> deviceInformat
String deviceOwnerName = deviceInformationRecord.getName();

String thingLabel = deviceOwnerName + " (" + deviceTypeName + ")";
String deviceId = deviceInformationRecord.getId();
String deviceIdHash = Integer.toHexString(deviceId.hashCode());
String deviceDiscoveryId = deviceInformationRecord.getDeviceDiscoveryId();
if (deviceDiscoveryId == null || deviceDiscoveryId.isBlank()) {
logger.debug("deviceDiscoveryId is empty, using device name for identification.");
deviceDiscoveryId = deviceOwnerName;
}
String deviceIdHash = Integer.toHexString(deviceDiscoveryId.hashCode());

logger.debug("iCloud device discovery for [{}]", deviceInformationRecord.getDeviceDisplayName());

ThingUID uid = new ThingUID(THING_TYPE_ICLOUDDEVICE, bridgeUID, deviceIdHash);
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID)
.withProperty(DEVICE_PROPERTY_ID, deviceId)
.withProperty(translatorService.getText(DEVICE_PROPERTY_ID_LABEL), deviceId)
.withProperty(DEVICE_PROPERTY_ID, deviceDiscoveryId)
.withProperty(translatorService.getText(DEVICE_PROPERTY_ID_LABEL), deviceDiscoveryId)
.withProperty(translatorService.getText(DEVICE_PROPERTY_OWNER_LABEL), deviceOwnerName)
.withRepresentationProperty(DEVICE_PROPERTY_ID).withLabel(thingLabel).build();

logger.debug("Device [{}, {}] found.", deviceIdHash, deviceId);
logger.debug("Device [{}, {}] found.", deviceIdHash, deviceDiscoveryId);

thingDiscovered(result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ private void updateLocationRelatedStates(ICloudDeviceInformation deviceInformati
this.logger.debug("Device: [{}]", this.deviceId);

for (ICloudDeviceInformation deviceInformationRecord : deviceInformationList) {
String currentId = deviceInformationRecord.getId();

String currentId = deviceInformationRecord.getDeviceDiscoveryId();
if (currentId == null || currentId.isBlank()) {
logger.debug("deviceDiscoveryId is empty, using device name for identification.");
currentId = deviceInformationRecord.getName();
}
logger.debug("Current data element: [id = {}]", currentId);

if (currentId != null && currentId.equals(deviceId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class ICloudDeviceInformation {

private String id;

private String deviceDiscoveryId;

private boolean isLocating;

private boolean isMac;
Expand Down Expand Up @@ -160,6 +162,10 @@ public String getId() {
return this.id;
}

public String getDeviceDiscoveryId() {
return this.deviceDiscoveryId;
}

public boolean getIsLocating() {
return this.isLocating;
}
Expand Down
Loading