iCloud custom_component device tracker that will not drain your battery

I have three accounts running with iCloud3 (since January). There have been some ups and downs, but overall very positive, especially since 1.0.0. Now on 1.0.2, and will shortly be adding a fourth account.

I only have include_device for each account to single out the iPhone.

Keith Lovatt
Have you looked at ‘include_device_type: iphone’ to get all iphone devices at once instead of adding them one-at-a-time. Also, using the device_type, I believe you can just use the icloud_command - restart and it will restart iCloud3 without restarting HA and probably pick up the 4th device.

This caused many exceptions. Please see log below:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/icloud3/device_tracker.py", line 1085, in _polling_loop_5_sec_device
    if self.any_device_being_updated_flag:
AttributeError: 'Icloud' object has no attribute 'any_device_being_updated_flag'

jwelter
Weird. This flag is set when devices are first initialized. I’ve even tried it with no devices and don’t get the error.

  • Can you look in the device_tracker attributes for the device and see what is shown. Is there a ‘tracked_devices’ attribute at the bottom?
  • Do you have entries in the HA log file like:
    Authentication for xxxx@xxxx as gary_icloud successful
    Waze Settings: Region=US, Realtime=False, MaxDistance=1609.35, MinDistance=1.61
    Filters: include_device_types=[‘iphone’], include_devices=[], exclude_device_types=[], exclude_devices=[]
    Initializing Device Tracking for user [email protected]
    Tracking gary_icloud/gary_iphone(iphone), Passed ‘include_device_type’ filter
    Not tracking gary_icloud/ipadmini(ipad), No location information
    Not tracking gary_icloud/gary_ipad(ipad), Unknown device
    Not tracking gary_icloud/conniessipad(ipad), No location information
    Not tracking gary_icloud/lillian_ipad(ipad), Unknown device
    Tracking gary_icloud/lillian_iphone(iphone), Passed ‘include_device_type’ filter
    Not tracking gary_icloud/lillian_iwatch(watch), Unknown device
    Tracking Devices gary_icloud/gary_iphone, gary_icloud/lillian_iphone
    Gary(iphone) Created Stationary Zone, GPS=(90, 180)
    Lillian(iphone) Created Stationary Zone, GPS=(90, 180)
    Gary(iphone) Updating, Initializing Device Data
    Lillian(iphone) Updating, Initializing Device Data

I can make sure the variable exists and send a copy of it to you to see if it solves the problem. Send your email address to [email protected].

Hi,

I turned on debug logging for this component and that led me to the realization it was setup to use an old iCloud.com account. So I fixed that.

But now I don’t seem to get anything displayed and the logs indicate many unknown devices, etc. See below.

2019-03-25 14:18:32 WARNING (MainThread) [homeassistant.loader] You are using a custom component for icloud3.device_tracker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ home _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=7
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: xx.918056, ‘longitude’: -xx.539649, ‘radius’: 150.0, ‘friendly_name’: ‘Home’, ‘icon’: ‘mdi:castle’, ‘beacon’: OrderedDict([(‘uuid’, ‘687F29A1-BFD2-46FF-AD0F-EBF148DA2F24’), (‘major’, 1), (‘minor’, 0)])}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ work _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: xx.952878, ‘longitude’: xxx.836191, ‘radius’: 300.0, ‘friendly_name’: ‘Work’, ‘icon’: ‘mdi:worker’}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ school _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: xx.013702, ‘longitude’: xx.590558, ‘radius’: 200.0, ‘friendly_name’: ‘School’, ‘icon’: ‘mdi:school’}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ iad _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: 38.953123, ‘longitude’: -77.456281, ‘radius’: 1500.0, ‘friendly_name’: ‘IAD’, ‘icon’: ‘mdi:run’}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ bwi _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: 39.180797, ‘longitude’: -76.669926, ‘radius’: 1500.0, ‘friendly_name’: ‘BWI’, ‘icon’: ‘mdi:run’}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ dca _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: 38.851209, ‘longitude’: -77.040232, ‘radius’: 1500.0, ‘friendly_name’: ‘DCA’, ‘icon’: ‘mdi:run’}{}
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] _____ mathnaseum _____ LoadZoneTbl Attrs _____ (LoadZoneTbl)
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Last=None, This=None, Elements=6
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] Attrs={‘hidden’: True, ‘latitude’: xxx.980013, ‘longitude’: xxx.545144, ‘radius’: 150.0, ‘friendly_name’: ‘Mathnaseum’, ‘icon’: ‘mdi:run’}{}
2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Zone Name Table Initialized {‘home’: ‘Home’, ‘work’: ‘Work’, ‘school’: ‘School’, ‘iad’: ‘IAD’, ‘bwi’: ‘BWI’, ‘dca’: ‘DCA’, ‘mathnaseum’: ‘Mathnaseum’}
2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Verifying Waze Route Service component
2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Waze Route Service not available
2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] iCloud3 device_tracker Initializing Account [email protected] as xxxxxxx
2019-03-25 14:18:33 DEBUG (SyncWorker_5) [custom_components.icloud3.device_tracker] ►►TIME ZONE OFFSET, Local Zone Offset: -0400, Seconds Offset: -14400
2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Authentication for [email protected] as xxxxx successful
2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Waze Settings: Region=US, Realtime=False, MaxDistance=1609.35, MinDistance=1.61
2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Filters: include_device_types=, include_devices=, exclude_device_types=, exclude_devices=
2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Initializing Device Tracking for user [email protected]
2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/johnsiphone(iphone), Unknown device
2019-03-25 14:18:35 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/johnsapple_watch(watch), No location information
2019-03-25 14:18:35 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/jwmacbookpro(macbookpro), Unknown device
2019-03-25 14:18:35 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/johnsapple_watch(watch), Multiple devices with samename
2019-03-25 14:18:35 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/kenzie_sschoolipad(ipad), Unknown device
2019-03-25 14:18:36 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/kenziesmacbook(macbook), No location information
2019-03-25 14:18:36 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/kenziesiphone(iphone), Unknown device
2019-03-25 14:18:36 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/kenziesapple_watch(watch), No location information
2019-03-25 14:18:36 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/connorsmacbookpro(macbookpro), Unknown device
2019-03-25 14:18:37 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/connorsipadpro(ipad), Unknown device
2019-03-25 14:18:37 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/connorsiphone(iphone), No location information
2019-03-25 14:18:37 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxxx/connorsapple_watch(watch), No location information
2019-03-25 14:18:37 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxx/connorsiphone(iphone), Multiple devices with samename
2019-03-25 14:18:38 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/kimsimac(imac), No location information
2019-03-25 14:18:38 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/kwipad(ipad), Unknown device
2019-03-25 14:18:38 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxx/kimberleysmacbookpro(macbookpro), No location information
2019-03-25 14:18:38 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Not tracking xxxxxxx/kimberleysiphone(iphone), Unknown device
2019-03-25 14:18:38 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Tracking Devices

jwelter
A few things I noticed…

  • It does look like you have a lot of old devices and will have to clean that up in your Apple icloud account. Nothing I can do about that.

  • It looks like Waze is not available on your HA computer. Google github WazeRouteTracker for instructions on setting it up.
    2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Verifying Waze Route Service component
    2019-03-25 14:18:33 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Waze Route Service not available

  • You have to have some type of include or nothing will get loaded.
    2019-03-25 14:18:34 INFO (SyncWorker_5) [custom_components.icloud3.device_tracker] Filters: include_device_types=[], include_devices=[], exclude_device_types=[], exclude_devices=[]

    See the information on this below::
    https://github.com/gcobb321/icloud3#user-account-and-device-configuration-items

It seems you are trying to write special characters to some of the sensors which cause issues with certain DB back ends. See below.

Perhaps this works ok on SQLLite back end? Surprised someone else hasn’t found this already as Mysql is pretty common.

2019-03-25 17:18:56 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (_mysql_exceptions.OperationalError) (1366, "Incorrect string value: '\\xE2\\x97\\x8FOld...' for column `homeassistant`.`states`.`state` at row 1") [SQL: 'INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: ('sensor', 'sensor.connorsmacbookpro_info', '●Old Location, #65, Age 65.4m', '{"icon": "mdi:information-outline"}', 1269081, datetime.datetime(2019, 3, 25, 19, 39, 15, 539267, tzinfo=<UTC>), datetime.datetime(2019, 3, 25, 19, 39, 15, 539267, tzinfo=<UTC>), datetime.datetime(2019, 3, 25, 21, 18, 56, 93425), '097138f0d49c4622bdaf90d000de3143', None)] (Background on this error at: http://sqlalche.me/e/e3q8)
2019-03-25 17:18:56 ERROR (Recorder) [homeassistant.components.recorder] Error in database connectivity: (_mysql_exceptions.OperationalError) (1366, "Incorrect string value: '\\xE2\\x97\\x8FOld...' for column `homeassistant`.`states`.`state` at row 1") [SQL: 'INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: ('sensor', 'sensor.connorsmacbookpro_info', '●Old Location, #65, Age 65.4m', '{"icon": "mdi:information-outline"}', 1269081, datetime.datetime(2019, 3, 25, 19, 39, 15, 539267, tzinfo=<UTC>), datetime.datetime(2019, 3, 25, 19, 39, 15, 539267, tzinfo=<UTC>), datetime.datetime(2019, 3, 25, 21, 18, 56, 93425), '097138f0d49c4622bdaf90d000de3143', None)] (Background on this error at: http://sqlalche.me/e/e3q8). (retrying in 3 seconds)

jwelter
Yes, it’s a utf-8 character that has been at the beginning of messages in the info field to separate one from another. Ive been using it for a long time and have not heard of any issues related to it from anyone else before now. It’s just a message field that doesn’t really contain any important data so maybe you could filter the fields you are working with.

iCoud3 v1.0.3 Device Tracker released Thursday, 3/28/2019

Download it from the iCloud3 Github Repository.

  • This release fixes a few minor bugs…

Thanks for this, looks really nice. I have installed it and it works like a charm. Good to see so much info.
I noticed the boolean stating “driving” but that is your version when your almost home.

The thing is that i thought it was a sensor at first that would only indicate if your moving or not. So i looked into the sensor and found the sensor._speed. Which looked like how fast a person is going. Tried that out while driving some times but it makes no chances.

Do really like the whole “if moving and condition is x and y then poll in a differente fashion”

Hi,
Just installed this so haven’t had a chance to check it out yet, but noticed in the documentation you have:

waze_region
The area used by Waze to determine the distance and travel time.
Valid values: US (United States), NA (North America), EU (Europe), IL (Isreal). Default: US

I’m in Australia, so I’m assuming that the Waze stuff won’t work?

Not sure if it’s just me but this appears to be broken in 0.92:

Configuration invalid

Integration icloud3 not found when trying to verify its device_tracker platform.

Having the same issue here after upgrading to 0.92

Just need to rename the file device_tracker.py to __init__.py and it’ll be back working :slight_smile:

1 Like

My bad, firstly I’m actually using icloud3, and secondly you need it se up like this: https://github.com/gcobb321/icloud3/tree/master/custom_components-icloud3

Gary,
I love this plugin (when I get it to work) but since 0.94 I’ve had it working once and then nothing since. I keep getting Unable to find service device_tracker/icloud_update in the logs.
What am I missing?
TIA
Neil

All iCloud account access is down due to changes made accessing the iCloud account. The best way to follow iCloud3 and keep up with news/updates if here

Thanks Apple!
And thank you Gary & team for all your hard work

I have everything set up and running, but how do i know or link the ha iOS app to the service? It seems to be relying only on iCloud at the moment. i have the names matched up in the ha app and in the iPhone general about setting

I’m getting a ton of these sorts of errors with MariaDB. Is there a way to fix this?


Error executing query: (MySQLdb._exceptions.OperationalError) (1366, "Incorrect string value: '\\xE2\\x97\\x8FBat...' for column `homeassistant`.`states`.`state` at row 1")
[SQL: INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: ('sensor', 'sensor.her_iphone_info', ' ●Battery-95%', '{"icon": "mdi:information-outline", "friendly_name": "her-iPhone-Info"}', 1388067, datetime.datetime(2020, 1, 11, 13, 16, 36, 550867, tzinfo=<UTC>), datetime.datetime(2020, 1, 11, 13, 16, 36, 550867, tzinfo=<UTC>), datetime.datetime(2020, 1, 11, 13, 20, 46, 383690), '84afa469aabb40398727d30a45fbc413', None)]
(Background on this error at: http://sqlalche.me/e/e3q8)