Skip to content

Commit

Permalink
iCloud3 v3.0.rc10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gcobb321 committed Feb 18, 2024
1 parent c5fa319 commit 544470e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 30 deletions.
12 changes: 6 additions & 6 deletions custom_components/icloud3/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

1. FIXED INTERVAL -
1. Normally, when a device is getting close to Home, the location interval changes to 15-secs to be able to update the Home distance very quickly. This lets automations fire when approaching Home in addition to when entering the Home zone. When a Fixed Interval was being used, that value was overriding the short interval time iCloud3 calculated based on distance from Home so iCloud/FamShr locates were never being done. Additionally, a locate request would not be done if the Old Location Threshold was greater or the same as the Fixed Interval value and old locations were being accepted.
1. Normally, when a device is getting close to Home, the location interval changes to 15-secs to be able to update the Home distance very quickly. This lets automations fire when approaching Home in addition to when entering the Home zone. When a Fixed Interval was being used, the Fixed Interval was overriding the short interval time iCloud3 calculated based on distance from Home so iCloud/FamShr locates were never being done. Additionally, a locate request would not be done if the Old Location Threshold was greater or the same as the Fixed Interval value and old locations were being accepted.

Now, iCloud3 will calculate the interval using the distance from Home and only use the Fixed Interval when it is greater.
Now, iCloud3 will calculate the interval using the distance from Home as it normally does. If that value is less than 5-minutes, it will be used. Otherwise, the Fixed Interval will be used if it is set.
2. Fixed a problem where the results from one device with a Fixed Interval was being used for another nearby device that was not using a Fixed Interval.
3. The minumum interval was changed to 5-minutes in rc10.3. This has been changed back to 1-minute or 0 if it is not used.
2. TRAVEL TIME INTERVAL AND NEXT LOCATION UPDATE MULTIPLIER - (Configure Settings > Tracking Parameters screen) - This value (.1 to .8) is used to determine the Interval and when the Next Location Update should be made using the travel time to Home. For example, if the travel time is 8-mins and the multiplier is .5, the next update will be done in 4-mins. This has been changed from entering a decimal value (.1 to .8) to a drop down list that goes from Shortest Inteval Time, to Shorter Inteval Time, to Average, Longer and Longest. It defaults to Average (.5*TravelTime) and you will probably never change it.
3. HOME_DISTANCE & ZONE_DISTANCE SENSOR - Changed the way the zone and devices distances are displayed to provide better accuracy and make it easier to display them on a dashboard screen entity card. The iCloud3 docomentation > Sensor Attribute chapter was updated to provide screenshots and example code that will help explain how to do this.
4. OTHER STUFF - Fixed a few other bugs. Cleaned up so code.
3. The minimum Fixed Interval is still 5-minutes.
2. TRAVEL TIME INTERVAL AND NEXT LOCATION UPDATE MULTIPLIER - (Configure Settings > Tracking Parameters screen) - This value (.1 to .8) is used to determine the Interval and when the Next Location Update should be made using the travel time to Home. For example, if the travel time is 8-mins and the multiplier is .5, the next update will be done in 4-mins. This has been changed from entering a decimal value (.1 to .8) to a drop down list that goes from Shortest Interval Time, to Shorter Interval Time, to Average, Longer and Longest. It defaults to Average (.5*TravelTime) and you will probably never change it.
3. HOME_DISTANCE & ZONE_DISTANCE SENSOR - Changed the way the zone and devices distances are displayed to provide better accuracy and make it easier to display them on a dashboard screen entity card. The iCloud3 documentation > Sensor Attribute chapter was updated to provide screenshots and example code that will help explain how to do this.
4. OTHER STUFF - Fixed a few other bugs. Cleaned up some code.


rc10.3
Expand Down
10 changes: 6 additions & 4 deletions custom_components/icloud3/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import time
# import asyncio
from collections import OrderedDict

from homeassistant import config_entries, data_entry_flow
from homeassistant.config_entries import ConfigEntry as config_entry
Expand Down Expand Up @@ -67,7 +65,7 @@
)
from .const_sensor import (SENSOR_GROUPS )
from .helpers.common import (instr, isnumber, obscure_field, list_to_str, str_to_list,
is_statzone, zone_dname, )
is_statzone, zone_dname, isbetween, )
from .helpers.messaging import (log_exception, log_debug_msg, _traceha, _trace,
post_event, post_monitor_msg,
open_ic3_log_file, close_reopen_ic3_log_file, )
Expand Down Expand Up @@ -3002,7 +3000,7 @@ def _validate_update_device(self, user_input):
self.errors['base'] = 'required_field_device'
self.errors[CONF_FAMSHR_DEVICENAME] = 'no_device_selected'
self.errors[CONF_FMF_EMAIL] = 'no_device_selected'
self.errors[CONF_MOBILE_APP_DEVICE] = 'no_device_selected'
self.errors[CONF_MOBILE_APP_DEVICE] = 'no_device_selected'

if (user_input[CONF_FAMSHR_DEVICENAME] in self.devicename_by_famshr_fmf
and self.devicename_by_famshr_fmf[user_input[CONF_FAMSHR_DEVICENAME]] not in ui_old_devicename):
Expand Down Expand Up @@ -3047,6 +3045,10 @@ def _validate_update_device(self, user_input):
track_from_zones.append(self.conf_device_selected[CONF_TRACK_FROM_BASE_ZONE])
user_input[CONF_TRACK_FROM_ZONES] = track_from_zones

if isbetween(user_input[CONF_FIXED_INTERVAL], 0, 5):
user_input[CONF_FIXED_INTERVAL] = 5
self.errors[CONF_FIXED_INTERVAL] = 'fixed_interval_invalid_range'

return user_input

#-------------------------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions custom_components/icloud3/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"unknown_mobapp_picture": "Check the Mobile App and Picture parameter values (Not found or Invalid)",

"tfz_selection_invalid": "The value must be a zone that is being tracked from",
"time_factor_invalid_range": "The 'travel_time_factor' must be between .1 and .9",
"time_factor_invalid_range": "The 'Travel Time Multiplier' must be between .1 and .9",
"fixed_interval_invalid_range": "The 'Fixed Interval' must be 0 (not used) or > 5",
"display_text_as_no_gtsign": "The '>' between the ActualText and DisplayAsText is missing",
"display_text_as_no_actual": "The 'ActualText' is not specified",
"display_text_as_no_display_as": "The 'DisplayAsText' is not specified",
Expand Down Expand Up @@ -247,7 +248,7 @@
},
"data_description": {
"inzone_interval": "Time between location requests when in a zone",
"fixed_interval": "A fixed time between location requests when not in a zone. If set (>0), this value is used instead of the calculating the interval using the distance from home.",
"fixed_interval": "A fixed time between location requests when not in a zone. iCloud3 calculates the interval for the next locate request and uses the calculated value if this is not set (= 0). This value will NOT be used when the calculated interval is less tnan 5-min, the current location data is old, the device is off-line or when the device is not in a zone.",
"track_from_base_zone": "Normally, the Home zone is used as the primary Track-from-Zone for all tracking (travel time, distance, etc). However, a different zone can be used as the primary Track-from-Zone if you are away from Home for an extended period or the device is normally at another location (vacation house, second home, parent's house, etc.). This can be set Globally for all devices on the Special Zones screen."
}
},
Expand Down Expand Up @@ -346,7 +347,7 @@
"mobapp_alive_interval": "REQUEST MOBILE APP LOCATION INTERVAL",
"tfz_tracking_max_distance": "TRACK-FROM-ZONE DISPLAY DISTANCE",
"offline_interval": "DEVICE OFFLINE INTERVAL",
"travel_time_factor": "TRAVEL TIME INTERVAL MULTIPLIER",
"travel_time_factor": "TRAVEL TIME INTERVAL AND NEXT LOCATION UPDATE MULTIPLIER",
"discard_poor_gps_inzone": "DISCARD POOR RESULTS - Discard Location Updates with Poor GPS Accuracy when in a Zone",
"center_in_zone": "MOVE DEVICE TO ZONE CENTER - Change Device's Location to the Zone's Center when in a Zone",
"event_log_card_directory": "EVENT LOG CARD LOVELACE RESOURCES DIRECTORY - Event Log custom card .js file directory",
Expand All @@ -363,7 +364,7 @@
"exit_zone_interval": "The time to the first location request after exiting a zone",
"mobapp_alive_interval": "Send a location request to the Mobile App if there has been no contact after this amount of time. This will check to see if the Mobile App is responding to location requests or is asleep and not running.",
"offline_interval": "Location request interval when offline (Airplane mode, dead cell area, etc.)",
"travel_time_factor": "Next location time = Waze travel time to zone * this value",
"travel_time_factor": "This is used to calculate the Interval and Next Location Time when going towards Home. A smaller value will reduce the interval time and increase the location requests, a larger value will increase the interval and reduce the location requests.",
"event_log_btnconfig_url": "Normally, this is blank and iCloud3 will determine the URL for it's Configure Settings screen. However, if there is a problem caused by running HA in a virtual environment, docker or on another device and the actual URL can not be detemined, a 404 not found error may be encountered. If that happens, select it the normal way (HA Devices & Services > Integration > iCloud3 > Configure Settings gear) and copy the URL from the browser into this field."
}
},
Expand Down
9 changes: 6 additions & 3 deletions custom_components/icloud3/support/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from ..support import start_ic3
from ..support import waze
from ..helpers.common import (instr, ordereddict_to_dict, )
from ..helpers.common import (instr, ordereddict_to_dict, isbetween, )
from ..helpers.messaging import (log_exception, _trace, _traceha, log_info_msg,
close_reopen_ic3_log_file, )
from ..helpers.time_util import (datetime_now, )
Expand Down Expand Up @@ -381,10 +381,10 @@ def config_file_check_range_values():
range_errors = {}
update_configuration_flag = False

range_errors.update({pname: DEFAULT_GENERAL_CONF.get(pname, range[MIN])
range_errors.update({pname: DEFAULT_GENERAL_CONF.get(pname, range[MIN])
for pname, range in RANGE_GENERAL_CONF.items()
if Gb.conf_general[pname] < range[MIN]})
range_errors.update({pname: DEFAULT_GENERAL_CONF.get(pname, range[MAX])
range_errors.update({pname: DEFAULT_GENERAL_CONF.get(pname, range[MAX])
for pname, range in RANGE_GENERAL_CONF.items()
if Gb.conf_general[pname] > range[MAX]})
update_configuration_flag = (range_errors != {})
Expand Down Expand Up @@ -436,6 +436,9 @@ def config_file_check_devices():
if conf_device[CONF_TRACK_FROM_ZONES] == []:
conf_device[CONF_TRACK_FROM_ZONES] = [HOME]
update_configuration_flag = True
if isbetween(conf_device[CONF_FIXED_INTERVAL], 0, 5):
conf_device[CONF_FIXED_INTERVAL] = 5.0
update_configuration_flag = True

if update_configuration_flag:
write_storage_icloud3_configuration_file()
Expand Down
26 changes: 15 additions & 11 deletions custom_components/icloud3/support/determine_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,6 @@ def determine_interval(Device, FromZone):
interval_method += '+6.>180s'
interval_secs = 180

# Use fixed_interval_secs if > 0 and > new interval
if (Device.fixed_interval_secs > 0
and interval_secs > Device.fixed_interval_secs
and Device.isnotin_zone_or_statzone
and Device.is_location_good
and Device.is_passthru_timer_set is False):
interval_secs = Device.fixed_interval_secs

#Turn off waze close to zone flag to use waze after leaving zone or getting more than 1km from it
if Gb.Waze.waze_close_to_zone_pause_flag:
if isin_zone or calc_dist_from_zone_km >= 1:
Expand Down Expand Up @@ -372,16 +364,28 @@ def determine_interval(Device, FromZone):
interval_method = "9.StatZone"
interval_secs = Device.statzone_inzone_interval_secs

# Use fixed_interval_secs if > 5m, not in a zone etc.
elif (Device.fixed_interval_secs >= 300
and interval_secs > 300
and Device.isnotin_zone_or_statzone
and Device.is_location_good
and Device.is_offline is False
and Device.is_passthru_timer_set is False):
interval_secs = Device.fixed_interval_secs
interval_method = "9.Fixed"

#check for max interval_secs, override in zone times
elif interval_secs > Gb.max_interval_secs:
if Device.isin_statzone:
interval_method = f"9.inZoneMax"
interval_method = "9.inZoneMax"
interval_secs = Device.statzone_inzone_interval_secs
elif isin_zone:
pass

else:
interval_method = f"9.Max"
elif (Device.is_location_good
and Device.is_offline is False
and Device.is_passthru_timer_set is False):
interval_method = "9.Max"
interval_secs = Gb.max_interval_secs

interval_str = secs_to_time_str(interval_secs)
Expand Down
5 changes: 3 additions & 2 deletions custom_components/icloud3/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"unknown_mobapp_picture": "Check the Mobile App and Picture parameter values (Not found or Invalid)",

"tfz_selection_invalid": "The value must be a zone that is being tracked from",
"time_factor_invalid_range": "The 'travel_time_factor' must be between .1 and .9",
"time_factor_invalid_range": "The 'Travel Time Multiplier' must be between .1 and .9",
"fixed_interval_invalid_range": "The 'Fixed Interval' must be 0 (not used) or > 5",
"display_text_as_no_gtsign": "The '>' between the ActualText and DisplayAsText is missing",
"display_text_as_no_actual": "The 'ActualText' is not specified",
"display_text_as_no_display_as": "The 'DisplayAsText' is not specified",
Expand Down Expand Up @@ -247,7 +248,7 @@
},
"data_description": {
"inzone_interval": "Time between location requests when in a zone",
"fixed_interval": "A fixed time between location requests when not in a zone. If set (>0), this value is used instead of the calculating the interval using the distance from home.",
"fixed_interval": "A fixed time between location requests when not in a zone. iCloud3 calculates the interval for the next locate request and uses the calculated value if this is not set (= 0). This value will NOT be used when the calculated interval is less tnan 5-min, the current location data is old, the device is off-line or when the device is not in a zone.",
"track_from_base_zone": "Normally, the Home zone is used as the primary Track-from-Zone for all tracking (travel time, distance, etc). However, a different zone can be used as the primary Track-from-Zone if you are away from Home for an extended period or the device is normally at another location (vacation house, second home, parent's house, etc.). This can be set Globally for all devices on the Special Zones screen."
}
},
Expand Down

0 comments on commit 544470e

Please sign in to comment.