diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae72ff..67b4a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # iCloud3 Change Log +#### v2.0.4 (11/29/2019) +- When the device's location, interval and next poll information were being updated, there were times when the state was 'stationary' but it had actualy moved into another zone. This might be caused by zones being close together, by no zone exit notification from the ios app or by the next update trigger being processed before the zone exit trigger had been received. This caused the device's location to be reset to the old location instead of the new location. This has been fixed. +- Waze history data is used to avoid calling Waze for route information when you are near another device or in a stationary zone with accurate Waze route information. If you were in a stationary zone and entered another zone without a zone exit trigger, the Waze history was still pointing to the old stationary zone. The old location information was being used for distance and interval calculations instead of the new location information. A check was added to always refresh the Waze route information when the state changes. +- Made some corrections to the iCloud3 documentation. + #### v2.0.3 (11/27/2019) - Fixed a problem with a malformed message that displayed old location information in the Event Log. diff --git a/custom_components/icloud3/device_tracker.py b/custom_components/icloud3/device_tracker.py index 54dcf23..b625076 100644 --- a/custom_components/icloud3/device_tracker.py +++ b/custom_components/icloud3/device_tracker.py @@ -22,8 +22,16 @@ #pylint: disable=unused-argument, unused-variable #pylint: disable=too-many-instance-attributes, too-many-lines -VERSION = '2.0.3' #Custom Component Updater +VERSION = '2.0.4' #Custom Component Updater ''' +v2.0.4 +- When the device's location, interval and next poll information were being updated, there were times when the state was 'stationary' but it had actualy moved into another zone. This might be caused by zones being close together, by no zone exit notification from the ios app or by the next update trigger being processed before the zone exit trigger had been received. This caused the device's location to be reset to the old location instead of the new location. This has been fixed. +- Waze history data is used to avoid calling Waze for route information when you are near another device or in a stationary zone with accurate Waze route information. If you were in a stationary zone and entered another zone without a zone exit trigger, the Waze history was still pointing to the old stationary zone. The old location information was being used for distance and interval calculations instead of the new location information. A check was added to always refresh the Waze route information when the state changes. + +v2.0.3 +- Fixed a problem with a malformed message that displayed old location information in the Event Log. +- Added a list of devices that are tracked and not tracked for the Family Sharing (famshr) tracking method. This is created when the iCloud account is scanned looking for the devices in the track_devices configuration parameter. + v2.0.2 - Fixed problem calculating distance and intervals for a second zone. - If the device_tracker.state is 'stationary' when the next update time is reached and you have moved into another zone that is not stationary, the 'zone' attribute is correct because it is based on the device's location values but the device_tracker.state is still 'stationary' instead of the zone the device is now in. This has been fixed. @@ -80,8 +88,9 @@ pass _LOGGER = logging.getLogger(__name__) -#REQUIREMENTS = ['pyicloud==0.9.1'] + DEBUG_TRACE_CONTROL_FLAG = False +#from .const_ic3 import "*" HA_ENTITY_REGISTRY_FILE_NAME='/config/.storage/core.entity_registry' @@ -1571,7 +1580,7 @@ def _polling_loop_5_sec_device(self, now): #icloud poll elif (self.location_isold_cnt.get(devicename) > 5 or self.poor_gps_accuracy_cnt.get(devicename) > 5): - event_msg = "__Discarding, Old data or Poor GPS" + event_msg = "__Discarding > Old data or Poor GPS" self._save_event(devicename, event_msg) continue @@ -1718,7 +1727,7 @@ def _polling_loop_5_sec_device(self, now): #set to last gps if in a zone if dist_from_zone < self.zone_home_radius * 1000: - event_msg = ("__Moving back to zone `{}` center, " + event_msg = ("__Moving to zone `{}` center, " "distance-{}m, GPS-({}, {}) to ({}, {})").format( current_zone, dist_from_zone, @@ -4276,7 +4285,7 @@ def _update_device_attributes(self, devicename, kwargs: str = None, state = self.state_this_poll.get(devicename) current_zone = self.zone_current.get(devicename) - ''' + ####################################################################### #The current zone is based on location of the device after it is looked #up in the zone tables. @@ -4285,7 +4294,7 @@ def _update_device_attributes(self, devicename, kwargs: str = None, #may not have been issued. If the trigger was the next update time #reached, the state and zone many now not match. (v2.0.2) - if state == NOT_SET: + if state == NOT_SET or current_zone == NOT_SET or current_zone == '': pass #If state is 'stationary' and in a stationary zone, nothing to do @@ -4305,7 +4314,7 @@ def _update_device_attributes(self, devicename, kwargs: str = None, self._save_event(devicename, event_msg) state = current_zone ####################################################################### - ''' + #Get friendly name or capitalize and reformat state @@ -4445,13 +4454,14 @@ def _setup_base_kwargs(self, devicename, latitude, longitude, elif self._is_inzoneZ(state): zone_name = self._format_zone_name(devicename, state) - if zone_name: + #v2.0.4-Added 'zone_name == state' check + if zone_name and zone_name == state: zone_lat = self.zone_latitude.get(zone_name) zone_long = self.zone_longitude.get(zone_name) if zone_lat and (latitude != zone_lat or longitude != zone_long): if self._update_last_latitude_longitude(devicename, zone_lat, zone_long, 4450): - event_msg = ("__Moving back to zone `{}` center, " + event_msg = ("__Moving to zone `{}` center, " "GPS-({}, {}) to ({}, {})").format( zone_name, latitude, @@ -6733,7 +6743,7 @@ def _get_waze_from_data_history(self, devicename, ''' Before getting Waze data, look at all other devices to see if there are any really close. If so, don't call waze but use their - distance & time instead if the data it it passes distance and age + distance & time instead if the data it passes distance and age tests. The other device's distance from home and distance from last @@ -6751,6 +6761,10 @@ def _get_waze_from_data_history(self, devicename, return None elif self.base_zone != HOME: return None + elif _isnot_inzone(devicename): + pass + elif self.state_this_poll.get(devicename) != self.zone_current.get(devicename): + return None #Calculate how far the old data can be from the new data before the #data will be refreshed. @@ -6763,8 +6777,7 @@ def _get_waze_from_data_history(self, devicename, devicename_zone = self._format_devicename_zone(devicename) self.waze_history_data_used_flag[devicename_zone] = False - waze_data_other_device = self.waze_distance_history.get( - near_devicename_zone) + waze_data_other_device = self.waze_distance_history.get(near_devicename_zone) #Skip if this device doesn't have any Waze data saved or it's for #another base_zone. if len(waze_data_other_device) == 0: diff --git a/docs/chapters/1-setting-up-icloud-account.md b/docs/chapters/1-setting-up-icloud-account.md index 4573711..19ea844 100644 --- a/docs/chapters/1-setting-up-icloud-account.md +++ b/docs/chapters/1-setting-up-icloud-account.md @@ -39,7 +39,7 @@ The Apple support web site has several articles that will help you set up yout i - Go [here](https://support.apple.com/en-us/HT201088) for Set up Family Sharing - Go [here](https://support.apple.com/en-us/HT210400) for Set up Find My app -#### Find-my-Friends (FmF) {docsify-ignore} +#### Find-my-Friends (FmF) tracking method You set up the device’s primary user as a friend on the `Find My` app (iOS 13) or the `Find-my-Friends` app (iOS 12) and iCloud3 will locate them just like the app does. Since your Apple iCloud account probably has 2fa turned on, you need to create a new iCloud account without 2fa, then add the person using the device as a friend to that account, share their location and verify their location is being shared before setting up iCloud3. 1. Add a new iCloud account with a different email address. Do not select the 2fa option, otherwise you will be in the same constant notification situation you are trying to avoid. You will use this email address in the `username` configuration parameter. @@ -60,17 +60,17 @@ You set up the device’s primary user as a friend on the `Find My` app (iOS 13) *This diagram shows how the Find-my-Friends Contact List information is stored on your iCloud Account. iCloud3 accesses this information to locate your devices. If any of the information is missing or not set up correctly, iCloud3 can not locate your device.*
-#### Trouble Shooting FmF {docsify-ignore} +#### Trouble Shooting the Find-my-Friends (FmF) tracking method {docsify-ignore} ##### iCloud3 Error: No devices to track message This can be caused by the following conditions: -1. The contacts have not been added to the non-2fa with the email address on the track_devices parameter. See item 4 above and verify they are visible on the `Find My` app. -2. The non-2fa username or password is invalid and the account can not be authorized. Verify the account can be accessed in the `Find My` app. If you need additional help, the links in the Apple iCloud Documentation paragraph above are a good source of information. -3. You can not connect to iCloud Location Services. Check the username and password. Check for network errors. +1. The contacts have not been added to the*Find-my-Friends* non-2fa account with the email address you have entered on the track_devices parameter. See item 4 above and verify they are visible on the `Find My` app. +2. The *Find-my-Friends* non-2fa account username or password is invalid and the account can not be authorized. Verify that the account can be accessed in the `Find My` app. If you need additional help, the links in the Apple iCloud Documentation paragraph above are a good source of information. +3. You can not connect to the iCloud Location Services. Again, check the *Find-my-Friends* non-2fa account username and password. Check for network errors. -#### Family Sharing (FamShr) {docsify-ignore} +#### Family Sharing (FamShr) Tracking Method If you do not have 2fa turned on on your 'real' iCloud account, you can use the Family Sharing tracking method to locate your device(s). iCloud3 looks for the devices to be tracked in the list of people that are in the Family Sharing list on your iCloud account. With Family Sharing, you use your 'real' iCloud account email address for the `username` configuration parameter. @@ -78,7 +78,7 @@ The `tracking_method` and `track_devices` configuration parameters are used to i !> Family Sharing was the only tracking method used on iCloud3 version 1. -#### Trouble Shooting FamShr +#### Trouble Shooting the Family Sharing (FamShr) Tracking Method {docsify-ignore} ##### You get an iCloud3 Error: No devices to track message @@ -88,6 +88,12 @@ iCloud3 scans through the list of devices that have been set up in the Family Sh 2. The username or password is invalid and the account can not be authorized. Verify the account can be accessed in the `Find My` app. If you need additional help, the links in the Apple iCloud Documentation paragraph above are a good source of information. 3. You can not connect to iCloud Location Services. Check the username and password. Check for network errors. +#### iCloud3 Event Log During Initialization + +The Event Log provides a lot of information on the iCloud initialization process. + +![event_log_initializing](../images/event_log_initializing.jpg) + ### Authenticating Your iCloud Account Home Assistant and iCloud3 needs to be authorized to access your iCloud account. It requests authorization by asking iCloud to send an authentication code via a text message to a trusted device, which is then entered in Home Assistant. The duration of this authentication is determined by Apple, but is now at 2 months. diff --git a/docs/images/event_log_initializing.jpg b/docs/images/event_log_initializing.jpg new file mode 100644 index 0000000..ee2595a Binary files /dev/null and b/docs/images/event_log_initializing.jpg differ