iCloud custom_component device tracker that will not drain your battery


#21

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


#22

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.


#23

Yes, you do have to authenticate every two months.


#24

pretty sure i will always forget that :slight_smile:


#25

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


#26

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


#27

@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.


#28

same here, apple watch battery is dying :frowning:


#29

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!


#30

@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.


#31

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?


#32

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!


#33

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


#34

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


#35

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


#36

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

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


#37

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

device_tracker:
  - 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'

#38

thank you for help I will try it out.


#39

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 ?


#40

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