Home Assistant Community

Latest release v1.03 (3/28/2019) -- iCloud3 Device Tracker Custom Component -- Tightly integrated with the HA IOS App, Waze Route Tracker integration, Dynamic Stationary Zones, device include/exclude filters, minimal battery usage, and more


I think this has nothing to do with the customer_component.
Don’t get me wrong, it happens to me since the app was updated to 1.5.0 and I don’t use this customer component.
Tonight my iPhone shifted over 200 m and back in 1 minute.
I hope this will be fixed with an update of the home assistant app.



Thanks for your formidable work!

I’m trying to set up your compenent. But I have few questions:

Thanks in advance.



Strangely enough HA is giving me the following error:

Platform not found: device_tracker.icloud3

Although I’ve placed the icloud3.py in

Do you’ve got any ideas?



I have my custom_components folder under the config folder.

Shows as being from the root if you map a drive to config.

Mind you, I have this on hassos.



Ah I see, that’s where my problem might occur; I’m not using hassos but HA on a Debian (stretch lite) installation on my RPI.

No I just have to find out where to place the icloud3.py I suppose… If you’ve got any suggestions? Feel free :wink:



in the folder where your configuration.yaml is, there should be a folder custom_components, if it is not there you have to create it.



That’s exactly what I tried. Strangely enough HA keeps telling me:

Platform not found: device_tracker.icloud3

Full path to my icloud3.py:




Here is an extract from the home-assistant.log maybe it makes sense to you?

2019-01-31 21:33:45 ERROR (Thread-21) [homeassistant.loader] Error loading custom_components.device_tracker.icloud3. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 117, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/icloud3.py", line 34, in <module>
    import WazeRouteCalculator
ImportError: No module named 'WazeRouteCalculator'
2019-01-31 21:33:45 ERROR (Thread-21) [homeassistant.loader] Unable to find platform icloud3
2019-01-31 21:33:45 ERROR (MainThread) [homeassistant.components] Platform not found: device_tracker.icloud3


It seems that not all dependencies are installed.
The module WazeRouteCalculator is not there.
Maybe @gcobb321 can help here.




Is it normal that I have 2 tracking device (integrated device_tracker in home assistant and Icloud3 component)
You can have as many as you set up.

To use zoning, I just have to create new zone with HA as normal?
Yes. Create a home zone. See the HA docs on Zones.

Could you share you Lovelace config for this card
All the config files are in the configuration files in the repository, including several lovelace cards.



I made myself a workaround by commenting line 34 in icloud3.py. So it’s not literally importing the WazeRouteCalculator and on first sight: it seems to work properly!




I think custom components go into the config/custom_components/device_tracker directory



Requirements added in next release. Also error code that will (might) trap the Waze import error. My Waze has always loaded without any issues. I’m using hass.io and don’t know if that makes a difference.

Edit: Requirements removed since it was causing too many other problems if it wasn’t available (there are areas of the world that don’t have Waze but still want to use the app with the iCloud service). It now catches the error that Waze can not load and automatically turns that option off when starting up.



I just had to install the wazeroutecalculator in my ha venv and was good to go …



Great work on this!

I seem to have some weirdness/conflict with the native tracker & icloud3 (my guess…):

1:40PM iPhone is at home
1:37PM iPhone is away
1:37PM iPhone is at home
… other stuff in log
1:26PM iPhone is away
1:26PM iPhone is at home
1:24PM iPhone is away

Essentially, every time I leave/arrive into a zone, I get 3 entries in the log like the above.

Anyone else see this?





Me too, it’s weird. I can’t use it this way. Because my alarm and lights are presence based. Now when i come home the lights turn on and back off again. Same for the alarm and then I trigger the alarm :frowning:. Hopefully there will be a fix. In the mean time I’m switching back to icloud2.



I see similar. So far have three iPhones being tracked, each on its own iCloud account. In cases where there are retries, it does appear there are multiple threads running for each account.

One example is a a 15 second loop and a 2 hour loop going for the same device.



I’ve started to do a little debugging and have found a couple things. Once I confirm them I’ll submit them as bugs to gcobb321’s github repository.

It seems that when iOS updates the state, icloud3 is accidentally setting it back (the update is not supposed to change the state, but in the case where iOS changes the state, it is out of sync with icloud3’s ‘last_state’). It’ll take me a few days to test… going into a long weekend here. :slight_smile:

1 Like


This is why I developed my gps filter script - unfortunately, it was designed around an older HA which allowed entities to be created and updated (we’ll say dynamically) but now there’s much more tighter controls around this. The symptom @Ricshy mentioned sounds a lot like what I encountered.

Unfortunately my wife uses an iPhone which I’m forced to support and need reliable GPS tracking. It was easy with my script because it would zero the device into home location (didn’t matter if I used the HA iOS app, iCloud, Owntracks, etc) and then keep it locked there with updates received. The problem with being indoors (even with my Android) is GPS drift and no line-of-sight to a satellite. I even dropped gps accuracy down a 50m value in hopes of filtering out too much drift but I still get false positives.

I’m still battling it and the whole reason I wrote that script in the first place… I’ve been watching this thread in hopes of a better component for my wife’s iPhone (I believe I’ve found one for my Android–Ariela) but sounds like the same problems still plague us with GPS.

@gcobb321 perhaps my ideas may help solve some problems experienced here, maybe not but figured I’d toss the idea out to you… see here: Zanzito GPS Filter (python script)

One thing I noticed is for example in the composite device tracker is when in the home zone, ignore all GPS updates with regards to zoning, ultimately, I think that’s probably the best approach.

Sorry for the rambling, just finished reading the entire thread and thinking about trying this component but feel it’s still plagued by the same issues all indoor-GPS tracking has.

EDIT: After reading through the github documentation, this is by far the best implementation I’ve seen to work around the issues noted above. Nice work.



While trying to tighten the integration with the HA IOS app, I kept running into several problems that are related to this issue. I am running on a 5-second cycle where I monitor the information sent by the IOS app to HA.
The IOS app sends transactions that update the state information of the device, it updates the gps coordinates (latitude & longitude), trigger, timestamp, battery and gps accuracy attributes of the device. These changes are first processed by the device_tracker.see in the device_tracker component init.py file. The gps coordinates are reformatted from ‘gps: (lat-value, long-value)’ to '…{‘latitude’: ‘lat-value’, ‘longitude’: ‘long-value’, …} items in the device_tracker entity state/attribute items.

Zone Ente/Exit transactions.-- The proximity sensor (proximity.py ) looks at the tracked device’s location and determines if it is in a zone and changes the state of the device to zone or not_home (I think). Other proximity attributes are also set… I am also looking at this and using it to trigger zone updates that start the interval timers, distance calculators, etc…One problem I have run into deals with a Zone Exit automation.An ‘Arrives Home’ automation is triggering when I leave home. I think this might be a state change timing timing issue. I pick up the state change and start processing it. Before I finish, another thread also picks up the state change and triggers the Arrive Home automation, I then reset the state using the new gps coordinates from the IOS app when it left home, think it is in the Home zone and set it back to Home based on the GPS coordinates of the device when the 5-second cycle began. I am going to put a condition in the automation that it must be heading Towards home but I think that is a work around rather than a solution.

Background Fetch – This transaction is sent periodically to HA and I think is the main problem of GPS wandering. I put a bunch of traces in the init.py file to follow when the gps coords are updated. I found that many these transactions have old information. I pick up the BF trigger when it happens found the timestamp to be from 2-minutes to 10-minutes old with gps coords that are now old. The proximity sensor code does not look at the timestamp to throw the transaction away but updates the device state based on it. I come along, see that it is old and throw the transaction away. I store the gps coords in iC3 in a table separate from the entity. Rather than throwing them away, I could also store their timestamp and reset them if the ones I have are newer than the device’s attributes.

Another problem I also kept running into that drove me nuts has to do with timing and HA running multiple threads.I would update the lat/long of the device based on the ios app data or icloud location data but the next time I read it to process another command would show the old data. The lat/long I used would be gone,along with the last location, interval, distance, etc. I found this by doing an attribute read right after I updated the attributes and checking to see if it had ever made it to the device’s entity state itself. Perhaps this is all timing related because everything seems to happen on a 5-second basis. The solution was to update the timestamp attribute, then read back the attribute’s state data and do a rewrite if the timestamps don’t match. Since I ran into these update issues, I have to wonder if other parts of HA also dealing with device location issues are losing transactions also. Or is it just because I am running on a 5-second cycle and a 10-second cycle would solve the problem. Another thing to look at.

These are a few of the things I have run into and hope it sheds a little more light on gps drift and timing issues.


Home Assistant for iOS 2.0 Beta Testing