From e7f99493654f3dd0787af787f4858e971bd3669f Mon Sep 17 00:00:00 2001 From: Ashley Gittins Date: Wed, 13 Nov 2024 03:33:22 +0000 Subject: [PATCH] fix: IRK devices temporary unavail on mac rotation - Fixes Devices go unavailable every few mins for a few seconds #362 - Fix insert when velo_max is exceeded but the hist_distance_by_interval was empty (such as after MAC rotation) --- custom_components/bermuda/bermuda_device_scanner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/bermuda/bermuda_device_scanner.py b/custom_components/bermuda/bermuda_device_scanner.py index 258b57e..c06f80e 100644 --- a/custom_components/bermuda/bermuda_device_scanner.py +++ b/custom_components/bermuda/bermuda_device_scanner.py @@ -401,7 +401,10 @@ def calculate_data(self): velocity, ) # Discard the bogus reading by duplicating the last. - self.hist_distance_by_interval.insert(0, self.hist_distance_by_interval[0]) + if len(self.hist_distance_by_interval) == 0: + self.hist_distance_by_interval = [self.rssi_distance_raw] + else: + self.hist_distance_by_interval.insert(0, self.hist_distance_by_interval[0]) else: # Looks valid enough, add the current reading to the interval log self.hist_distance_by_interval.insert(0, self.rssi_distance_raw)