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

I just installed v 1.0.1 of this component on hass.io 0.90.1. Everything configured according to documentation. When I restart HA, I get a 2FA notification from iCloud which I approve (so my credentials obviously works), but there is nowhere in the GUI where I can enter the OTP. Consequently, no entities get generated.
Any pointers to where I should look?

After two months, memory is a bit hazy. Have you looked at notifications on the Overview page?

Where the failed login notifications and similar stuff go? Yep, thatā€™s where I expected to find it, but no such luck.

Update: I missed something in the logs that is probably significant:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File ā€œ/usr/local/lib/python3.7/concurrent/futures/thread.pyā€, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File ā€œ/config/custom_components/icloud3/device_tracker.pyā€, line 1231, in _polling_loop_5_sec_device
self.iosapp_update_flag[devicename] = False
UnboundLocalError: local variable ā€˜devicenameā€™ referenced before assignment

1 Like

I found those same errors in my log being generated every 15 secsā€¦ Downgraded to previous version for now until this gets fixed.

1 Like

Did a reinstallation of this component. Same issue:

Sat Mar 23 2019 11:00:45 GMT+0100 (sentraleuropeisk normaltid)
Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/icloud3/device_tracker.py", line 1233, in _polling_loop_5_sec_device
self.iosapp_update_flag[devicename] = False
UnboundLocalError: local variable 'devicename' referenced before assignment

My environment:

arch x86_64
dev false
docker true
hassio true
os_name Linux
python_version 3.7.2
timezone Europe/Oslo
version 0.90.1
virtualenv false

Lovelace

mode storage
resources 3
views 13

configuration.yaml:

device_tracker:
  - platform: icloud3
    username: !secret icloud_user_ragnar
    password: !secret icloud_pass_ragnar
    account_name: ragnar_icloud

custom component:

root@doffen icloud3]# pwd
/usr/share/hassio/homeassistant/custom_components/icloud3
[root@doffen icloud3]# ls
device_tracker.py  __pycache__
[root@doffen icloud3]# md5sum device_tracker.py
ee331652f3472c35b87e02c0ae1e9c6c  device_tracker.py
1 Like

@gcobb321 ETA on 1.0.2 ? So far 1.0.1 working well minus the Waze issue.

I just updated iCloud3 to v1.0.2.

A brief description of the changes:

  1. If you are a long way from home, it appears Waze times out and doesnā€™t return any route information. But if you try again, it might. I am now retrying getting waze route data. and generates an error if it doesnā€™t return anything after 4 retrys.
  2. A message in the Waze Distance field will be displayed if there were any problems, waze is paused, waze is off, etc rather than leaving it blank.
  3. Sharing Waze data between devices on the same iCloud account to reduce the number of calls to the Waze Route Calculator.
  4. Fixed some issues with the _badge where if you defined a template for a badge, the entity_picture data was getting destroyed.
  5. Optimizing some code related to sensors.

See the ChangeLog for details on the changes and breaking changes to the ā€˜_badge Sensorā€™.

https://github.com/gcobb321/icloud3/releases/tag/v1.0.2

Hi,
I have a problem with configuration. I canā€™t confirm the code. Still have info that configuration service canā€™t start.
Any thought?
Errors log:
list index out of range
19:14 custom_components/icloud3/device_tracker.py (ERROR) - message first occured at 19:10 and shows up 6 times
iCloud Acount Reauthorization Needed
19:14 custom_components/icloud3/device_tracker.py (ERROR) - message first occured at 19:10 and shows up 17 times

robertpe

Try taking a look at this in the Readme

Solved, thanks. Now is working OK.

1.0.2 fixed the log errors, just as advertised. It also made the configuration dialog show up in persistent notifications. Great work!

I was working well on 1.0.1 other than sometimes it seemed to take a while to leave my home zone, I thought it might be related to timing of a restarts? Anyway, just upgraded to 1.0.2, left home, was gone for a few hours, and the icloud3 showed me as home the whole time. Even entered another zone. This was both my icloud devices.

Edit: Well I did drive past my house at the very end, and it went from home to away, and then back to home (where I am now). Weā€™ll see, maybe it just needs to have a few zone changes after a restart?

ptdalen

Go into the IOS app Settings page, scroll down and look at the Events List. Look at each item and see if there were any Geographic Region Enter/Exit items. That is what I use to trigger a zone change. The HA log file might also show something. If I get a Background Fetch when outside of the zone without first getting an Exit notification, it throws the Fetch away and puts you back in the zone.

Also, turn on the iCloud3 debugger which writes a lot of stuff to the log file (See the end of the readme) There was a script that would do that in the config files. If you installed the script, you can turn the debugger on and off without restarting HA.

Shouldnā€™t need any zone changes after a restart to get synced up.

Bad GPS and old icloud records will also cause retries. Are you looking at the device_tracker.state changes or the sensor.zone changes?

I didnā€™t make any changes there. But the one area I did change was the Waze data history. If the phone saved some waze data that was in a zone and then reset it at a later time, it might that might have put it back into the zone. The log file would indicate the waze history was being used to rather than calling waze again. But I think waze is paused when in the home zone. If it still acts weird and you want me to look at the log file, let me know. Or send it to [email protected]

Keep me posted on what happens. Always get concerned about issues just after an update.

Gary.

Here is my icloud 3 info this morning

source type
gps
latitude
36.xxxx
longitude
-75.yyyy
gps accuracy
8
battery
100
zone
home
last zone
home
zone timestamp
03/24/19, 5:27:42
trigger
iCloud
timestamp
2019-03-25T07:29:30.249
interval
2 hrs
travel time
distance
0
calc distance
0
waze distance
last located
7:29:27
last update
7:29:30
next update
9:29:30
poll count
4:0:16
dir of travel
in_zone
travel distance
0
info
ā—Battery-100%
speed
0
altitude
0
battery status
NotCharging
device status
online
low power mode
false
authenticated
03/25/19, 7:29:17
tracking
pauls_icloud/paulsiphone, pauls_icloud/tracy_siphone
icloud3 version
1.0.2
account name
pauls_icloud

and here is my ios app info

source type
gps
latitude
36.differentxxx
longitude
-76.differentyyy
gps accuracy
65
battery
98
timestamp
2019-03-25T08:39:28.120-0400
course
-1
trigger
Background Fetch
altitude
1.2575989961624146
speed
-1
vertical accuracy
10
floor
2146959360

I traveled about 20 miles over 30 minutes.


I restarted HA last night. I was at home at the time, and had not left home until this morning. My wifeā€™s phone has similiar results at the moment.

It did change to my current zone (both me and my wife at the same time) at the Next Update time.

ptdalen
From the attribute screenshots, it looks like the ios app issued:
7:58 Background Fetch
8:05 Zone Exit
8:15 device_tracker.see (this can change the device_trackerā€™s state)
8:23 device_tracker.see
8:23 Background Fetch
8:27 Zone Enter

iCloud3 Attributes:
5:27 changed Home Zone, Last Zone is also Home
7:29 next_update time reached, did iCloud trigger

Poll count of 4:0:16 says there were 4 iCloud location updates, 0 updates from the IOS app and 16 notifications from the IOS app that were discarded. The reasons for discarding the IOS app notification are:

  • the location data was more than 2 minutes old (and could be wrong)
  • the gps location on a Background Fetch was outside of the zone.when the deviceā€™s zoneā€™ attribute was still in the zone so it was probably because the gps wandered.

Seeing the IOS transaction count of 0 says that all of the IOS app notifications were thrown away. The IOS app triggeres a state change (device_tracker.see) before iCloud3 gets the data . iCloud3, by using itā€™s own Zone attribute that it maintains can avoid wrong state changes and correcting them when it finds them in a short period of time.

I think that is what is happening, the d_t.state is changed by the IOS app and changed back by iC3. But the Zone attribute remains the same.

In your first post, you left home and it never went to not_home. If you leave home and the IOS app doesnā€™t issue an Exit notification, iC3 will never change the zone. If you are always having this issue, you have two options:

  • set up another ā€˜near_zoneā€™ down the road a bit that might wake the IOS app up (see the Readme Special Zones for more info about a ā€˜near_zoneā€™.
  • put a beacon in your garage and use that to also trigger a zone exit via the IOS app.

Iā€™m thinking about adding an ā€˜event_logā€™ attributeā€™ that be updated on significant events. Then you can just scroll through the ā€˜Logā€™ entries on the HA Frontend and it will give you a sense of the iC3 events without going through the HA Log file.

Hope this helps.

Iā€™ll continue to check on this, but just saying that, I have not changed or added zones in quite a while. I donā€™t think my gps data was stale, but who knows. I have three GPS device based trackers plus this one.

the iOS app, life 360 and google location sharing. These three all changed to away (not_home) within 1 minute or less of each other. Life 360 showed me as moving, and updated itā€™s info as expected.

The iOS app showed me entering my work zone, immediately upon entering the zone. I have another automation that I use to calculate commute times from zone to zone, and it ran right on schedule, as I pulled up.

1.0.1, worked, 1.0.2 does not seem to be getting updated zone change info from my iOS app. My other iphone (wife) is acting the exact same way.

Of course I dont change zones often, so Iā€™ll have to see what happens when I leave work today.

Do I need to sign out and back in with the iOS app, is there some cache somewhere that should have been deleted?

I wonder if iC3 is throwing away an IOS notification that it shouldnā€™t be. If it gets a Background Fetch and is in a zone, it looks at the distance from the zone ā€¦

  • distance<.05, it puts it back in the zone
  • distance<1km, discard transaction
  • distance<2km, relocate via iCloud location services.

Question, what changed to away, the device_tracker.paulsiphone state or the sensor.paulsiphone state?

The HA log file with the debugger on is the only way to know for sure. If you want to turn it on and email to [email protected], Iā€™ll see if I see anything.

I dont mind, and Iā€™ll set it up when I get a chance (might not be until tomorrow.)

Not related, just wondering about the battery state and the format with the bullet. Is that intentional? Really, just curious.