Skip to content

Commit

Permalink
iCloud3 v3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gcobb321 committed Nov 8, 2024
1 parent 54a14e3 commit 656dda3
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

------

[![CurrentVersion](https://img.shields.io/badge/Current_Version-v3.1.1-blue.svg)](https://github.com/gcobb321/icloud3_v3) [![Type](https://img.shields.io/badge/Type-Custom_Component-orange.svg)](https://github.com/gcobb321/icloud3_v3) [![HACS](https://img.shields.io/badge/HACS-Custom_Repository-orange.svg)](https://github.com/gcobb321/icloud3_v3)
[![CurrentVersion](https://img.shields.io/badge/Current_Version-v3.1.2-blue.svg)](https://github.com/gcobb321/icloud3_v3) [![Type](https://img.shields.io/badge/Type-Custom_Component-orange.svg)](https://github.com/gcobb321/icloud3_v3) [![HACS](https://img.shields.io/badge/HACS-Custom_Repository-orange.svg)](https://github.com/gcobb321/icloud3_v3)

[![ProjectStage](https://img.shields.io/badge/Project_Stage-Development_Version-forestgreen.svg)](https://github/gcobb321/icloud3_v3) [![Released](https://img.shields.io/badge/Released-November,_2024-forestgreen.svg)](https://github.com/gcobb321/icloud3_v3)

Expand Down
14 changes: 11 additions & 3 deletions custom_components/icloud3/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@



3.1.2
.......................
### Change Log - v3.1.2
1. INITIAL SETUP (Fixed) - Fixed some issues related to setting up iCloud3 the first time or with no apple accounts.



3.1.1
.......................
### Change Log - v3.1.1
1. LOCATING DEVICES:
- Added additional checks to insure the Apple Account location data was refreshed during startup and while configuing iCloud3 settings. Fixed a problem where the location information data from Apple was not being initialized properly.
- Fixed the location refresh not being causied the '0 of 0' to be displayed in the Configure Setting screens, leading to the Apple Account selection lists to not be populated.
- Fixed the location refresh not being done that caused the '0 of 0' to be displayed in the Configure Setting screens, leading to the Apple Account selection lists to not be populated.
- Fixed some problems where 'Locate All Devices = False' would still locate all the devices in the Apple account
- Added error checking to make sure the Locate All Devices can not be disabled if there were Family devices that
were asigned to that Apple account. If it was disabled, they would never be locaed.
2. UPDATE DEVICE SCREEN - Added (and fixed) the TOOLS - RESET DATA SOURCE(S), DELETE DEVICE(S) option where you can reset the device's Apple Account and Mobile App to default values (None) and fixed a problem deleting devices. Reworked the Apple Acccount selection list to provide more information and identify setup errors.
were assigned to that Apple account. If it was disabled, they would never be located.
2. UPDATE DEVICE SCREEN - Added (and fixed) the TOOLS - RESET DATA SOURCE(S), DELETE DEVICE(S) option where you can reset the device's Apple Account and Mobile App to default values (None) and fixed a problem deleting devices. Reworked the Apple Account selection list to provide more information and identify setup errors.
3. UPDATE APPLE ACCOUNT USERNAME/PASSWORD SCREEN - Added checks to insure Locating All Devices can not be disabled if there are tracked devices assigned to this account that are in the Family list.
4. OTHER THINGS - Changed several things under the covers.

Expand Down
3 changes: 3 additions & 0 deletions custom_components/icloud3/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,9 @@ def _update_conf_apple_accounts(self, aa_idx, user_input, remove_acct_flag=False

# Add a new account
elif self.add_apple_acct_flag:
if len(Gb.conf_apple_accounts) < 1:
Gb.conf_apple_accounts = [DEFAULT_APPLE_ACCOUNTS_CONF.copy()]

if Gb.conf_apple_accounts[0][CONF_USERNAME] == '':
Gb.conf_apple_accounts[0] = self.conf_apple_acct.copy()
self.aa_idx = 0
Expand Down
10 changes: 5 additions & 5 deletions custom_components/icloud3/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

VERSION = '3.1.1'
VERSION = '3.1.2'
VERSION_BETA = ''
#-----------------------------------------
ICLOUD3 = 'iCloud3'
Expand Down Expand Up @@ -295,12 +295,12 @@ def DEVICE_TYPE_FNAME(device_type):
RED_ALERT = '⛔'
RED_STOP = '🛑'
RED_CIRCLE = '⭕'
SMALL_X = '× '
SMALL_X = ' '
CIRCLE_STAR = '✪ '
CIRCLE_STAR2 = '✪'
CIRCLE_BIG_X = '⊗'
CIRCLE_SLASH = '⊘'
CIRCLE_X = ''
CIRCLE_X = ''
DOT = '• '
PDOT = '•'
SQUARE_DOT = '▪'
Expand All @@ -318,7 +318,7 @@ def DEVICE_TYPE_FNAME(device_type):
NL_DOT = f'{NL} • '
CRLF_XD = f'{CRLF}{NBSP2}×{NBSP2}'
CRLF_X = f'{CRLF}{NBSP3}×{NBSP2}'
CRLF_CIRCLE_X = f'{CRLF}{NBSP2}{NBSP}'
CRLF_CIRCLE_X = f'{CRLF}{NBSP2}{NBSP}'
CRLF_RED_X = f'{CRLF}❌'
CRLF_HDOT = f'{CRLF}{NBSP4}{NBSP3}{NBSP2}'
CRLF_CHK = f'{CRLF}{NBSP3}{NBSP}'
Expand Down Expand Up @@ -852,7 +852,7 @@ def DEVICE_TYPE_FNAME(device_type):
DEFAULT_TRACKING_CONF = {
CONF_USERNAME: '',
CONF_PASSWORD: '',
CONF_APPLE_ACCOUNTS: [DEFAULT_APPLE_ACCOUNTS_CONF],
CONF_APPLE_ACCOUNTS: [],
CONF_ENCODE_PASSWORD: True,
CONF_ICLOUD_SERVER_ENDPOINT_SUFFIX: '',
CONF_SETUP_ICLOUD_SESSION_EARLY: True,
Expand Down
1 change: 1 addition & 0 deletions custom_components/icloud3/helpers/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ def filter_special_chars(log_msg, evlog_export=False):
log_msg = log_msg.replace('* >', '')
log_msg = log_msg.replace('&lt;', '<')

# The Gb.log_file_filter is set up in config_file.build_log_file_filter
for log_file_filter in Gb.log_file_filter:
log_msg = log_msg.replace(log_file_filter, '…………')

Expand Down
2 changes: 1 addition & 1 deletion custom_components/icloud3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/gcobb321/icloud3_v3/issues",
"loggers": ["icloud3"],
"requirements": ["srp"],
"version": "3.1"
"version": "3.1.2"
}
26 changes: 14 additions & 12 deletions custom_components/icloud3/support/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _reconstruct_conf_file():

# for apple_acct in Gb.conf_apple_accounts:
# apple_acct[CONF_PASSWORD] = encode_password(apple_acct[CONF_PASSWORD])

encode_all_passwords()

Gb.conf_tracking[CONF_APPLE_ACCOUNTS] = Gb.conf_apple_accounts
Expand Down Expand Up @@ -308,7 +308,9 @@ def build_log_file_filters():

try:
for apple_acct in Gb.conf_apple_accounts:
if instr(apple_acct[CONF_USERNAME], '@'):
if apple_acct[CONF_USERNAME] == '':
continue
elif instr(apple_acct[CONF_USERNAME], '@'):
email_extn = f"{apple_acct[CONF_USERNAME].split('@')[1]}"
list_add(Gb.log_file_filter, email_extn)

Expand Down Expand Up @@ -377,7 +379,7 @@ def conf_apple_acct(idx_or_username):
try:
if len(Gb.conf_apple_accounts) == 0:
conf_apple_acct = DEFAULT_APPLE_ACCOUNTS_CONF.copy()
Gb.conf_apple_accounts = [conf_apple_acct]
# Gb.conf_apple_accounts = [conf_apple_acct]
return (conf_apple_acct, 0)

if type(idx_or_username) is int:
Expand All @@ -389,7 +391,7 @@ def conf_apple_acct(idx_or_username):
elif type(idx_or_username) is str:
conf_apple_acct = [apple_acct for apple_acct in Gb.conf_apple_accounts
if apple_acct[CONF_USERNAME] == idx_or_username]
conf_apple_acct_username = [apple_account[CONF_USERNAME]
conf_apple_acct_username = [apple_account[CONF_USERNAME]
for apple_account in Gb.conf_apple_accounts]
conf_apple_acct_idx = conf_apple_acct_username.index(idx_or_username)

Expand Down Expand Up @@ -606,21 +608,21 @@ def _update_tracking_parameters():

# v3.1 Add Apple accounts list
try:
if (CONF_APPLE_ACCOUNTS not in Gb.conf_tracking
or Gb.conf_tracking[CONF_APPLE_ACCOUNTS] == []):
if (CONF_APPLE_ACCOUNTS not in Gb.conf_tracking):
# or Gb.conf_tracking[CONF_APPLE_ACCOUNTS] == []):
update_config_file_flag = True

Gb.conf_tracking = _insert_into_conf_dict_parameter(
Gb.conf_tracking,
CONF_APPLE_ACCOUNTS, '',
before=CONF_DEVICES)

Gb.conf_apple_accounts = Gb.conf_tracking[CONF_APPLE_ACCOUNTS] = [
{ CONF_USERNAME: Gb.conf_tracking[CONF_USERNAME],
CONF_PASSWORD: encode_password(Gb.conf_tracking[CONF_PASSWORD]),
CONF_TOTP_KEY: '',
CONF_LOCATE_ALL: True,
}]
Gb.conf_apple_accounts = Gb.conf_tracking[CONF_APPLE_ACCOUNTS] = []
# { CONF_USERNAME: Gb.conf_tracking[CONF_USERNAME],
# CONF_PASSWORD: encode_password(Gb.conf_tracking[CONF_PASSWORD]),
# CONF_TOTP_KEY: '',
# CONF_LOCATE_ALL: True,
# }]

except Exception as err:
_LOGGER.exception(err)
Expand Down
9 changes: 3 additions & 6 deletions custom_components/icloud3/support/pyicloud_ic3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ def verify_all_apple_accounts():
username = conf_apple_acct[CONF_USERNAME]
password = Gb.PyiCloud_password_by_username[username]

if is_empty(username):
Gb.username_valid_by_username[f"AA-NOTSPECIFIED-#{cnt}"]
continue
if is_empty(password):
Gb.username_valid_by_username[f"AA-NOPASSWORD-#-{cnt}"]
if is_empty(username) or is_empty(password):
Gb.username_valid_by_username[f"AppleAcctNoUserPW-#{cnt}"] = False
continue

# Validate username/password so we know all future login attempts will be with valid apple accts
Expand All @@ -131,7 +128,7 @@ def verify_all_apple_accounts():
if valid_apple_acct is False:
post_event(f"Apple Acct > {username}, Username/Password Invalid")

Gb.startup_lists['Gb.username_valid_by_username'] = Gb.username_valid_by_username
Gb.startup_lists['Gb.username_valid_by_username'] = Gb.username_valid_by_username


#--------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion custom_components/icloud3/support/start_ic3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,10 @@ def create_Devices_object():
Gb.icloud_dnames_by_devicename = {}
Gb.conf_startup_errors_by_devicename = {}

_log(f"{len(Gb.conf_apple_accounts)=} {len(Gb.username_valid_by_username)=}")
if len(Gb.conf_apple_accounts) != len(Gb.username_valid_by_username):
pyicloud_ic3_interface.verify_all_apple_accounts()
_log(f"{len(Gb.conf_apple_accounts)=} {len(Gb.username_valid_by_username)=}")

for conf_device in Gb.conf_devices:
devicename = conf_device[CONF_IC3_DEVICENAME]
Expand Down Expand Up @@ -1697,7 +1699,7 @@ def _post_evlog_apple_acct_tracked_devices_info(PyiCloud):
f"{devices_assigned_msg}"
f"{devices_not_assigned_msg}")

famshr_crlf = CRLF_DOT if PyiCloud.locate_all_devices else CRLF_CIRCLE_X
famshr_crlf = CRLF_DOT if PyiCloud.locate_all_devices else CRLF_STAR
if owner_icloud_dnames:
evlog_msg += f"{CRLF_DOT} myDevices-{owner_icloud_dnames}"
if famshr_dnames_msg:
Expand Down
27 changes: 17 additions & 10 deletions custom_components/icloud3/support/start_ic3_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ def stage_4_setup_data_sources():
post_event(f"Data Source > HA Mobile App used-{Gb.use_data_source_MOBAPP}")

try:
if Gb.use_data_source_ICLOUD:
_log_into_apple_accounts()
# Get list of all unique Apple Acct usernames in config
Gb.conf_usernames = [apple_account[CONF_USERNAME]
for apple_account in Gb.conf_apple_accounts
if (apple_account[CONF_USERNAME] in Gb.username_valid_by_username
and apple_account[CONF_USERNAME] != '')]

if Gb.use_data_source_ICLOUD and isnot_empty(Gb.conf_usernames):
_log_into_apple_accounts(retry=True)

start_ic3.setup_data_source_ICLOUD()

Expand Down Expand Up @@ -332,13 +338,13 @@ def _log_into_apple_accounts(retry=False):
if Gb.initial_icloud3_loading_flag is False:
return True

# When iCloud3 starts, an executor job is started at the beginning of __init__
# to connect to all Apple Accounts. Now, cycle through the PyiCloud object table
# and see if any are not set up that should be
# Get list of all unique Apple Acct usernames in config
Gb.conf_usernames = [apple_account[CONF_USERNAME]
for apple_account in Gb.conf_apple_accounts
if apple_account[CONF_USERNAME] in Gb.username_valid_by_username]
# # Get list of all unique Apple Acct usernames in config
# Gb.conf_usernames = [apple_account[CONF_USERNAME]
# for apple_account in Gb.conf_apple_accounts
# if (apple_account[CONF_USERNAME] in Gb.username_valid_by_username
# and apple_account[CONF_USERNAME] != '')]
if is_empty(Gb.conf_usernames):
return False

# Verify that all apple accts have been setup. Restart the setup process for any that
# are not complete
Expand All @@ -361,7 +367,8 @@ def _log_into_apple_accounts(retry=False):
post_event(f"Apple Acct > {PyiCloud.username_base}, All Devices Located")
else:
post_event(f"Apple Acct > Devices not Located > {list_to_str(Gb.devices_without_location_data)}")
return False

return True

#------------------------------------------------------------------
def _are_all_devices_verified(retry=False):
Expand Down

0 comments on commit 656dda3

Please sign in to comment.