work: Реализована работа расписания. Проведен первый тест.

This commit is contained in:
Fedorov Dmitriy
2026-09-13 23:04:35 +03:00
parent 419b8efe33
commit 4c665d9108
9 changed files with 1398 additions and 1 deletions
+66
View File
@@ -0,0 +1,66 @@
import asyncio
import logging
from pathlib import Path
from app.my_dataclasses import TION_MAC
from app.tion import TionController, TionService
from schedule import (
ScheduleService,
load_schedule,
)
logging.disable(logging.CRITICAL)
PROJECT_ROOT = Path(__file__).resolve().parents[1]
SCHEDULE_FILE = (
PROJECT_ROOT
/ "config"
/ "schedule.yaml"
)
async def main():
config = load_schedule(SCHEDULE_FILE)
controller = TionController(TION_MAC)
tion = TionService(
controller,
poll_interval=5,
)
schedule = ScheduleService(
config,
tion,
check_interval=5,
)
await tion.start()
await schedule.start()
print("Schedule started. Ctrl+C to stop.")
try:
while True:
await asyncio.sleep(5)
if tion.state:
print(
f"power={tion.state.power} "
f"speed={tion.state.fan_speed} "
f"heater={tion.state.heater}"
)
finally:
await schedule.stop()
await tion.stop()
if __name__ == "__main__":
asyncio.run(main())