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