iCloud custom_component device tracker that will not drain your battery

Thanks. I’ll just bite the bullet on it then. I’ll trial it out on my own XS Max and see how it goes before rolling it out to the whole family.

This looks great @gcobb321, I’ll start trialling this as well. Thanks for the kind attribution, and great job on the documentation.

Does WazeRouteCalculator need to be added to the requirements? I had to install this manually on my system, though I have automatic PIP install turned off.

Also have you looked at all trying to see if the icloud services support single device polling? If this was supported, it would really let these trackers be more energy efficient.

Thanks, glad you are following it.

The Waze component does not need to be installed. It interfaces directly to Waze via the Waze APIs.

I did a lot of digging into pyicloud code and it would be nice if they did single device polling but I doubt if it will ever happen. The Find-my-Friends is only a small piece of it, most seems to deal with getting data (contacts, photos, etc) off the phone.

Version .86 - 1/22/2019 now on Github

I just pushed out an update that:

  1. Fixed an issue where a device was not being included if another one with a similar name was in an exclude_device configuration statement.For example, garyold was being excluded, gary was being included but gary was not showing up in the iCloud3.
  2. The tracked_devices attribute now shows the account name the device is associated with to easier troubleshoot device setup for multiple Apple iCloud accounts.
  3. Updated the documentation to include information and examples on multiple accounts, device naming between the device and the HA IOS app, and and explanation of the impact of not using the HA IOS app.
1 Like

Exceptional amount of work. Thank you very much. It’s still not entirely clear to me if the newer 2-factor authentication will work or not. I have been using the icloud2.py file for several months and configured it before I had turned on 2FA. But now with icloud3 it is working and I even got prompted in HA… So i’m not sure if i’m working because I had it working before or something else.

Thanks again for the great work.

Thank you very much for this.

An enhancement request - if possible - I would love to have an entity that showed the last time the component talked to ios to get the status. Nice to know how fresh the data is.

Hello @gcobb321

I have successfully installed your icloud3.py, but I have a lot of message(8 per minutes !) like this in my hassio log:

►►Error on retrieving data: Internal Error
17:10 custom_components/device_tracker/icloud3.py (ERROR)

I can still see the correct Iphones on hassio but it became very laggy (it slows down the whole hassio).
I have the last hassio version 0.87

For info, my config is like this:

– platform: icloud3
username: [email protected]
password: mypassword
account_name: myusername
include_device_type: iPhone

Do you know how I can fix this ?

Thanks!

Try the prerelease version on github it took care of the error for me (but detailed logging is on) Gary is working on an update but the last I heard was still testing it … should be soon hopefully

1 Like

Hello Bartem!
I have taken icloud3 from this link https://github.com/gcobb321/icloud3/archive/v0.86.2.zip so I guess it is the pre release.
I have also a question. How can I make it refresh more frequently ? Because It launches correctly but then I have no refresh (now it’s one hour without any refresh and some iphones have moved far.)

Thanks!

https://github.com/gcobb321/icloud3/tree/master/prerelease Use this copy of icloud3.py and make sure you copied all the scripts/automations for near/far flags etc… (from main release couple changes in prerelease folder also) Hopefully @gcobb321 will have another update soon.

I’ve been working on the next update and hoped to have it out last week but ran into some snags. Hopefully, I’m tracking the last one down now. This will get rid of the messages, make it more responsive and add a few new features and options.

The biggest is a tight integration with the IOS app… When it notifies HA that a zone has been entered or exited from, iCloud3 will pick that up within 5-second without calling the iCloud location service on a 15-second interval. The gps coordinates from the IOS app are used to determine the zone information. Also, the IOS app sends a Background Fetch periodically that tells HA the location information. This is also picked up by iCloud3 to refresh the distance, time, interval, etc attributes. Again, without interacting with iCloud location services.

The goal was to have a quicker response, less gps accuracy errors and a tighter integration with the IOS app.

Keep watching this page for release information.

1 Like

In my setup, I have 1 apple account which monitors 3 different iPhones.

That means I should install Home Assistant IOS app in each iPhones to have this functionnality in the next update?

Yes, it needs to be installed on each phone. ‘Background Fetch’ should also be turned on, along with ‘Zone enter/exit’.

I’m using this custom integration as I only wanted to track the iPhones and not all my iCloud devices. But what Ive noticed it that the update interval is always set to 30mins till it expires the 30mins then it changes, I though from reading the docs it would be “dynamic” based on being on movement et all.

I’m I doing something wrong?

Thanks

Hi @rechena , I had the same question. I don’t know how does it update the location ?
Is it when it significally moves ? or is it every x minutes?

Some of my tracked iPhones had some major moves and the update wasn’t firing, so I really don’t know how it updates…

Thanks for the reply, I even tried to keep the iPhone app with Location always on. but no joy so far… its very “random” :frowning:

@bonilla, @rechena
It updates the location via the iCloud find-my-friends locator service and information from the IOS app. When the NextUpdate time is reached, it calls the iCloud service and gets the gps location. It then passes this to the Waze route calculator for the drive time and distance home. This is used to calculate the interval between the iCloud polls. The details are towards the end of the docs.

Thanks for the reply. So if I’m reading correctly this means that if for example I’m leaving the current location and the interval just restarted to the 30mins I will have to wait another 30 for the phone to notice that I’m moving or moved? I know this saves alot of battery but it does not make updates that reliable/fast. For example I have a location on my Gym and then on my daugthers school. When I’m picking her up after the Gym most of the times the distance is not enough to trigger the location change. Isn’t there another way? Maybe using the iPhone App in conjuction with the icloud2? I might be just suggesting something silly but worth the shot. Thanks

@rechena It’s not icloud2, @gcobb321 is talking about icloud3.

Ah…thanks for clarifying. I’m currently using icloud2 so prob worth checking 3? Thanks