From aab66512532f956662db33dd2b2bbf9703aa81ba Mon Sep 17 00:00:00 2001 From: gcobb321 Date: Sat, 9 Nov 2024 12:49:02 -0500 Subject: [PATCH] iCloud3 v3.1.3 --- README.md | 2 +- custom_components/icloud3/ChangeLog.txt | 12 +++++++++++- custom_components/icloud3/config_flow.py | 14 ++++++++------ custom_components/icloud3/const.py | 2 +- custom_components/icloud3/const_more_info.py | 13 +++++++++++-- custom_components/icloud3/manifest.json | 2 +- custom_components/icloud3/support/pyicloud_ic3.py | 9 +++------ .../icloud3/support/pyicloud_ic3_interface.py | 2 +- custom_components/icloud3/support/start_ic3.py | 13 ++++++++----- .../icloud3/support/start_ic3_control.py | 6 +++--- 10 files changed, 48 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 880b4d0..f5ff122 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ------ -[![CurrentVersion](https://img.shields.io/badge/Current_Version-v3.1.2-blue.svg)](https://github.com/gcobb321/icloud3) [![Type](https://img.shields.io/badge/Type-Custom_Component-orange.svg)](https://github.com/gcobb321/icloud3) [![HACS](https://img.shields.io/badge/HACS-Standard_Repository-orange.svg)](https://github.com/gcobb321/icloud3) +[![CurrentVersion](https://img.shields.io/badge/Current_Version-v3.1.3-blue.svg)](https://github.com/gcobb321/icloud3) [![Type](https://img.shields.io/badge/Type-Custom_Component-orange.svg)](https://github.com/gcobb321/icloud3) [![HACS](https://img.shields.io/badge/HACS-Standard_Repository-orange.svg)](https://github.com/gcobb321/icloud3) [![ProjectStage](https://img.shields.io/badge/Project_Stage-General_Availability-forestgreen.svg)](https://github/gcobb321/icloud3) [![Released](https://img.shields.io/badge/Released-November,_2024-forestgreen.svg)](https://github.com/gcobb321/icloud3) diff --git a/custom_components/icloud3/ChangeLog.txt b/custom_components/icloud3/ChangeLog.txt index cc58164..bdeaf77 100644 --- a/custom_components/icloud3/ChangeLog.txt +++ b/custom_components/icloud3/ChangeLog.txt @@ -8,7 +8,17 @@ 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. +1. INITIAL SETUP (Fixed) - This fixed some issues related an initial install where there are no apple accounts or where the iCloud3 Apple account's first configuration file entry was blank.. This fixes the error message: + ``` + File "/config/custom_components/icloud3/config_flow.py", line 1974, + in async_step_update_apple_acct + self._update_conf_apple_accounts(self.aa_idx, user_input) + File "/config/custom_components/icloud3/config_flow.py", line 2055, + in _update_conf_apple_accounts + if Gb.conf_apple_accounts[0][CONF_USERNAME] == '': + ~~~~~~~~~~~~~~~~~~~~~~^^^ + IndexError: list index out of range +``` diff --git a/custom_components/icloud3/config_flow.py b/custom_components/icloud3/config_flow.py index 1db203c..aac5ee8 100644 --- a/custom_components/icloud3/config_flow.py +++ b/custom_components/icloud3/config_flow.py @@ -64,7 +64,7 @@ sort_dict_by_values, encode_password, decode_password, ) from .helpers.messaging import (log_exception, log_debug_msg, log_info_msg, - _log, _evlog, + _log, _evlog, more_info, post_event, post_monitor_msg, ) from .helpers import entity_io from .helpers import file_io @@ -3977,9 +3977,6 @@ async def _build_mobapp_entity_selection_list(self, selected_devicename=None): Gb.mobapp_dnames_by_devicename[_conf_device[CONF_IC3_DEVICENAME]] =\ _conf_device[CONF_MOBILE_APP_DEVICE] - # if is_empty(Gb.devicenames_by_mobapp_dname): - # return - mobapp_devices ={mobapp_dname:( f"{mobapp_info[0]} " f"(device_tracker.{mobapp_dname}) > " @@ -3998,10 +3995,15 @@ async def _build_mobapp_entity_selection_list(self, selected_devicename=None): else: devicename = Gb.devicenames_by_mobapp_dname[mobapp_dname] - Device = Gb.Devices_by_devicename[devicename] + Device = Gb.Devices_by_devicename.get(devicename) + if Device: + fname_devicename = Device.fname_devicename + else: + fname_devicename = f"{CIRCLE_STAR}{devicename} (UNKNOWN)" + devices_used[mobapp_dname] = ( f"{mobapp_info.split(';')[0]}{RARROW}" - f"ASSIGNED TO-{Device.fname_devicename}") + f"ASSIGNED TO-{fname_devicename}") try: scan_for_mobapp_devices = { diff --git a/custom_components/icloud3/const.py b/custom_components/icloud3/const.py index 92306d0..6bedf49 100644 --- a/custom_components/icloud3/const.py +++ b/custom_components/icloud3/const.py @@ -10,7 +10,7 @@ # #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -VERSION = '3.1.2' +VERSION = '3.1.3' VERSION_BETA = '' #----------------------------------------- ICLOUD3 = 'iCloud3' diff --git a/custom_components/icloud3/const_more_info.py b/custom_components/icloud3/const_more_info.py index 5d65bd7..8d828bf 100644 --- a/custom_components/icloud3/const_more_info.py +++ b/custom_components/icloud3/const_more_info.py @@ -213,6 +213,15 @@ 'instructions_already_displayed': ( f"{CRLF_DASH_75}" - f"{CRLF}See the instructions that have already been displayed" - ), + f"{CRLF}See the instructions that have already been displayed"), + + 'password_srp_error': ( + f"{CRLF_DASH_75}" + f"{CRLF}The Python module that creates the Secure Remote Password (SRP) " + f"hash key has calculated an incorrect value for a valid assword. You probably " + f"will have to change the Apple Account password to be able to log into it. " + f"{CRLF}{CRLF}For more infornation, go to the iCloud3 GitHub " + f"issues page. Click the red Bug icon on the Event Log and " + f"review the{CRLF}`➤ Password SRP Error Message` issue at the top of the screen."), + } diff --git a/custom_components/icloud3/manifest.json b/custom_components/icloud3/manifest.json index 3fb6793..b47f10f 100644 --- a/custom_components/icloud3/manifest.json +++ b/custom_components/icloud3/manifest.json @@ -10,5 +10,5 @@ "issue_tracker": "https://github.com/gcobb321/icloud3/issues", "loggers": ["icloud3"], "requirements": ["srp"], - "version": "3.1.2" + "version": "3.1.3" } diff --git a/custom_components/icloud3/support/pyicloud_ic3.py b/custom_components/icloud3/support/pyicloud_ic3.py index 55205ec..e6776c1 100644 --- a/custom_components/icloud3/support/pyicloud_ic3.py +++ b/custom_components/icloud3/support/pyicloud_ic3.py @@ -802,11 +802,8 @@ def authenticate(self, refresh_session=False): Gb.PyiCloudValidateAppleAcct.validate_username_password( self.username, self.password) if username_password_valid: - err_msg += ("Python SRP Library Credentials Error. The Python " - "module that creates the Secure Remote Password hash key " - "has calculated an incorrect value for a valid " - "Username/Password. Try changing the Password to see " - "if the Apple Acct can be logged into. ") + err_msg += (f"Python SRP Library Credentials Error" + f"{more_info('password_srp_error')}") else: err_msg += "Authentication error, Invalid Username or Password, " elif self.response_code == 503 or self.response_code_pwsrp_err == 503: @@ -1815,7 +1812,7 @@ def update_device_location_data(self, requested_by_devicename=None, devices_data or device_data[LOCATION] == {} or device_data[LOCATION] is None): if device_id not in Gb.devices_without_location_data: - Gb.devices_without_location_data.append(device_id) + list_add(Gb.devices_without_location_data, device_data_name) rawdata_hdr_msg = 'NO LOCATION' if device_data[ICLOUD_DEVICE_STATUS] == 203: rawdata_hdr_msg += ', OFFLINE' diff --git a/custom_components/icloud3/support/pyicloud_ic3_interface.py b/custom_components/icloud3/support/pyicloud_ic3_interface.py index e070f1f..b08f758 100644 --- a/custom_components/icloud3/support/pyicloud_ic3_interface.py +++ b/custom_components/icloud3/support/pyicloud_ic3_interface.py @@ -118,7 +118,7 @@ def verify_all_apple_accounts(): password = Gb.PyiCloud_password_by_username[username] if is_empty(username) or is_empty(password): - Gb.username_valid_by_username[f"AppleAcctNoUserPW-#{cnt}"] = False + # 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 diff --git a/custom_components/icloud3/support/start_ic3.py b/custom_components/icloud3/support/start_ic3.py index 33aa04d..139f7aa 100644 --- a/custom_components/icloud3/support/start_ic3.py +++ b/custom_components/icloud3/support/start_ic3.py @@ -1135,10 +1135,9 @@ 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)=}") + # _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() for conf_device in Gb.conf_devices: devicename = conf_device[CONF_IC3_DEVICENAME] @@ -1639,6 +1638,9 @@ def _post_evlog_apple_acct_tracked_devices_info(PyiCloud): exception_msg = ', DUPLICATE DEVICE' else: msg_symb = CRLF_X + if pyicloud_icloud_dname in Gb.devices_without_location_data: + msg_symb = f"{CRLF} {YELLOW_ALERT} " + exception_msg = ', NOT LOCATED' device_msg = ( f"{msg_symb}" f"{pyicloud_icloud_dname}{RARROW}") @@ -1683,7 +1685,8 @@ def _post_evlog_apple_acct_tracked_devices_info(PyiCloud): # log_rawdata(log_title, {'filter': _RawData.device_data}) devices_assigned_cnt += 1 - msg_symb = f"{CRLF}{NBSP2}{YELLOW_ALERT}" if pyicloud_icloud_dname.endswith('.') else CRLF_CHK + msg_symb = f"{CRLF}{NBSP2}{YELLOW_ALERT}" \ + if pyicloud_icloud_dname.endswith('.') else CRLF_CHK device_msg=(f"{msg_symb}" f"{pyicloud_icloud_dname}{RARROW}" f"{Device.fname}/{devicename} ") diff --git a/custom_components/icloud3/support/start_ic3_control.py b/custom_components/icloud3/support/start_ic3_control.py index af21644..fe14d9c 100644 --- a/custom_components/icloud3/support/start_ic3_control.py +++ b/custom_components/icloud3/support/start_ic3_control.py @@ -1,7 +1,7 @@ from ..global_variables import GlobalVariables as Gb from ..const import (VERSION, VERSION_BETA, ICLOUD3, ICLOUD3_VERSION, DOMAIN, ICLOUD3_VERSION_MSG, NOT_SET, IC3LOG_FILENAME, - CRLF, CRLF_DOT, CRLF_HDOT, CRLF_X, NL, NL_DOT, LINK, + CRLF, CRLF_DOT, CRLF_HDOT, CRLF_X, NL, NL_DOT, LINK, YELLOW_ALERT, EVLOG_ALERT, EVLOG_ERROR, EVLOG_IC3_STARTING, EVLOG_IC3_STAGE_HDR, SETTINGS_INTEGRATIONS_MSG, INTEGRATIONS_IC3_CONFIG_MSG, CONF_VERSION, ICLOUD, ZONE_DISTANCE, @@ -365,8 +365,8 @@ def _log_into_apple_accounts(retry=False): if is_empty(Gb.devices_without_location_data): 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)}") + # else: + # post_event(f"{YELLOW_ALERT}Apple Acct > Devices not Located, {list_to_str(Gb.devices_without_location_data)}") return True