From c4e302aef276a39dc8b367fc3bcc4fa199efb81a Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Mon, 6 May 2024 22:23:32 +0200 Subject: [PATCH] Fixed warning active flag --- src/endpoints/handlers/bett.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/endpoints/handlers/bett.py b/src/endpoints/handlers/bett.py index 91f174d..c53074b 100644 --- a/src/endpoints/handlers/bett.py +++ b/src/endpoints/handlers/bett.py @@ -21,7 +21,7 @@ show_scale_countdown: int = 0 # Number of updates for the scale, until return t average_person_weight: float = 75 -is_warning_active: bool = False +is_warning_active: int = 0 leg_capacity_limit_patterns = [ {"limit": 80, "pattern": 110, "duration": 1000}, {"limit": 90, "pattern": 110, "duration": 250}, @@ -61,14 +61,17 @@ def is_capacity_reached() -> bool: global is_warning_active if highest_limit is None: if is_warning_active: - is_warning_active = False + is_warning_active = 0 show_time() - return + return False - is_warning_active = True - r.post( - f"{matrix_clock_api}/pattern?pattern={highest_limit['pattern']}&step_ms={highest_limit['duration']}" - ) + if is_warning_active != highest_limit["limit"]: + is_warning_active = highest_limit["limit"] + r.post( + f"{matrix_clock_api}/pattern?pattern={highest_limit['pattern']}&step_ms={highest_limit['duration']}" + ) + + return True def check_for_change():