Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ashley Gittins <[email protected]>
  • Loading branch information
Lash-L and agittins authored Nov 11, 2024
1 parent 4a0fa09 commit 0dd4552
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/bermuda/bermuda_device_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def calculate_data(self):
dist_count = self.smoothing_samples

# Calculate a moving-window average, that only includes
# historical values if their "closer" (ie more reliable).
# historical values if they're "closer" (ie more reliable).
#
# This might be improved by weighting the values by age, but
# already does a fairly reasonable job of hugging the bottom
Expand All @@ -417,9 +417,9 @@ def calculate_data(self):
local_min = distance
dist_total += local_min

if dist_count > 0:
movavg = dist_total / dist_count
else:
if dist_total > 0: # Calculate the minimised-windowed-average
movavg = dist_total / len(self.hist_distance_by_interval)
else: # we have only a single measurement.
movavg = local_min
# The average is only helpful if it's lower than the actual reading.
if self.rssi_distance_raw is None or movavg < self.rssi_distance_raw:
Expand Down

0 comments on commit 0dd4552

Please sign in to comment.