From cf4894e0ba309ef074c5bf8fdacd7ae9b4244b13 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Tue, 7 May 2024 00:02:40 +0200 Subject: [PATCH] Adjusted plot script for new circumstances --- bettwaage-plotter/main.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/bettwaage-plotter/main.py b/bettwaage-plotter/main.py index afc76e8..cf0f72a 100644 --- a/bettwaage-plotter/main.py +++ b/bettwaage-plotter/main.py @@ -4,7 +4,7 @@ from datetime import datetime import json -file_path = "history.json" +file_path = None history_url = "http://192.168.178.84:9587/bettwaage/history" convert_time_to_seconds = True @@ -21,44 +21,40 @@ else: # Experiment: Solving for missing foot with known total weight -bed_weight = 78290 -person_weight = 63000 +bed_weight = 81 +person_weight = 63 known_total_weight = bed_weight + person_weight bed_only_weight = {} for d in data: - if d["total"] == bed_weight: + if d["total"] < bed_weight: bed_only_weight = { "tl": d["tl"], "tr": d["tr"], - "bl": bed_weight - (d["tl"] + d["tr"] + d["br"]), + "bl": d["bl"], "br": d["br"], } break in_bed_data = None -threshhold = 100000 +threshhold = 100.0 min_length = 100 +skip = 0 for d in data: t = d["total"] if t >= threshhold: if in_bed_data is None: in_bed_data = [] in_bed_data.append(d) - elif in_bed_data is not None: - if len(in_bed_data) < min_length: + elif in_bed_data is not None and len(in_bed_data) > 0: + if skip > 0: + in_bed_data = [] + skip -= 1 + elif len(in_bed_data) < min_length: in_bed_data = [] else: break - -# Calculate bottom left -for d in data: - d["bl"] = known_total_weight - (d["br"] + d["tr"] + d["tl"]) - # Set known total weight - d["total"] = known_total_weight - - -data = in_bed_data +# data = in_bed_data # Array data