iCloud3 v2.0 Device Tracker - Advanced tracking features with HA iOS App integrated monitoring (Updated)

what’s the easiest way to get it to pull the new devices without messing anything up?

You do have to restart HA … That is the only way to get configuration file changes to be recognized. If configuration file changes are not needed (I.e., you just added an iPhone to your account that already had iphone as an include_device_type), you can just do an device_tracker.icloud_restart service call to include it.

oh I see I forgot it won’t even look for it until I add it to the device types… thanks

So another unrelated issue, I’ve added the lost iPhone script, it will work for my device but then I get this for the others… not just the watch but the other phones/ipads

Log Details (ERROR)
Sun Jun 09 2019 22:09:21 GMT-0400 (EDT)

Error executing script script.lost_iphone_amyswatch. Unknown error for call_service at pos 1: 
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/script/__init__.py", line 173, in async_turn_on
    kwargs.get(ATTR_VARIABLES), context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 89, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1174, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  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 423, in service_callback_lost_iphone
    account, devicename)
  File "/home/homeassistant/.homeassistant/custom_components/icloud3/device_tracker.py", line 5208, in service_handler_lost_iphone
    device.play_sound()
  File "/srv/homeassistant/lib/python3.6/site-packages/pyicloud/services/findmyiphone.py", line 137, in play_sound
    data=data
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/pyicloud/base.py", line 99, in request
    raise api_error


Log Details (ERROR)
Sun Jun 09 2019 22:09:21 GMT-0400 (EDT)

Error executing service <ServiceCall script.lost_iphone_amyswatch (c:5a5d6f2f932a47d3b82e418d018baf7b)>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/script/__init__.py", line 114, in service_handler
    context=service.context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/script/__init__.py", line 178, in async_turn_on
    raise err
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/script/__init__.py", line 173, in async_turn_on
    kwargs.get(ATTR_VARIABLES), context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 89, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1174, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  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 423, in service_callback_lost_iphone
    account, devicename)
  File "/home/homeassistant/.homeassistant/custom_components/icloud3/device_tracker.py", line 5208, in service_handler_lost_iphone
    device.play_sound()
  File "/srv/homeassistant/lib/python3.6/site-packages/pyicloud/services/findmyiphone.py", line 137, in play_sound
    data=data
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/pyicloud/base.py", line 99, in request
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Internal Server Error

But either way… wanted to share my little Apple Devices page… iCloud3 is the only way I finally got reliable battery levels… I appreciate all your hard work

The last error:

File "/srv/homeassistant/lib/python3.6/site-packages/pyicloud/base.py", line 99, in request
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Internal Server Error

Shows that Pyicloud caused the crash. That is the interface between the code and the icloud find-my-friends that was written several years ago so I’m not sure what is going on there.

I ran the Lost Phone Alert on my iphone, my wife’s iphone and her iwatch and everything worked fine.

Are all of your ipads, iphones, ipods and iwatches on the same apple account or different accounts. When HA starts and iCloud3 loads, there is a lot of tracking messages as each account is processed for the device types and devices that are included and excluded for each device_tracker.icloud3 platform. Perhaps that will give you some more information as to what is going on.

++++ Breaking News +++++

FYI - It has been reported that Apple changed something on there end that is breaking the pyicloud.py program that sits between HA components and Apple. There is some issue where authorizing the access to the Apple iCloud account fails. It is happening on all versions of HA and on icloud3 (all versions), along with the base icloud component that is part of HA. I’ve tried it on 0.92.0, 0.93.0, 0.93.2, 0.94.0 & 0.94.1.

Everything works, or seems to, until the account needs to be reauthorized. I’m now keeping up with what is going on and am dead in the water until this issue is resolved.

Gary aka GeeksterGary

2 Likes

hmm…hope this is resolved soon. I like this component. BTW, anyone know if the official component is dead too?

1 Like

Yes, the official component is also dead😟

Well that stinks

Gotta blame apple for this

This seems to get it to authenticate but I’m at work and can’t do much testing… maybe someone else can see if it works for them https://github.com/PeterHedley94/pyicloud/commit/6bf11c87c784fa9b0f94318ea845e441b0937cf5

Going to give it a try now. Just need to find the base.py file.

Found and replaced it with the raw file. Only one error left in the log related to Icloud.

Are you using icloud3 1.0.4a ? Or the regular version. I believe that prerelease version may have fixed that error for me. I have the error too but I’m on 1.0.4. again. This I cloud breaking thing happened in the midst of my python upgrade and 0.94 upgrade so I rolled HA and iCloud3 back to versions I knew was working previously. If I get a chance in a little bit I will go to the prerelease version and see what happens

Edit: same error with 104a… I’m also getting ssl certificate errors… not sure if somehow related

i’m using the Icloud3 1.0.4 version.

Yep mine broke today also :frowning:

Noticed that it stoped working and when checking the logs its full of:

    if self.any_device_being_updated_flag:
AttributeError: 'Icloud' object has no attribute 'any_device_being_updated_flag'
2019-06-14 13:40:35 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/jrechena/.homeassistant/custom_components/icloud3/device_tracker.py", line 1088, in _polling_loop_5_sec_device
    if self.any_device_being_updated_flag:
AttributeError: 'Icloud' object has no attribute 'any_device_being_updated_flag'
2019-06-14 13:40:35 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/jrechena/.homeassistant/custom_components/icloud3/device_tracker.py", line 1088, in _polling_loop_5_sec_device
    if self.any_device_being_updated_flag:
AttributeError: 'Icloud' object has no attribute 'any_device_being_updated_flag'

:frowning:

Using HA 0.94.3 and I have the same issue. Would downgrading fix it?

No. See the post above.

1 Like

iCloud3 v1.0.5 is now available for download

The significant change is tracking devices when the iCloud Location Service is unavailable using the notifications from the HA ios app v1.5x. You will have to use the include_devices configuration parameter to specify the devices to be tracked. The include_device_type will not work since it is used to scan the iCloud account which is not available. The Change Log describes how it works in more detail.

More information is in the Change Log here
It can be downloaded from the iCloud3 github repository here.

1 Like

I assume this only works with ios app 1.5 and not 2.0 beta? I got to ask.

@Dayve67 That is correct. It only works with ios app v1.5. I’ve had the v2.0 beta and made some coding changes to support it but I need it to settle down and get closer to a finalized state before getting back into it.