iCloud custom_component device tracker that will not drain your battery

It does work with 2FA, the documentation is out of date!

Ouch, last time i did check it, it would also require to authenticate every month or so again. If you have any insights/docs regarding it, would be appreciated.

Yes, you do have to authenticate every two months.

pretty sure i will always forget that :slight_smile:

You’ll get a pop-up/persistent notification on your dashboard reminding you to log back in

That is actually pretty nice… hope to see the improvements flowing into mainstream.

@walt i’ve added this custom component and even though I set it to only filter ‘phone’ i’ve noticed that my apple watch battery now dies by midday.

same here, apple watch battery is dying :frowning:

This has saved me! Used to be the Watch would be dead by 3 to 5 PM now at 30 to 40% at that time and never dies anymore!

@nicx You both will want to enable debugging and then look though your home-assistant.log for "custom_components.device_tracker.icloud2] Updating device "

The way the component is currently written if you have a matching device that is offline the calculated interval will stay at one minute, and you’ll drain the battery on all of your devices quickly.

Just so I am clear on this, tracking any device that’s off, causes all other devices to drain the battery as well? Does that mean individual devices are not tracked, but every device is tracked every time any device location is requested?

Yes, that is the way the component and the underlying library, pyicloud, is written. Anytime the component interval evaluates true, a find my iPhone call is made to all devices on that iCloud account. It’s not ideal but I didn’t see any way to improve from the icloud2 component level with just a cursory look through pyicloud.

You can also see with the current iCloud device tracker component that is in the HA release that if you have say four devices you will be polling each device four times a minute! Crazy battery drain!

How do I setup filters to track family members phones ?
If for example my phone’s name is A wife B kid C ?

filter_devices: ‘phone’ shows only my phone

Try this version, still pass it a filter, but it will be ignored.

I use sosumi to automate when HA retrieves our iphone’s locations. It doesn’t require icloud component.

thanks but I still don’t understand how to apply filters.

filter_devices: ‘phone’ , ‘A’, ‘B’ ?
- phone
- A
- B

When you add the icloud email, password, name to show in HA / your iphone will say somewhere has try to login to use icloud. The step for icloud to authorized your accounts to HA is on post #8 Mr.VladTepz

  - platform: icloud2
    username: !secret icloud_usernameA
    password: !secret icloud_passwordA
    account_name: !secret icloud_descriptive_nameA
    filter_devices: 'phone'
  - platform: icloud2
    username: !secret icloud_usernameB
    password: !secret icloud_passwordB
    account_name: !secret icloud_descriptive_nameB
    filter_devices: 'phone'
  - platform: icloud2
    username: !secret icloud_usernameC
    password: !secret icloud_passwordC
    account_name: !secret icloud_descriptive_nameC
    filter_devices: 'phone'
1 Like

thank you for help I will try it out.

I set up icloud2 but I do not see any new device in the list. I have nmap enabled so devices are being tracked by it. I do not see any new device connected to icloud2 anywhere. What am I doing wrong ?

for iphone you have to allow Settings > iCloud > Share My Location.
for nmap enable, this is for local connection same network.
If your network didn’t find any new devices (iphone). Check at known_devices.yaml in your home assistant config folder.

If there isn’t any new device in known_devices.yaml, then manually add them in

devicename: <=== this normally is the name you given according to your iphone Setting>General>about>name> then the name your iphone use
  name: Friendly Name  <== name display in HA
  mac: EA:AA:55:E7:C6:94  <== iphone mac address
  picture: /local/****.jpg <== ****.jpg file locatedin www folder in your homeassistant folder
  track: yes
  hide_if_away: no
1 Like