iCloud custom_component device tracker that will not drain your battery


Hi Just changed from iCloud to this but some reason the devises are not tracked i.e. never leave home ??
Anyone els having this issue ??

  • platform: icloud2
    username: #########
    password: ########
    account_name: Suds32
    filter_devices: ‘phone’


What directory does icloud2.py go into?

I tried /use/share/hassio/homeassistant/custom_components but when I run a check configuration, it’s not liking the icloud2 directive.




As in right off the root?


In your homeassistant directory folder



after I red the whole post still cannot get access to the folder where the .py file should go.
Any good hints how to see all flders (as root maybe)?
hass.io instaled clasic methond via image
ssh works, ssh on 22222 not so much (access restricted)
so how exactly do I copy that python file (removeing the sd?::slight_smile:


Can you access your homeassistant installed folder? If you can then create folder name custom_component in homeassistant folder and create folder device_tracker folder inside custom_component folder. The icloud2.py is in device_tracker folder.


Is this still a issue for the original icloud component?


I use original icloud component now. Everything works fine.


@walt do you know if your code has been incorporated into the official release? I’m other words, is your “fix” still needed or can we use the default?


I use HASS.IO not home hasistant install. the SD card is unreadable , and the only folders are those as standard shared by hass.io via ssh. SO how do i see the whole folder structure and write on them for HASS.IO?
share, addons, backup, config are the only ones shared by hassio as mountable.


the icloud2.py will be in config/custom_components/device_tracker/icloud2.py

then add in your configuration.yaml

  - platform: icloud2
    username: !secret icloud_username
    password: !secret icloud_password
    account_name: !secret icloud_descriptive_name
    filter_devices: 'phone'


I don.t understand why someone will give just part of info to help another…
Let’s try again so everybody understand all the pieces of info scattered all over and incomplete…

  1. What is the complete method to access HASSIO ssd/drive/ENTIRE folder structure? (Hassio NOT another install of HA).
  2. HOW do one uploads the script to that folder (ssh, putty, rubberduck etc\0
  3. What is the COMPLETE path to put the script in? (as in the WHOLE path from the root of the drive, not just from a specific folder, and if there are any folders to create )

Please explain as for a janitor :slight_smile: to understand, do not assume everyone knows what you know (unix, ssh etc)

Right now I cannot access any folder of hassio (unlike Hasbian), I cannot ssh into it, ftp to it, not even mounting the sd card on a mac, I can ony access yaml files via “configurator addon” in hassio page.

thank you


Would love to know this as well! The upstream documentation implies that the iCloud component will wake up devices on longer intervals now if they’re away from home:

“To disable the drainage of the battery, a dynamic interval is being used for each individual device instead of a fixed interval for all devices linked to one account. The dynamic interval is based on the current zone of a device, the distance towards home and the battery level of the device.”

That doesn’t seem to be correct though, based on https://github.com/home-assistant/home-assistant/issues/12135 and https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/device_tracker/icloud.py#L293, the api.authenticate call is still being called frequently and causing the device wakeups/battery drainage.

Edit: Also, does icloud2.py do anything for 2FA accounts? It seems like there’s still a self.api.authenticate call in the 2FA branch, but maybe I’m misunderstanding when that branch is taken.


What worked for me:
-in hassio icloud popup window put 0 (zero) then OK (don’t close it)
-once you put that 0 and clicked OK , a sms will come with a code
-in hassio icloud window delete that 0 (from previous you enter) and put instead the sms code, then again press OK buton.


Putting first 0 (zero) and click OK will sent icloud a request for the SMS code to use in hassio.
DO NOT use the code in the popup on the idevice screen (the one with a map:)), the SMS code is what you want.
I have 2FA :stuck_out_tongue_winking_eye: and it is not important :slight_smile:

This was trial and error… documentation is ambiguous and instructions blurry (to say the least).


How can I put icloud2.py into /custom_components/device_tracker?

The SSH add on won’t start with a password, so that’s a no go. I’m running hassio installed on a VM. I can put the file on /home/futuretense, is there a way to create the directory structure and copy it from that?


I know this is frustrating. It is for me too. It’s taken me several days of reading through lots of different information to begin to get an understanding of how this all fits together. It’s not a bad idea to go read through the development docs here even.

  1. On Hassio installation, the way to connect to the file system is actually documented on the 2nd page (Configure Home Assistant) of the “Getting Started” section on the main home-assistant.io site albeit somewhat indirectly.
    Read here.
    Basically you have to install at least the Samba add-on in order to expose a set of default folders (config, addons, share and backup) as traditional network shares. From there, you can access these folders for various needs. The most important (at least initially) is the ‘config’ share. This is where you’ll find you’re config.yaml and many other core tidbits controlling your instance of HA.
  2. The above method answers the HOW to upload things into your environment.
  3. What path?? This is what didn’t make sense to me and I certainly still don’t know all the ins and outs but at least on Hassio if I want to try out some custom code such as this icloud2.py, and as was stated in the original post at the top of this thread, “To use, put icloud2.py in your /custom_components/device_tracker/ directory”. What wasn’t clear however is that you have to create those directories inside of the ‘config’ share. By doing so, HASSIO uses the custom_components directory FIRST and will load any component it finds there in place of the standard system component by that same name/path. You can read more about that here in the developers guide for loading components…

Good luck


And for the record, I still haven’t been able to get this one to work yet either and my daughters are asking for new phones now because they think their batteries are ruined because the phones die by mid-afternoon while they’re at school. I don’t yet have the heart to tell them it’s my fault. I’ve backed off the timing interval from 30 to 60 to 120 and now to 180 minutes but it doesn’t seem to make a difference. I do see the interval is set to 180 mins when they’re within any zone i’ve created and when they’re outside of those zones, I see it drop way down to like 5 mins. I haven’t yet noticed that change as their proximity to home changes or for any reason for that matter other than arriving back within a zone.

I very much want to keep using this feature but it’s got to be tweaked because it doesn’t seem like it’s working as documented at them moment. That or the documentation needs to be more explicit (give better example) about how to setup the configuration.


Thank you for complete answer.

#3 was the problem.
It was not specified that you have to CREATE those folder and most important WHERE to create them. A “/” is either guesswork or the root of the device, or any other folder for that matter.

In the meantime I discovered indirectly I have to create them and I “presume” (aka guesswork) is “config” folder.

" Your documentation is good only when the janitor can fallow it" :))


Install addon Configurator.
It will let you browse the entire file system, upload and download any file from Hassio.
Left icon on the top blue band (when in Configurator).