work: добавил автоматический режим

This commit is contained in:
Fedorov Dmitriy
2026-09-18 23:59:42 +03:00
parent 7dbfd8b069
commit cdec9b0996
24 changed files with 3449 additions and 33 deletions
+101
View File
@@ -0,0 +1,101 @@
from pathlib import Path
from app.auto.config import (
load_auto_config,
)
PROJECT_ROOT = (
Path(__file__)
.resolve()
.parents[1]
)
AUTO_CONFIG_FILE = (
PROJECT_ROOT
/ "config"
/ "auto.yaml"
)
def main():
config = load_auto_config(
AUTO_CONFIG_FILE
)
print()
print("=" * 70)
print("AUTO CONFIG")
print("=" * 70)
print(
"Version:",
config.version,
)
print(
"Check interval:",
config.check_interval,
)
print(
"Base speed:",
config.co2.base_speed,
)
print(
"Hysteresis:",
config.co2.hysteresis,
)
print(
"Thresholds:"
)
for ppm, speed in (
config.co2.thresholds
):
print(
f" CO2 >= {ppm:<4} "
f"-> speed {speed}"
)
assert config.version == 1
assert (
config.check_interval
== 5.0
)
assert (
config.co2.base_speed
== 1
)
assert (
config.co2.hysteresis
== 100
)
assert (
config.co2.thresholds
== (
(800, 2),
(1000, 3),
(1300, 4),
(1600, 5),
(2000, 6),
)
)
print()
print("=" * 70)
print(
"AUTO CONFIG TEST PASSED"
)
print("=" * 70)
if __name__ == "__main__":
main()