iCloud3 v2.3 Update - Advanced device_tracker and iOS App location monitor

The iCloud3 device tracker custom component is a major advancement over the iCloud component that is part of Home Assistant. It monitors the iOS App for location information and zone changes, uses the Waze route tracker for travel times, supports multiple zones, works with the Family Sharing and Find-my-Friends iCloud Location Services tracking methods, solves the false zone exits caused by gps wandering problem and much more.

Review the changes and features below and the extensive documentation to see how iCloud3 can be used to monitor your devices and provide you with presence detection that is accurate, responsive and timely.

iCloud3 v2.3 is a significant enhancement to iCloud3. It’s major enhancements include:

  • Support for Apple’s 2-factor authentication trusted device verification. This is the real verification process, the one you are familiar and used by other 2fa apps, web sites and browsers. It replaces the 2-step verification method you have ben using for years.

    You will be asked to reauthenticate your Apple account when you install this update. Use the HA Notification center to open the Verification ID entry window. Enter the 6-digit number from the Apple ID Verification window on your phone or other device.

  • The iCloud Location Services tracking methods (Find-my-Friends and Family Sharing) have been combined and the most efficient method is assigned by iCloud3 on a per-device basis. iCloud3 analyzes how your devices are configured and determines the one to use that will minimize the number of locations requests. This reduces the lag time between the request and the response and helps lower the number of old locations received.

  • The configuration parameters for defining devices has changed to provide for future device specifications and to conform to HA’s methods of configuring devices. The old track_devices still works but is being depreciated.

  • Updated the handling of the config_ic3.yaml iCloud3 configuration file.

  • A new configuration parameters for displaying zones on the Event Log.

  • And some bug fixes.

  • And some other things.

Important Links

  • Download iCloud3 using HACS – Open HACS, search for iCloud3, select Install and restart HA. The Quick Start Guide leads you through the steps needed to begin using iCloud3 to track your devices.
  • Extensive documentation with with examples of presence detection, including sample configuration files can be found here
  • The iCloud3 GitHub Repository is here

Description and Features
iCloud3 is a device_tracker custom_component for iPhones, iPads and iWatches. It is tightly integrated with the HA IOS App, uses the Waze Route Tracker for distance and time information, creates Dynamic Stationary Zones when you are stationary, supports device include/exclude filters, minimizes battery usage, and much more.

iCloud3 is a Home Assistant device tracker custom component that greatly expands the capabilities of the HA iCloud integration. It exposes many new attributes, provides many new features, is based on enhanced route tracking methods, is much more accurate, and includes additional service calls.

Some of these features include:

  • A variable polling interval based on the Waze route mapping service (drive time and distance rather than just a calculated straight line distance).
  • Immediate zone changes (enter/exit) and location changes triggered by the iOS App.
  • An Event Log that highlights startup events, tracking events, errors, alerts and statistics and provides an Actions pulldown command window to Restart iCloud3, pause and resume polling, show tracking monitors and more…
  • Sensor templates that are used in automations, in scripts and on Lovelace cards are created and updated automatically.
  • GPS wandering that changes the device’s state from home to not_home randomly is eliminated.
  • Ability to track your location from multiple zones.
  • Short 15-second polling when less than 1 mi/km from home (reliably trigger automations based on an accurate distance).
  • Ability to include or exclude devices or device types (filters for devices you want to track).
  • Stationary Zones that help reduce polling and conserve battery life when you have not moved for a while…
  • Old location data and GPS accuracy are automatically discarded.
  • Additional service call commands (setting intervals, pausing and resuming polling, zone assignment, etc.)
  • No longer need any other program (other than the HA iOS or app) to handle device tracking and presence detection (no more Nmap, OwnTracks or router based tracking components).
  • Many new configuration variables attributes, sensors and Service Calls.
  • And more…

Gary Cobb, aka GeeksterGary

Edited January, 2021

3 Likes

Hi Gary, great component! Been using it for a while without issues but this new update broke something. I modified the config settings as described but after restart I’m getting a few errors and no travel_time sensor at all.

Error logs:

Logger: custom_components.icloud3.device_tracker
Source: custom_components/icloud3/device_tracker.py:1380
Integration: icloud3 (documentation)
First occurred: 15:07:46 (1 occurrences)
Last logged: 15:07:46

object of type ‘NoneType’ has no len()

Traceback (most recent call last): File “/config/custom_components/icloud3/device_tracker.py”, line 1380, in _start_icloud3 if len(self.track_from_zone.get(devicename)) > 1: TypeError: object of type ‘NoneType’ has no len()


Logger: custom_components.icloud3.device_tracker
Source: custom_components/icloud3/device_tracker.py:7167
Integration: icloud3 (documentation)
First occurred: 15:07:43 (1 occurrences)
Last logged: 15:07:43

‘str’ object has no attribute ‘append’

Traceback (most recent call last): File “/config/custom_components/icloud3/device_tracker.py”, line 7167, in _setup_tracked_devices_config_parm zones.append(HOME) AttributeError: ‘str’ object has no attribute ‘append’

My config:

  - platform: icloud3
    username: /email/
    password: /pass/
    unit_of_measurement: km
    distance_method: waze
    waze_region: EU
    create_sensors: zon,zonn,zonfn,ttim,wdis,bat,batstat
    devices:
      - device_name: /device name/
        email: /email/
        name: /name/
        picture: /local/laci.png
        noiosapp: false
        iosapp_entity: /ios app entity/
        zone: office

I also deleted and reinstalled icloud3 but no change. Do we need to do anything else when updating to make it work as intended?

Many thanks!

@suxlala
I’ll look at the error when I get home. Does it start ok when you take off the zone: office parameter? Also, the noiosapp: false really isn’t needed and can be removed. It is only needed if it is true.

Thank you that did the trick! No errors in the log anymore.
I thought these parameters were important to have but it now works without them.

@suxlala
The zone parameter is only used if you want to also track from another zone, have automations set up for the other zone or want to monitor the travel time and distance to the other zone. But iCloud3 should also not give an error message like you saw. Is office a valid zone name or a mistake?

Thanks, now it’s more clear!
I have a zone defined and named as “Office”, so it’s a valid one, and tried both as ‘Office’ and ‘office’ - with the same result. However the error message mentions ‘(HOME)’ and nothing about ‘office’.

Hey Gary - hope you’re doing well! :slight_smile:

Do you happen to know how to increase the area for the home zone? I have announcements happening when people enter/leave zones and I would like them to come a bit earlier than they do. I thought one way to solve that would be to increase the size of the Home zone. I couldn’t find a way to do that. Maybe I should move the real “Home” zone somewhere else, and create my own custom home zone where I want it and of the size that I want. Does that seem reasonable and would there be any issues with iCloud3 from doing that?

@Allistah
I am doing good and finally getting to work on some other things after getting v2.3 done. You can specify the home zone parameters in the configuration.yaml file. Mine looks like:

zone:
  - name: Home
    radius: 100
    icon: mdi:home
    latitude: !secret home_latitude
    longitude: !secret home_longitude

Hope that helps.

1 Like

Perfect, thank you! I’ll give that a try. Hope you have a great weekend!

You can also customise the radius in Configuration => Customisations, if you prefer to keep configuration.yaml small and tidy.

1 Like

I recently upgraded to v2.3 and noticed that two devices don’t receive IC3 zone updates. The UI reports both with “NotSet”. The info part in Lovelace repeats “Locating device via iCloud” with “May be offline No location” and nothing happens. If i check via the “Find my” app, all devices can be located.

My configuration

- platform: icloud3
  username: !secret icloud_name
  password: !secret icloud_password
  tracking_method: famshr

and the config_ic3.yaml file

# for us europeans
unit_of_measurement: km
time_format: 24
waze_region: EU
devices:
  - device_name: swaiPhone
    name: Stefan
    picture: swa.jpg
  - device_name: jphone
    name: Julia
    picture: julia.jpg
  - device_name: iphone_von_anna
    name: Anna
    picture: anna.jpg

@swa72

  1. Check the Event Log for any errors.
  2. Check the HA Configuration > Logs for any errors.
  3. Did the Apple ID Verification for 2fa code entry request display with the 6-digit code? Are any HA Notifications pending?
  4. Any authentication errors?
  5. Can you open the HA iOS App on the ‘offline’ phone.
  6. Go to Event Log > Actions > Update All Locations and see if that gets it tracking again.
    7 Go to Event Log > Actions > Restart iCloud3 and see if it now starts tracking.

I have seen my phone display offline for 30-seconds or so while my wife’s phone was located. It would then go to a normal status and everything would be fine. The device status code of ‘offline’ is returned from iCloud when a location request is
received.
.
Edit: I just had an issue where iCloud3 had paused my phone from location tracking. It also displayed ‘Requesting New iCloud Location’ over and over again. Looking at the HA Log file, an Error 401 was displayed many times. This error has to do with a failed authentication retry response from Apple. I selected Event Log > Actions > Resume and everything started again and things are normal.

Hi Gary,

I think that I have done 1 thru 7 a couple of times by now ;-). I see no errors in stages 1 thru 4 in the logs. It completes successfully in about 7s. The only error I could spot (not sure whether it is related is …

Logger: aiohttp.server
Source: components/websocket_api/http.py:81
First occurred: 5:08:09 PM (1 occurrences)
Last logged: 5:08:09 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 233, in async_handle
    await self._writer_task
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 81, in _writer
    await self.wsock.send_str(message)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_ws.py", line 300, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 656, in _send_frame
    await self.protocol._drain_helper()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/base_protocol.py", line 87, in _drain_helper
    await waiter
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 935, in _write_ready
    n = self._sock.send(self._buffer)
BrokenPipeError: [Errno 32] Broken pipe

The recent event log for one phone shows no location data repeatedly.

swaiphone	17:14:28	Home	-	5 min	-	-	Service Call Command Received > `resume`
swaiphone	17:14:28	Home	-	5 min	-	-	FamShr update started (Resuming)
swaiphone	17:14:28	Home	-	5 min	-	-	Requesting New iCloud Location > LastLocTime-Never (Initial Locate)
swaiphone	17:14:29	Home	-	5 min	-	-	Refreshed FamShr iCloud location data
swaiphone	17:14:30	Home	-	5 min	-	-	Discarded Results: Home > CurrZone-not_set, GPS-(0, 0), Interval-5 min, NextUpdt-17:19:30, OldLocPoorGpsCnt-#9, UpdateErrorCnt-#74, InfoMsg-May be Offline, No Location (#9)
swaiphone	17:14:30	Home	-	5 min	-	-	Discarded > No location data (#9) > GPS-(0.0, 0.0), LocationTime-Never, NextUpdate-17:19:30, OldLocThreshold-1.5 min
swaiphone	17:14:35	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (31s ago), [email protected]:09:57 (4m38s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:14:35	Home	-	5 min	-	-	Device Monitor > UpdateMethod-ICLOUD, UpdateReason-Initial Locate, State-not_set, Trigger-Initial Locate, LastLoc-17:14:29, Zone-not_set, HomeDist-0m, inZone-True, GPS-(49.420803, 8.759997), StateThisPoll-not_set, StateLastPoll-not_set
swaiphone	17:14:40	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (36s ago), [email protected]:09:57 (4m43s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:14:45	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (41s ago), [email protected]:09:57 (4m48s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:14:50	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (46s ago), [email protected]:09:57 (4m53s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:14:55	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (51s ago), [email protected]:09:57 (4m58s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:17:00	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (2m56s ago), [email protected]:09:57 (7m3s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:17:05	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (3m1s ago), [email protected]:09:57 (7m8s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:14:25, WillUpdate-False, Already Processed
swaiphone	17:19:30	Home	-	5 min	-	-	FamShr update started (Initial Locate)
swaiphone	17:19:30	Home	-	5 min	-	-	Requesting New iCloud Location > LastLocTime-Never (Initial Locate)
swaiphone	17:19:31	Home	-	5 min	-	-	Refreshed FamShr iCloud location data
swaiphone	17:19:32	Home	-	5 min	-	-	Discarded Results: Home > CurrZone-not_set, GPS-(0, 0), Interval-5 min, NextUpdt-17:24:30, OldLocPoorGpsCnt-#10, UpdateErrorCnt-#75, InfoMsg-May be Offline, No Location (#10)
swaiphone	17:19:32	Home	-	5 min	-	-	Discarded > No location data (#10) > GPS-(0.0, 0.0), LocationTime-Never, NextUpdate-17:24:30, OldLocThreshold-1.5 min
swaiphone	17:19:35	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (5m31s ago), [email protected]:09:57 (9m38s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:19:30, WillUpdate-False, Already Processed
swaiphone	17:19:35	Home	-	5 min	-	-	Device Monitor > UpdateMethod-ICLOUD, UpdateReason-Initial Locate, State-not_set, Trigger-Initial Locate, LastLoc-17:19:31, Zone-not_set, HomeDist-0m, inZone-True, GPS-(49.420803, 8.759997), StateThisPoll-not_set, StateLastPoll-not_set
swaiphone	17:19:40	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (5m36s ago), [email protected]:09:57 (9m43s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:19:30, WillUpdate-False, Already Processed
swaiphone	17:19:55	Home	-	5 min	-	-	iOSApp Monitor > [email protected]:14:04 (5m51s ago), [email protected]:09:57 (9m58s ago), GPS-(49.420563, 8.759925)/15m), LastiC3UpdtTime-17:19:30, WillUpdate-False, Already Processed

@swa72
Export the Event Log (Event Log > Actions > Export Event Log) and email the /config/icloud-event-log.txt file to [email protected]. I’ll look at it and see if I notice anything.

Hi,

I’m completely noob, wasn’t even known what yaml or python were a few days ago, and obviously missing something!

I haven’t installed the HA app for the moment, wanted icloud3 firstly.
I’ve installed HACS on my HA supervisor, and immediatly icloud3.
I’ve created a www/custom_cards file, put icloud3-event-log-card.js in it and restart HA.

I became no notification for 2 factors authentification and have an error message when I try to install the card in Lovelace.

I’ve tried lot’s of things, a community file instead of the custom_cards file too, but always had the same result: this error message

Logger: frontend.js.latest.202012291
Source: components/system_log/__init__.py:193
First occurred: 13:28:23 (4 occurrences)
Last logged: 13:28:24

    http://192.168.178.****:8123/local/community/icloud3/icloud3-event-log-card.js:1541:9 TypeError: hass.states['sensor.icloud3_event_log'] is undefined
    http://192.168.178.****:8123/local/community/icloud3/icloud3-event-log-card.js:1463:9 TypeError: hass.states['sensor.icloud3_event_log'] is undefined 

What am I doing wrong?

Thank you

@romain7
The Lovelace editor will not highlight the Enregistrer button for you wo save the card until you have an entity item.

When you add the card, also add the sensor: icloud3_event_log after the type…

type: 'custom:icloud3-event-log-card'
entity: sensor.icloud3_event_log

Then click Save/Enregistrer at the bottom and you should be all set.

Thank you for your answer.

I’m able now to save. But I still doesn’t have the notification for the 2 FA and I’ve always the error message

Logger: frontend.js.latest.202012291
Source: components/system_log/__init__.py:193
First occurred: 13:28:23 (4 occurrences)
Last logged: 13:28:24

    http://192.168.178.****:8123/local/community/icloud3/icloud3-event-log-card.js:1541:9 TypeError: hass.states['sensor.icloud3_event_log'] is undefined
    http://192.168.178.****:8123/local/community/icloud3/icloud3-event-log-card.js:1463:9 TypeError: hass.states['sensor.icloud3_event_log'] is undefined 

Just before saving the card, I’ve this message :

@romain7
That sensor is created by iCloud3 and the error means you do not have iCloud3 running. You have to set up the platform: icloud3 parameters in the configuration file and restart HA. See the iCloud3 docs here for more information about configuring and starting iCloud3.

I’d tried lot’s of time, comitting (obviously) errors, but now it seems to work!

I’ll customize later.
Thank for your help and job

I’ve sucessfully gotten iCloud3 running and have the appropriate sensors for myself and 2 family members via Family Sharing. I’m using the Home Assistant iOS app but the other 2 family members are not. Additionally, the other 2 family memvbers are currently our other house, not the one with Home Assistant. I have Zones setup in HA for the other house and some other nearby areas. There are no erros in the HA Logs or iCloud3 Event Logs.

The issue is that the location for these 2 other family members is not upading in iCloud3, sometimes until hours later. If I look in “Find My,” it will sohe correctly, but iCloud3 does not. If I manually trigger an update once via the iCloud3 Event Log, nothing typically happens. But, if I manually trigger an update, wait ~1 min and then manually trigger another update, iCloud3 will then properly show their location.

Any ideas how to improve the responsiveness or further debug?