bettwaage-sidequest #2

Merged
m.giller merged 38 commits from bettwaage-sidequest into master 2024-06-07 23:38:56 +02:00
Showing only changes of commit 1b5c73127e - Show all commits

View file

@ -6,6 +6,7 @@ from statistics import median
from typing import Optional
import requests as r
from ..hue import hue
import logging
file_path: str = "bettwaage.csv"
header: str = "timestamp;tl;tr;bl;br;total;\n"
@ -77,6 +78,7 @@ def is_capacity_reached() -> bool:
def check_for_change():
# Check for capicity limits
if is_capacity_reached():
logging.info(f"Capacity reached")
return
global show_scale_countdown
@ -91,6 +93,7 @@ def check_for_change():
return
# Changed weight up or down?
logging.info(f"Delta: {delta}")
weight_increased = delta > 0
# Make sure there is a bed_weight
@ -98,9 +101,11 @@ def check_for_change():
if empty_weight is None:
clusters = get_clusters([d["total"] for d in local_history])
empty_weight = min([median(cluster) for cluster in clusters.values()])
logging.info(f"Empty weight: {empty_weight}")
# Determine number of people
number_of_people = round((latest["total"] - empty_weight) / average_person_weight)
logging.info(f"Number of people: {number_of_people}")
if number_of_people == 1 and weight_increased:
show_scale_countdown = 60 # Should be a multiple of 3