Closed scotty1395 closed 1 year ago
Hi Gary. I've emailed you an export of the event log.
Edit: Changed the individual lines with a block of code for clarity and to make the update easier. Also corrected one line of code in the _statzone_cleartimer function
I have found the problem. The distance moved from the last location is being added to a total distance moved each time the interval time expires. When close to home and with a 15-secs interval expire time, the total moves gets greater than the still time very fast. This code changes how this is done to keeping the gps lat/long when the StatZone timer is set and always checking the distance from that point instead on using the distance moved.
Edit the icloud3/device.py file.
Line 177, add the _self.statzonelatitude and _self.statzonelongitude statements below so the code block is:
# StatZone fields
self.statzone_latitude = 0.0
self.statzone_longitude = 0.0
self.statzone_timer = 0
self.statzone_dist_moved_km = 0
self.statzone_setup_secs = 0 # Time the statzone was set up
Lines 1036-1062, Replace a block of code with this. (The line number may be slightly different but replace the functions _statzone_reset_timer, statzone_clear_timer, update_distancemoved
@property
def statzone_reset_timer(self):
''' Set the Stationary Zone timer expiration time '''
self.statzone_dist_moved_km = 0
self.statzone_timer = Gb.this_update_secs + Gb.statzone_still_time_secs
self.statzone_latitude = self.loc_data_latitude
self.statzone_longitude = self.loc_data_longitude
@property
def statzone_clear_timer(self):
''' Clear the Stationary Zone timer '''
self.statzone_reset_timer
self.statzone_timer = 0
def update_distance_moved(self, distance):
self.statzone_dist_moved_km = self.distance_km(self.statzone_latitude, self.statzone_longitude)
if Gb.evlog_trk_monitors_flag:
log_msg = (f"StatZone Movement > "
f"TotalMoved-{format_dist_km(self.statzone_dist_moved_km)}, "
f"UnderMoveLimit-{self.statzone_dist_moved_km <= Gb.statzone_dist_move_limit_km}, "
f"Timer-{secs_to_time(self.statzone_timer)}, "
f"TimerLeft- {self.statzone_timer_left} secs, "
f"TimerExpired-{self.is_statzone_timer_reached}")
post_monitor_msg(self.devicename, log_msg)
post_event(self.devicename, log_msg)
return self.statzone_dist_moved_km
Save the file and restart HA.
Note: The line numbers may be off by a few lines.
I'm finding it quite difficult getting devices to register as stationary. Every update during the stationary timer adds distance moved to the StatZone Movement Total. If I'm walking 35m backwards and forwards with each update, at the end of the stationary timer I'm not 140m from the point when the stationary timer started, I'm 35m or less.
Should IC3 be comparing the coordinates at the start and end of the stationary timer and the distance between them, rather than accumulating distance moved with each update during the stationary timer?
Alternatively, is there a way to modify the DistMoveLimit to a greater distance than 125m? I can't find a setting for it.