iCloud3 v3 iDevice Tracker - Version 3

The iCloud3 iDevice Tracker custom component is a major advancement over the iCloud component that is part of Home Assistant.

Version 3, a Home Assistant Custom Component Integration

  • Version 3 User Guide can be found here. It describes new features and the v2.4.7 to v3 migration

Version 3

  • iCloud3 Documentation is here
  • Download using HACS – Open HACS, select Integrations, search for iCloud3, select Install.

It is designed to:

  • Connect with the iCloud Location Services using Find-my-Phone tracking methods.
  • Support Apple iCloud 2fa security.
  • Provide easy-to-use presence detection that does not rely on any other program, other than Home Assistant and the Home Assistant IOS app.
  • Report accurate information, i.e. current zone, location, distance from a zone and travel time on a timely basis that can be used reliably in automations and scripts.
  • Track the device (phone) from more than one zone, e.g, Home zone, work zone, school zone, etc.
  • Conserve the devices battery.
  • Correct GPS wandering errors leading to incorrect triggering of automations.
  • Provide more distance, travel time, and zone attributes than the base iCloud component.
  • Automatically create sensors containing device tracking information that can be used in automations, scripts and on Lovelace cards.
  • Monitor the iOS App for zone and location changes on a 5-second interval.
  • Display activity on the iCloud3 Event Log custom Lovelace card.

Below are some sample Lovelace screenshots showing how iCloud3 information can be displayed (see ui-lovelace-icloud3.yaml in the sample_automations_scripts directory of the iCloud3 repository). Example configuration files for sensors, switches, badges, automations and scripts are also found in the sample_automations_scripts directory that report location information and device status, along with running automations (opening a garage door) when arriving home. Other uses (security, lighting, heating & cooling control, etc.) can be added to the automations to meet your needs.

Gary Cobb, aka GeeksterGary

What’s different between HA iCloud and the iCloud3 Custom Component

iCloud3 has many features not in the base iCloud device_tracker that is part of Home Assistant. 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. Lets look at the differences.

Feature Original iCloud iCloud3
Integration with the HA IOS App No Yes, Geographic Zone Enter/Exit, Background Fetch, Significant Location Update & Manual transactions are detected and processed immediately after they are issued.
Device Selection None Specify devices to be tracked by their devicename, i.e., gary_iphone or lillian_iphone using the tracked_devices parameter.
Locate device using Family Sharing List Yes Yes
Locate device using Find-my-Friends No Yes
Locate device using HA IOS App without iCloud Services No Yes
Minimum Poll Interval 1 minute 15 second
Zone used to calculate distance and travel time ‘Home’ zone only ‘Home’ zone and any other HA zone(s)
Distance Accuracy 1 km/mile .01 km/mile
Variable Polling Yes - Based on distance from home, battery level, GPS Accuracy Yes, based on distance and Waze travel time to the ‘home’ or another zone, direction of travel, if the device is in a zone, battery level, GPS Accuracy and ‘old location’ status.
Detects zone changes No - Also requires other device_trackers (OwnTracks, Nmap, ping, etc. Yes, no other programs are needed other than the HA IOS App.
Detects when leaving Home Zone (or another base_zone zone) Delayed to next polling cycle (default of 30-minutes) Detects when the Home Assistant IOS app issues a Zone Enter/Exit notification
Discards old transactions No Yes, if older than 2-minutes or with poor gps accuracy.
Fixes ‘Not Home’ issue when in Sleep Mode No Yes, by discarding all transactions that are closer than 1-km when the device is in a zone and by providing zone template sensors that are used to trigger automations rather than device_tracker state changes.
Integrates with Waze route/map tracker No Yes, the Waze travel time is used to determine the ‘polling interval’. Waze can be disabled if not available using configuration parameters.
Device Polling Interval when close to the ‘home’ or another zone 1+ minutes (?) 15-seconds
Dynamic Stationary Zone No Yes, a Stationary Zone is created if no movement has been detected in 8-minutes (configurable). The polling interval is set to 30-minutes (default) until zone exit notification is received.
Service call commands Set polling interval, reset devices Set polling interval, reset devices, pause/restart polling, change zone, enable/disable Waze Route information usage, information logging (some commands can be for all devices or for a specific device)
Track device from more than one location No, can only track from the ‘home’ zone Yes, can track from the Home zone and another base_zone zone (office, second home, etc.).
Event Log Lovelace Card No Yes. Displays significant events as iCloud3 starts up and locates devices.
Create Sensors for device attributes No Yes. Sensors created for many of the device_tracker attributes. You can also customize the list of sensors to only create the ones you are interested in.

Edited April, 2021

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

2 Likes

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 > Trigger-Periodic@17:14:04 (31s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (36s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (41s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (46s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (51s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (2m56s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (3m1s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (5m31s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (5m36s ago), State-home@17: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 > Trigger-Periodic@17:14:04 (5m51s ago), State-home@17: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?