Skip to content

Commit

Permalink
iCloud3 v3.0.rc7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gcobb321 committed Oct 18, 2023
1 parent 7937788 commit 7e8b2a4
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 171 deletions.
9 changes: 8 additions & 1 deletion custom_components/icloud3/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
rc7 - Release Candidate 6 (10/7/2023)
rc7.1 - Release Candidate 7.1 (10/15/2023)
...............................
1. Zone-Device Count bug fix - Fixed a bug where the device counts were not being displayed correctly.
2. Exit Zone for Devices without the iOSApp (Watch) - When a Device exits a zone, all other devices that were in the same zone that do not have the iOS App installed will be updated immediately. They were being updated when their next update timer was reached. Hopefully, this will make Watch zone exit updates to be done when they happen.
3. Apple account password - When iCloud3 starts, the password is checked to see if it is encoded in the configuration parameter file. If it is not and it should be, it will be encoded and the configuration file will be updated. Previously, there were times when the file was not being updated.
4. iCloud Account username/password changes - When the username/password is changed, the Apple account is logged into. If you select 'Save' the configuration file is updated. If you select 'Return', the updated username/password is not saved and the menu is displayed. This can lead to login problems the next time iCloud3 starts if you really wanted to save them but didn't. An additional Confirmation Screen is now displayed that lets you save them or not save them.

rc7 - Release Candidate 7 (10/15/2023)
...............................
1. yaml Zones - Fixed a problem where zones configured using yaml were not being loaded when iCloud3 started.
2. Zone-Devices Count - New feature - The number of the devices within a zone is displayed with the tracking results on the Event Log. The counts are the numbers (x) after the zone name. For Example:
Expand Down
100 changes: 83 additions & 17 deletions custom_components/icloud3/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def dict_value_to_list(key_value_dict):
'exit': 'EXIT ᐳ Exit the iCloud3 Configurator',
'return': 'RETURN ᐳ Return to the Main Menu',

'confirm_return': 'RETURN WITHOUT SAVING CONFIGURATION CHANGES ᐳ Return to the Main Menu without saving any changes',
'confirm_save': 'SAVE THE CONFIGURATION CHANGES ᐳ Save any changes, then return to the Main Menu',

"divider1": "═══════════════════════════════════════",
"divider2": "═══════════════════════════════════════",
"divider3": "═══════════════════════════════════════"
Expand Down Expand Up @@ -1168,6 +1171,49 @@ async def async_step_change_device_order(self, user_input=None, errors=None, cal
data_schema=self.form_schema(self.step_id),
errors=self.errors)

#-------------------------------------------------------------------------------------------
async def async_step_confirm_action(self, user_input=None, action_items=None,
called_from_step_id=None):
'''
Confirm an action - This will display a screen containing the action_items.
Parameters:
action_items - The action_item keys in the ACTION_LIST_ITEMS_KEY_TEXT dictionary.
The last key is the default item on the confirm actions screen.
called_from_step_id - The name of the step to return to.
Notes:
Before calling this function, set the self.user_input_multi_form to the user_input.
This will preserve all parameter changes in the calling screen. They are
returned to the called from step on exit.
Action item - The action_item selected on this screen is added to the
self.user_input_multi_form variable returned. It is resolved in the calling
step in the self._action_text_to_item function in the calling step.
On Return - Set the function to return to for the called_from_step_id.
'''
self.step_id = 'confirm_action'
self.errors = {}
self.errors_user_input = {}
self.called_from_step_id_1 = called_from_step_id or self.called_from_step_id_1 or 'menu'

if action_items is not None:
actions_list = []
for action_item in action_items:
actions_list.append(ACTION_LIST_ITEMS_KEY_TEXT[action_item])

return self.async_show_form(step_id=self.step_id,
data_schema=self.form_schema(self.step_id,
actions_list=actions_list),
errors=self.errors)

user_input, action_item = self._action_text_to_item(user_input)
self.user_input_multi_form['action_item'] = action_item

if self.called_from_step_id_1 == 'icloud_account':
return await self.async_step_icloud_account(user_input=self.user_input_multi_form)

return await self.async_step_menu()

#-------------------------------------------------------------------------------------------
def _set_example_zone_name(self):
'''
Expand Down Expand Up @@ -1921,7 +1967,22 @@ async def async_step_icloud_account(self, user_input=None, errors=None, called_f
if CONF_PASSWORD in log_user_input: log_user_input[CONF_PASSWORD] = obscure_field(log_user_input[CONF_PASSWORD])
log_debug_msg(f"{self.step_id} ({action_item}) > UserInput-{log_user_input}, Errors-{errors}")

if action_item == 'cancel':
if action_item == 'confirm_save':
# user_input = self.user_input_multi_form
action_item = 'save'

elif action_item == 'confirm_return':
return await self.async_step_menu()

elif action_item == 'cancel':
if (Gb.username != user_input[CONF_USERNAME]
or Gb.password != user_input[CONF_PASSWORD]
or Gb.icloud_server_endpoint_suffix != user_input['url_suffix_china']):
self.user_input_multi_form = user_input.copy()

return await self.async_step_confirm_action(user_input,
action_items = ['confirm_return','confirm_save'],
called_from_step_id='icloud_account')
return await self.async_step_menu()

# Data Source is iOS App only, iCloud was not selected
Expand Down Expand Up @@ -2069,7 +2130,7 @@ async def async_step_reauth(self, user_input=None, errors=None, called_from_step
post_event(f"{EVLOG_NOTICE}iCLOUD ALERT > Apple ID Verification complete")

Gb.EvLog.clear_alert()
Gb.force_icloud_update_flag = True
Gb.icloud_force_update_flag = True
PyiCloud.new_2fa_code_already_requested_flag = False

self.errors['base'] = self.header_msg = 'verification_code_accepted'
Expand Down Expand Up @@ -3467,7 +3528,11 @@ def _action_text_to_item(self, user_input):
return None, None

action_text = None
if 'action_items' in user_input:
if 'action_item' in user_input:
action_item = user_input['action_item']
user_input.pop('action_item')

elif 'action_items' in user_input:
action_text = user_input['action_items']
if action_text.startswith('NEXT PAGE ITEMS > '):
action_item = 'next_page_items'
Expand All @@ -3476,6 +3541,8 @@ def _action_text_to_item(self, user_input):
action_item = [k for k, v in ACTION_LIST_ITEMS_KEY_TEXT.items()
if v.startswith(action_text[:action_text_len])][0]
user_input.pop('action_items')


else:
action_item = None

Expand Down Expand Up @@ -3777,12 +3844,12 @@ def _discard_changes(self, user_input):
#
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

def form_schema(self, step_id):
def form_schema(self, step_id, actions_list=None, actions_list_default=None):
'''
Return the step_id form schema for the data entry forms
'''
schema = {}
self.actions_list = ACTION_LIST_ITEMS_BASE.copy()
self.actions_list = actions_list or ACTION_LIST_ITEMS_BASE.copy()

if step_id == 'menu':
menu_action_items = MENU_ACTION_ITEMS.copy()
Expand Down Expand Up @@ -3814,8 +3881,18 @@ def form_schema(self, step_id):
return schema

#------------------------------------------------------------------------
elif step_id == 'restart_icloud3':
elif step_id.startswith('confirm_action'):
actions_list_default = actions_list_default or self.actions_list[-1]

return vol.Schema({
vol.Required('action_items',
default=actions_list_default):
selector.SelectSelector(selector.SelectSelectorConfig(
options=self.actions_list, mode='list')),
})

#------------------------------------------------------------------------
elif step_id == 'restart_icloud3':
self.actions_list = []
restart_default='restart_ic3_now'

Expand Down Expand Up @@ -4431,17 +4508,6 @@ def form_schema(self, step_id):
default=Gb.conf_general[CONF_STAT_ZONE_INZONE_INTERVAL]):
selector.NumberSelector(selector.NumberSelectorConfig(
min=5, max=60, unit_of_measurement='minutes')),

# vol.Optional('base_offset_header',
# default=sbzh_default):
# cv.multi_select([STAT_ZONE_BASE_HEADER]),
# vol.Required(CONF_STAT_ZONE_BASE_LATITUDE,
# default=Gb.conf_general[CONF_STAT_ZONE_BASE_LATITUDE]):
# selector.NumberSelector(selector.NumberSelectorConfig(min=-90, max=90)),
# vol.Required(CONF_STAT_ZONE_BASE_LONGITUDE,
# default=Gb.conf_general[CONF_STAT_ZONE_BASE_LONGITUDE]):
# selector.NumberSelector(selector.NumberSelectorConfig(min=-180, max=180)),

vol.Optional('track_from_zone_header',
default=tfzh_default):
cv.multi_select([TRK_FROM_HOME_ZONE_HEADER]),
Expand Down
2 changes: 1 addition & 1 deletion custom_components/icloud3/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

VERSION = '3.0.rc7'
VERSION = '3.0.rc7.1'

DOMAIN = 'icloud3'
ICLOUD3 = 'iCloud3'
Expand Down
8 changes: 4 additions & 4 deletions custom_components/icloud3/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def __init__(self, devicename, conf_device):
self.StatZone = None # The StatZone this Device is in or None if not in a StatZone
#self.stationary_zonename = (f"{self.devicename}_{STATIONARY}")

self.FromZones_by_zone = {} # DeviceFmZones objects for the track_from_zones parameter for this Device
self.FromZone_Home = None # DeviceFmZone object for the Home zone
self.from_zone_names = [] # List of the from_zones in the FromZones_by_zone dictionary
self.FromZones_by_zone = {} # DeviceFmZones objects for the track_from_zones parameter for this Device
self.FromZone_Home = None # DeviceFmZone object for the Home zone
self.from_zone_names = [] # List of the from_zones in the FromZones_by_zone dictionary
self.only_track_from_home = True # Track from only Home (True) or also track from other zones (False)
self.FromZone_BeingUpdated = None # DeviceFmZone object being updated in determine_interval for EvLog TfZ info
self.FromZone_NextToUpdate = None # Set to the DeviceFmZone when it's next_update_time is reached
Expand Down Expand Up @@ -247,7 +247,7 @@ def initialize(self):
self.last_iosapp_trigger = ''

# iCloud data update control variables
# self.icloud_update_needed_flag = False
self.icloud_force_update_flag = False # Bypass all update needed checks and force an iCloud update
self.icloud_devdata_useable_flag = False
self.icloud_acct_error_flag = False # An error occured from the iCloud account update request
self.icloud_update_reason = 'Trigger > Initial Locate'
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion custom_components/icloud3/global_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class GlobalVariables(object):
device_trackers_cnt = 0 # Number of device_trackers that will be creted (__init__.py)
device_trackers_created_cnt = 0 # Number of device_trackers that have been set up (incremented in device_tracker.py)
area_id_personal_device = None

# restore_state file
restore_state_file_data = {}
restore_state_profile = {}
Expand Down Expand Up @@ -312,6 +312,7 @@ class GlobalVariables(object):
used_data_source_FAMSHR = False
used_data_source_FMF = False
used_data_source_IOSAPP = False
iosapp_monitor_any_devices_false_flag = False

# Primary data source being used that can be turned off if errors
primary_data_source_ICLOUD = conf_data_source_ICLOUD
Expand Down
Loading

0 comments on commit 7e8b2a4

Please sign in to comment.