iCloud custom_component device tracker that will not drain your battery

I just deleted the old icloud section in the configuration!
It works perfectly fine.
I would love to See this in the next hass.io release!

I have removed the old configuration and added the icloud2 platform, but it is still polling every minute…

Has anyone tried this recently? Can anyone confirm if the battery issues are resolved? There seems to be a few mixed results in this thread.

I tried it for weeks, but the battery was drained aswell. Thats why I don’t use it anymore.
I use the app, the recent beta, and also the fritzbox component.
If you don’t have a fritzbox, look if there is a component for your router.

I use the iOS app (beta) and asuswrt with pretty good results… my only issue is my kids iPads and iPods don’t update the battery level/state as frequently as I’d like and I’m pretty sure when I using the actual iCloud component they all updated pretty regularly… oh well… I’m hoping when the new iOS app is released it will resolve it (I can’t put the beta on the kids due to their age it won’t let me)

I think it could take a while till it will be released.
See this post here

iCloud3 custom component released

iCloud3 is a new Home Assistant device tracker custom component that greatly expands the capabilities of the iCloud (and iCloud2) HA component. It exposes many new attributes, provides many new features, is based on enhanced route tracking methods, is much more accurate, and includes additional service calls.

Some of these features include:

  1. A variable polling interval based on the Waze route mapping service (drive time and distance rather than just a calculated straight line distance).
  2. Immediate status update on zone changes (enter and exit).
  3. Short 15-second polling when less than 1 mi/km from home (reliabily trigger automations based on an accurace distance).
  4. Ability to include or exclude devices or device types (filters for devices you want to track).
  5. Dynamic Stationary Zones (conserve battery life when stationary).
  6. Automatically repoll the device if the GPS location data is ‘old’ or inaccurate (on the next 15-second interval).
  7. Tracking security (prevent GPS coordinates from being reported to HA if not in a zone).
  8. Additional service call commands (setting intervals, pausing and resuming polling, zone assignment, etc.)
  9. No longer need any other program (other than the HA IOS app) to handle device tracking and presence detection (no more Nmap, OwnTracks or router based tracking components).
  10. Configuration variables (16 new variables), Attributes (13 new items returned), Service Calls (10 new subcommands), lines of code (from 425 to 2500+).
  11. And more…

It is now available for download at https://github.com/gcobb321/icloud3. You will find comprehensive documentation and screenshots, all the configuration files, automations and lovelace card setup that I use for device tracking, presence detection and reporting on my rig.

I’ve been using this for a while but this is the first general release of the component. You may run into some problems I haven’t come across. If so, post them on the Issues page on my repositary.

Gary Cobb, aka GeeksterGary

1 Like

This looks pretty good and looks like a lot of time has gone into developing this.

I only have one question… how does this affect the battery on the iPhones?? The previous version of were just too much of a drain ion the battery to keep using.

2 Likes

I have used an iPhone X until December (iPhone XS since then) and have noticed no noticeable effect on the battery. Most of the time I am in a zone (Home and others) that is on a 2-hour inzone (configurable) polling cycle. As soon as I leave the zone, the IOS app generates an exit zone notification and actual polling begins. I just picked 2-hours but it configurable and could be 6, 12 or whatever works best in your situation.

A lot of work has been spent minimizing battery usage and the polling interval calculation is a major part of that… The base iCloud component calculates the polling interval on the distance from home, not the time it will take to get there. iCloud3 uses the driving time/distance from the Waze mapping service (except for the last mile). This makes determining the polling interval much more accurate. For example, it’s a 20-minute drive home – the next poll is in 12-minutes. If, at that poll, I am now 10-minutes from home, the next poll would be in 6-minutes. The interval is determined by taking 60% of the Waze drive time (configurable) until the last mile. Then it goes to a 15-second poll to trigger ‘arrive home’ automations.

Another way it minimizes battery usage is by creating Dynamic Station Zones. If you haven’t moved very much during 2 polling cycles (shopping, friends house, doctors office, the beach, etc), a DSZ is created with the current location and you are now on a 2-hour polling cycle. When you leave the DSZ, the IOS app notifies HA of the zone exit and you are back on the time/distance cycle.

Service Call commands let you pause and resume polling. For example, you are on a trip far from home. It makes no sense to poll the device even though the polling interval would be very large. If you are out of the country I am sure the driving time returned from the Waze service would be unrealistic. When you arrive back in the country, resume polling and it will be gin in 15-seconds.

Let me know if you have any more questions.

BTW, Yes, I have been working on this for a while. The project started last March when I could not get any reliable presence detection to work and just wanted my garage door to open when I got home. I kept adding functions and features until I was satisfied and couldn’t think of anything else to add.

No more questions, but you seem to have really worked on battery usage. I’ll give it a go when I get a chance to set it up. Actually, 1 more question. Is the HA app needed for this to work? I don’t really want to put the HA app on my kids iphones, but if it’s needed, then oh well.

Yes. It is needed. Otherwise, there is no reliable way to get zone enter and exit notifications.

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!