Skip to content

Commit

Permalink
iCloud3 v3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gcobb321 committed May 7, 2024
1 parent 1a63caf commit 60f6ca2
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 164 deletions.
21 changes: 17 additions & 4 deletions custom_components/icloud3/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@
- iCloud3 Documentation is [here](https://gcobb321.github.io/icloud3_v3_docs/#/chapters/0.1-introduction)
- The *Installing iCloud3* chapter describes migrating from iCloud3 v2 and installing iCloud3 for the first time

### Change Log - v3.0.3 (4/14/2024)
1. ALERTS (New) - An alert message is displayed on the Event Log and in the _alert_ attribute on the device's device_tracker and badge entities until it has been resolved. Exaqmples of alerts are a startup error, no gps data, the device is offline, the battery below 20%, and tracking is paused. The alert attribute can be used in an automation to trigger sending a message to the device. See the Event Log chapter in the iCloud3 docs for more information and example automations.


v3.0.4
.......................
### Change Log - v3.0.4 (not released)
1. ADD DEVICE (Fixed) - An 'Out of Range' error message was encountered adding the first device.
2. DIRECTION OF TRAVEL (Improvement) - Tweaked the AwayFrom direction override when approaching Home after the previous directions were Towards.
3. Event Type DEPRECIATED EOORO MESSAGE (Fixed) - This was a warning about the removal of the EventType from HA next year. It has been removed.
4. RAWDATA LOGGING - Changed some formatting of the log to better filter device messages.


v3.0.3
.......................
### Change Log - v3.0.3 (5/1/2024)
1. ALERTS (New) - An alert message is displayed on the Event Log and in the _alert_ attribute on the device's device_tracker and badge entities until it has been resolved. Examples of alerts are a startup error, no gps data, the device is offline, the battery below 20%, and tracking is paused. The alert attribute can be used in an automation to trigger sending a message to any device using the Mobile App. See the _Reference > Devices and Other Alerts_ chapter in the iCloud3 docs [here](#/chapters/7.6-alerts) for more information and example automations.
2. BATTERY (Improvement) - The battery information attribute has been added to the device's device_tracker and badge entity. It shows the battery level, charging state, when the information was updated and the source of the data. The charging status text has been changed to 'Charged', 'Charging', 'NotCharging', 'Low' and 'Unknown'.
3. UPDATE SENSOR (Fixed) - An 'AttributeError' message has been fixed. It was caused by trying to update the sensor before the sensor had been set up.
4. CONFIGURE SETTINGS > ICLOUD ACCOUNT AND MOBILE APP screen (Fixed) - Changing iCloud account information (Username or password), logging into and saving the new account information was not being saved correctly so restarting iCloud3 would still use the old account information. Also added a LogOut option to log out of the iCloud Account.
5. DIRECTION OF TRAVEL (Improvement) - When Driving towards Home, the calculated straight line distance is used to determine the travel direction ('Towards'). The direction would momentairily change to 'AwayFrom' if the distance from Home increased due to a curve in the road or you were stopped at an intersection. It would then back to 'Towards' on the next update. In this case, the direction will now remain 'Towards'.
4. CONFIGURE SETTINGS > ICLOUD ACCOUNT AND MOBILE APP screen (Fixed) - Changing iCloud account information (Username or password) was not being saved correctly so restarting iCloud3 would still use the old account. A Log Off option was added to initialize the iCloud Account username/password fields.
5. DIRECTION OF TRAVEL (Improvement) - When Driving towards Home, the calculated straight line distance is used to determine the travel direction ('Towards'). The direction would momentarily change to 'AwayFrom' if the distance from Home increased due to a curve in the road or you were stopped at an intersection. It would then change back to 'Towards' on the next update. In this case, the direction will not be changed and will remain 'Towards'.
6. Other minor code changes, tuning and code cleanup.


Expand Down
14 changes: 10 additions & 4 deletions custom_components/icloud3/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2989,11 +2989,17 @@ def _is_only_non_tracked_field_updated(self, user_input):
Restart iCloud3 if a tracked field was updated
'''

for pname, pvalue in user_input.items():
if (Gb.conf_devices[self.conf_device_selected_idx][pname] != pvalue
and pname not in DEVICE_NON_TRACKING_FIELDS):
try:
if Gb.conf_devices == []:
return False

for pname, pvalue in user_input.items():
if (Gb.conf_devices[self.conf_device_selected_idx][pname] != pvalue
and pname not in DEVICE_NON_TRACKING_FIELDS):
return False
except:
return False

return True

#-------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3705,7 +3711,7 @@ def remove_track_fm_zone_sensor_entity(self, devicename, remove_tfz_zones_list):
if remove_tfz_zones_list == []:
return

device_tfz_sensors = Gb.Sensors_by_devicename_from_zone.get(devicename)
device_tfz_sensors = Gb.Sensors_by_devicename_from_zone.get(devicename).copy()

if device_tfz_sensors is None:
return
Expand Down
4 changes: 2 additions & 2 deletions custom_components/icloud3/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

VERSION = '3.0.3'
VERSION = '3.0.4'
#-----------------------------------------
DOMAIN = 'icloud3'
ICLOUD3 = 'iCloud3'
Expand Down Expand Up @@ -252,7 +252,7 @@
dark_circled_letters = "🅐 🅑 🅒 🅓 🅔 🅕 🅖 🅗 🅘 🅙 🅚 🅛 🅜 🅝 🅞 🅟 🅠 🅡 🅢 🅣 🅤 🅥 🅦 🅧 🅨 🅩 ✪"
Symbols = ±▪•●▬⮾ ⊗ ⊘✓×ø¦ ▶◀ ►◄▲▼ ∙▪ »« oPhone=►▶→⟾➤➟➜➔➤🡆🡪🡺⟹🡆➔ᐅ◈🝱☒☢⛒⊘Ɵ⊗ⓧⓍ⛒🜔
Important = ❗❌⚠️❓🛑⛔⚡⭐⭕ⓘ• ⍰ ‶″“”‘’‶″ 🕓
— –ᗒ ⁃ » ━▶ ━➤🡺 —> > > ❯↦ … 🡪ᗕ ᗒ ᐳ ─🡢 ──ᗒ 🡢 ─ᐅ ↣ ➙ →《》◆◈◉●
— –ᗒ ⁃ » ━▶ ━➤🡺 —> > > ❯↦ … 🡪ᗕ ᗒ ᐳ ─🡢 ──ᗒ 🡢 ─ᐅ ↣ ➙ →《》◆◈◉●
▐‖ ▹▻▷◁◅◃‖╠ᐅ🡆▶▐🡆▐▶‖➤▐➤➜➔❰❰❱❱ ⠤ ²
⣇⠈⠉⠋⠛⠟⠿⡿⣿ https://www.fileformat.info/info/unicode/block/braille_patterns/utf8test.htm
'''
Expand Down
43 changes: 23 additions & 20 deletions custom_components/icloud3/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ def is_approaching_tracked_zone(self):
if (secs_to(self.next_update_secs) <= 15
and secs_since(self.loc_data_secs > 15)
and self.FromZone_TrackFrom.is_going_towards
and self.FromZone_TrackFrom.zone_dist < 1
and self.went_3km):
return True
# and self.FromZone_TrackFrom.zone_dist < 1
return False

@property
Expand Down Expand Up @@ -1438,16 +1438,20 @@ def set_passthru_zone_delay(self, data_source, zone_entered=None, zone_entered_s
False - Zone was reset and should proceed with an update
'''
# Passthru zone is not used or already set up
passthru_not_used_reason = ''
if (zone_entered == self.passthru_zone
or zone_entered == self.loc_data_zone):
return True

# Entering a zone not subject to a delay
if (zone_entered in self.FromZones_by_zone
or is_statzone(zone_entered)
or zone_entered is None
or (data_source == ICLOUD and self.is_location_old_or_gps_poor)):
return False
if zone_entered in self.FromZones_by_zone:
passthru_not_used_reason = 'TrackedFrom Zone'
elif is_statzone(zone_entered):
passthru_not_used_reason = 'Stat Zone'
elif zone_entered is None:
passthru_not_used_reason = 'Unknown Zone'
elif (data_source == ICLOUD and self.is_location_old_or_gps_poor):
passthru_not_used_reason = 'Old Location'

# Not set and next update not reached, set it below
elif (self.is_passthru_timer_set is False
Expand All @@ -1457,14 +1461,17 @@ def set_passthru_zone_delay(self, data_source, zone_entered=None, zone_entered_s
# Time for an update, reset it
elif self.is_next_update_time_reached:
self.reset_passthru_zone_delay()

return False
passthru_not_used_reason = 'Next Update Time Reached'

# Passthru expire is set, if before enter zone time or this update time, reset it
elif (self.is_passthru_timer_set
and (zone_entered_secs > self.passthru_zone_timer
or Gb.this_update_secs >= self.passthru_zone_timer)):
self.reset_passthru_zone_delay()
passthru_not_used_reason = 'Timer Expired'

if passthru_not_used_reason:
post_event(self.devicename, f"Zone Enter Not Delayed > {passthru_not_used_reason}")
return False

# Activate Passthru zone
Expand Down Expand Up @@ -1902,9 +1909,9 @@ def update_battery_data_from_mobapp(self):
return False

battery_level = int(battery_level_attrs[STATE])
if (mins_since(battery_update_secs) > 45
or battery_level_attrs[LAST_UPDATED_SECS] != battery_level_attrs[LAST_CHANGED_SECS]):
log_rawdata(f"Mobile App Battery Level - {self.devicename}", battery_level_attrs)
if (Gb.this_update_time.endswith('00:00')
or battery_update_secs != self.mobapp_data_battery_update_secs):
log_rawdata(f"MobApp Battery Level - <{self.devicename}>", battery_level_attrs)

if battery_level > 99:
battery_status = 'Charged'
Expand Down Expand Up @@ -2096,11 +2103,12 @@ def update_dev_loc_data_from_raw_data_FAMSHR_FMF(self, RawData, requesting_devic
#-------------------------------------------------------------------
def display_update_location_msg(self):

return
if self.loc_data_time_gps == self.last_loc_data_time_gps:
return

if self.isnotin_zone or self.loc_data_dist_moved_km > .015:
event_msg =(f"SinceLast > "
event_msg =(f"Selected > "
f"{self.last_loc_data_time_gps}"
f"{RARROW}{self.dev_data_source}-{self.loc_data_time_gps}")
post_event(self.devicename,event_msg)
Expand Down Expand Up @@ -2154,6 +2162,7 @@ def update_sensor_values_from_data_fields(self):
self.sensors[MOVED_TIME_TO] = self.loc_data_time_moved_to
self.sensors[ZONE_DATETIME] = secs_to_datetime(self.zone_change_secs)

if self.FromZone_NextToUpdate is None: self.FromZone_NextToUpdate = self.FromZone_Home
self.interval_secs = self.FromZone_NextToUpdate.interval_secs
self.interval_str = self.FromZone_NextToUpdate.interval_str
self.next_update_secs = self.FromZone_NextToUpdate.next_update_secs
Expand All @@ -2162,6 +2171,7 @@ def update_sensor_values_from_data_fields(self):
self.sensors[NEXT_UPDATE_TIME] = self.FromZone_NextToUpdate.sensors[NEXT_UPDATE_TIME]
self.sensors[NEXT_UPDATE] = self.FromZone_NextToUpdate.sensors[NEXT_UPDATE]

if self.FromZone_TrackFrom is None: self.FromZone_TrackFrom = self.FromZone_Home
self.sensors[FROM_ZONE] = self.FromZone_TrackFrom.from_zone
self.sensors[LAST_UPDATE_DATETIME] = self.FromZone_TrackFrom.sensors[LAST_UPDATE_DATETIME]
self.sensors[LAST_UPDATE_TIME] = self.FromZone_TrackFrom.sensors[LAST_UPDATE_TIME]
Expand All @@ -2178,14 +2188,11 @@ def update_sensor_values_from_data_fields(self):
self.sensors[WAZE_DISTANCE] = self.FromZone_TrackFrom.sensors[WAZE_DISTANCE]
self.sensors[WAZE_METHOD] = self.FromZone_TrackFrom.sensors[WAZE_METHOD]
self.sensors[CALC_DISTANCE] = self.FromZone_TrackFrom.sensors[CALC_DISTANCE]

self.sensors[HOME_DISTANCE] = self.FromZone_Home.sensors[ZONE_DISTANCE]
self.FromZone_TrackFrom.dir_of_travel = dir_of_travel = \
self.FromZone_TrackFrom.sensors[DIR_OF_TRAVEL]

# if dir_of_travel == INZONE:
# self.sensors[DIR_OF_TRAVEL] = f"@{zone_dname(self.loc_data_zone)[:8]}"
# else:
# self.sensors[DIR_OF_TRAVEL] = dir_of_travel
self.sensors[DIR_OF_TRAVEL] = dir_of_travel

# Update the last zone info if the device was in a zone and now not in a zone or went immediatelly from
Expand Down Expand Up @@ -2418,10 +2425,6 @@ def display_info_msg(self, info_msg=None, new_base_msg=False):
# PassThru zone msg has priority over all other messages
if self.is_passthru_zone_delay_active and instr(info_msg, 'PassThru') is False:
return
# if new_base_msg is False:
# return

#info_msg = info_msg if new_base_msg else f"《{info_msg}》{self.info_msg}"

try:
self.write_ha_sensor_state(INFO, info_msg)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/icloud3/helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def list_to_str(list_value, separator=None):
'''
if list_value == []: return ''
separator_str = separator if separator else ', '
if None in list_value:
list_value = [lv for lv in list_value if lv is not None]
if None in list_value or '' in list_value:
list_value = [lv for lv in list_value if lv is not None and lv != '']
list_str = separator_str.join(list_value) if list_value else 'None'

if separator_str.startswith(CRLF):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/icloud3/helpers/entity_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def trace_device_attributes(Device, description, fct_name, attrs):
log_msg = (f"{description} Attrs-{trace_attrs}{trace_attrs_in_attrs}")
log_debug_msg(Device.devicename, log_msg)

log_rawdata(f"iCloud Rawdata - {Device.devicename}--{description}", attrs)
log_rawdata(f"FamShr iCloud Rawdata - <{Device.devicename}> {description}", attrs)

except Exception as err:
pass
Expand Down
Loading

0 comments on commit 60f6ca2

Please sign in to comment.