diff --git a/src/endpoints/handlers/bett.py b/src/endpoints/handlers/bett.py index be627d7..05732aa 100644 --- a/src/endpoints/handlers/bett.py +++ b/src/endpoints/handlers/bett.py @@ -18,14 +18,17 @@ empty_weight: Optional[float] = None local_history = [] history_max_length: int = 24 * 60 * 60 # 24 hours min_noticable_difference: float = 25 # In kg -show_scale_countdown: int = 0 # Number of updates for the scale, until return to clock +initial_scale_coutndown: int = ( + 0 # Number of updates for the scale, until return to clock, should be a multiple of 3 +) +current_scale_countdown: int = 0 average_person_weight: float = 75 is_warning_active: int = -1 leg_capacity_limit_patterns = [ - {"limit": 80, "pattern": 110, "duration": 250}, - {"limit": 90, "pattern": 110, "duration": 100}, + # {"limit": 80, "pattern": 110, "duration": 250}, + # {"limit": 90, "pattern": 110, "duration": 100}, {"limit": 100, "pattern": 10, "duration": 50}, ] @@ -84,13 +87,13 @@ def check_for_change(): if len(local_history) < 2: return - global show_scale_countdown + global current_scale_countdown global empty_weight latest = local_history[-1] - if show_scale_countdown > 0: - if show_scale_countdown % 3 == 0: + if current_scale_countdown > 0: + if current_scale_countdown % 3 == 0: show_scale(latest["total"] - empty_weight) - show_scale_countdown -= 1 + current_scale_countdown -= 1 # Is triggered? delta = latest["total"] - local_history[-2]["total"] @@ -113,10 +116,10 @@ def check_for_change(): logging.info(f"Number of people: {number_of_people}") # Show scale? - if number_of_people == 1 and weight_increased and show_scale_countdown == 0: - show_scale_countdown = 60 # Should be a multiple of 3 + if number_of_people == 1 and weight_increased and current_scale_countdown == 0: + current_scale_countdown = initial_scale_coutndown else: - show_scale_countdown = 0 + current_scale_countdown = 0 # Make room sexy if number_of_people >= 2 and weight_increased: