iCloud custom_component device tracker that will not drain your battery


Thank you for your help .
My iCloud “Share My location” is always on. I do know that nmap scans my network and gets all devices on my LAN using MAC address: After activating icloud2 and going through apple verification, I still don’t see any new devices added to my know_devices.yaml file.
I have tried all HA presence detection components. I think Geofency work best for me so I will stick with that for now. Again thanks for help.


Shelving this for now, the underlying library does locate for all devices on each update:

If that gets resolved, I’ll rework iCloud2 into a pull request to update the official HA component.


I wanted to try and save batteries a bit and trigger the icloud tracking only by other events, never periodically. E.g. magnetic door sensor: when front door is opened, check if a family member’s location changed from not_home to home --> turn on lights and TV. Or vice versa, door opens, one minute delay, some family member from home to not_home AND all family members now not_home, turn off all lights. Or, door opens, all family members status stays at not_home --> alarm.

I just couldn’t find how to make this manual triggering of icloud tracking in automation. Is it possible?


If you mean your icloud2 custom_component. Works really fine.

I have read some other users from post above. If you could provide the possibility to track not only phone but also ipad, apple watch.

Thank you very much.


What sort of timeline are you thinking it will get added to the main component? I’m using the iCloud component currently and wondering if i try holding out using that or consider moving over to your battery friendly version


Thanks for the useful component. However, even putting the configuration as explained, all my iCloud devices are listed and not only my iPhone. How can I fix this?


After upgrade to 0.69 icloud2 component not found.


I found changing line 16 in icloud2.py fixed the component not found error.

from homeassistant.components.zone import active_zone

from homeassistant.components.zone.zone import active_zone

Mine is now loading again.


Thank you very much. I have now use the original icloud which a little more drain the battery.


Is this thing still working? I followed the instructions but the component was not working I changed the icloud2.py as @scffgeek suggested and then went through the icloud configuration but i did not manage to get my device shown in home assistant.


Working for me after @scffgeek fix.


I would like to know whether the original icloud.py itself support apple watch? The icloud2 support only phone. After update to 0.69 I have used icloud.py


Updated the public gist to be 0.69 compatible. Thanks @scffgeek


I have had trouble with the icloud service calling two devices at the same time when only one is called for. I found your service works well for me as just as a means to update one iphone’s locations. I use the following with your script to automate updates in HA. Thanks

      - service: device_tracker.icloud_set_interval
          interval: 999
          account_name : iphone
          device_name : xxxiphone


Glad it’s working for you Rob – All the devices on your account will still be polled, but the frequency that each is polled is much more reasonable with this custom component.

I’m still watching the underlying library pyicloud, and hoping they can implement specific device polling. Once that is supported, we can be much smarter on polling the right device and saving battery across all devices.


I setup an automation that recored every state change of the icloud device trackers I use. I am sure using the above code that icloud2.py will only update HA device tracker that the interval is changed. (not using the update service)

It is possible that all devices get polled but HA only registers the state change of the entity that I changed the interval on. I am not sure how I can check if a device is getting updated if its not reported to HA.


I set the red marked icloud tracker to interval 300 and the blue to interval 999 last night. These are the state changes of the device tracker. It appears interval 300 was set twice and occur 2 mins apart. I might have set the interval twice.



Might be something simple but… Anyone know what I’m doing wrong here?

Log Details (ERROR)

Fri Jun 01 2018 09:10:27 GMT-0500 (CDT)

Error executing service <ServiceCall configurator.configure: configure_id=1860385680-1, fields=trusted_device=XXXXXX>

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1007, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/configurator.py”, line 224, in async_handle_service_call
call.data.get(ATTR_FIELDS, {}))
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/device_tracker/icloud2.py”, line 208, in icloud_trusted_device_callback
self._trusted_device = self.api.trusted_devices[self._trusted_device]
IndexError: list index out of range


Hi! Does this support find my iPhone lost phone alerts, specifically using device_name to specify the device to ring?

Or does this issue persist from the original component? Thanks!


Hi - any thoughts on this? Has anyone managed to get the lost iPhone feature to work?