Hi @gcobb321, have looked a little more at the problem I am having getting the icould3 FMF tracking working. The home-assistant.log file contains the following entry, which indicates the the iCloud account has no contacts associated with it:
2020-02-09 16:17:22 ERROR (SyncWorker_15) [custom_components.icloud3.device_tracker] iCloud3 Error: Setting up-iphone_neil > The email [email protected] is invalid or is not in the Username: [email protected] FMF contact list. Valid [email protected] contacts are .
However, everything seems to be set up fine on icloud.com, the iphones that I want to track all have associated contacts (with the correct emails addresses) and I can see them on www.icloud.com in the ‘Find Friends’ and ‘Find iPhone’ app.
The problem seems to be caused in the device_tracker.py function _setup_tracked_devices_for_fmf(). Even though I believe I have set up the devices/contacts on icloud.com in accordance with your guidance, the “contactDetails” array returned by the API is empty. The json contains:
"contactDetails":[ ],
From the comments in the code, I would expect this element to contain an array of contact details, with fields for email addresses, first & last name, a photo URL and an ‘Id’. I have tried various ways to persuade the API to populate this element, but have been unsucessful.
To get things working on my system I have made a couple of changes to the code so that instead of the empty “contactDetails” array the “following” array, which is populated, is used instead. It contains the relevant email address, and the “Id” field, which allows the correct association to be made:
"following":[
{
"invitationSentToEmail":"[email protected]",
"optedNotToShare":true,
"expires":0,
"expiresByGroupId":{ "kFMFGroupIdOneToOne":0 },
"invitationAcceptedByEmail":"[email protected]",
"source":"APP_OFFER",
"invitationId":"41fc982a-af42-4546-bd40-3f4d6e03fc7e",
"tkPermission":false,
"onlyInEvent":false,
"updateTimestamp":1581246917431,
"createTimestamp":1581246917431,
"invitationFromHandles":[ "[email protected]" ],
"invitationFromEmail":"[email protected]",
"personIdHash":"c98c61b62e9579055555ee190d58f823d855558b042e4e7e76d98fa3c73f352d",
"invitationAcceptedHandles":[ "[email protected]" ],
"friendPrefs":null,
"personId":"107233321",
"id":"MTA3MfkdhjeIyMQ~~"
},
....
],
To use the alternate data, line of pyicloud_ic3.py changes at around line 851:
From:
@property
def contacts(self):
return self.data.get('contactDetails')
To:
@property
def contacts(self):
return self.data.get('following')
And device_tracker.py at around line 5645:
From:
for contact in fmf.contacts:
contact_emails = contact.get('emails')
id_contact = contact.get('id')
To:
for contact in fmf.contacts:
contact_emails = contact.get('invitationAcceptedHandles')
id_contact = contact.get('id')
Because the “firstName” is not available also needs a change to prevent the friendly name being set to a null value. Comment out line 5678:
From:
self.friendly_name[devicename] = contact.get('firstName')
To:
# self.friendly_name[devicename] = contact.get('firstName')
The root cause of my issue is probably a misconfiguration of the iCloud.com account, so I don’t know whether this observation/suggestion is of any use to others. But if anyone else finds that they have an empty “contactDetails” array it may help.
If you have any suggestions for what may be causing the lack of contact details they would be gratefully received!