Fixed format string quotes
This commit is contained in:
parent
3ced1992a5
commit
ab5a192524
1 changed files with 16 additions and 14 deletions
|
@ -15,9 +15,9 @@ matrix_clock_api: str = "http://192.168.178.84:8000"
|
||||||
|
|
||||||
empty_weight: Optional[float] = None
|
empty_weight: Optional[float] = None
|
||||||
local_history = []
|
local_history = []
|
||||||
history_max_length: int = 24 * 60 * 60 # 24 hours
|
history_max_length: int = 24 * 60 * 60 # 24 hours
|
||||||
min_noticable_difference: float= 25 # In kg
|
min_noticable_difference: float = 25 # In kg
|
||||||
show_scale_countdown: int = 0 # Number of updates for the scale, until return to clock
|
show_scale_countdown: int = 0 # Number of updates for the scale, until return to clock
|
||||||
|
|
||||||
average_person_weight: float = 75
|
average_person_weight: float = 75
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ leg_capacity_limit_patterns = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_clusters(data: list[float], min_delta: float) -> dict:
|
def get_clusters(data: list[float], min_delta: float) -> dict:
|
||||||
clusters = {}
|
clusters = {}
|
||||||
for point in data:
|
for point in data:
|
||||||
|
@ -40,13 +39,13 @@ def get_clusters(data: list[float], min_delta: float) -> dict:
|
||||||
clusters[point] = [point]
|
clusters[point] = [point]
|
||||||
return clusters
|
return clusters
|
||||||
|
|
||||||
|
|
||||||
def show_time():
|
def show_time():
|
||||||
r.post(f"{matrix_clock_api}/time")
|
r.post(f"{matrix_clock_api}/time")
|
||||||
|
|
||||||
def show_scale(weight:float):
|
|
||||||
r.post(f"{matrix_clock_api}/message", json={
|
def show_scale(weight: float):
|
||||||
"message": f"{weight:3.1f}kg"
|
r.post(f"{matrix_clock_api}/message", json={"message": f"{weight:3.1f}kg"})
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def is_capacity_reached() -> bool:
|
def is_capacity_reached() -> bool:
|
||||||
|
@ -65,15 +64,18 @@ def is_capacity_reached() -> bool:
|
||||||
is_warning_active = False
|
is_warning_active = False
|
||||||
show_time()
|
show_time()
|
||||||
return
|
return
|
||||||
|
|
||||||
is_warning_active = True
|
is_warning_active = True
|
||||||
r.post(f"{matrix_clock_api}/pattern?pattern={highest_limit["pattern"]}&step_ms={highest_limit["duration"]}&contrast=255")
|
r.post(
|
||||||
|
f"{matrix_clock_api}/pattern?pattern={highest_limit['pattern']}&step_ms={highest_limit['duration']}&contrast=255"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_for_change():
|
def check_for_change():
|
||||||
# Check for capicity limits
|
# Check for capicity limits
|
||||||
if is_capacity_reached():
|
if is_capacity_reached():
|
||||||
return
|
return
|
||||||
|
|
||||||
global show_scale_countdown
|
global show_scale_countdown
|
||||||
latest = local_history[-1]
|
latest = local_history[-1]
|
||||||
if show_scale_countdown > 0 and show_scale_countdown % 3 == 0:
|
if show_scale_countdown > 0 and show_scale_countdown % 3 == 0:
|
||||||
|
@ -93,12 +95,12 @@ def check_for_change():
|
||||||
if empty_weight is None:
|
if empty_weight is None:
|
||||||
clusters = get_clusters(local_history)
|
clusters = get_clusters(local_history)
|
||||||
empty_weight = min([median(cluster) for cluster in clusters.values()])
|
empty_weight = min([median(cluster) for cluster in clusters.values()])
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
||||||
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
|
||||||
elif number_of_people >= 2 and weight_increased:
|
elif number_of_people >= 2 and weight_increased:
|
||||||
show_scale_countdown = 0
|
show_scale_countdown = 0
|
||||||
show_time()
|
show_time()
|
||||||
|
|
Loading…
Reference in a new issue