Move configuration to config.py

This commit is contained in:
2026-06-09 09:20:49 +02:00
parent 9002cbbe08
commit 0c6e94ef9f
3 changed files with 29 additions and 18 deletions

View File

@ -4,7 +4,8 @@
import json
from http.server import HTTPServer, BaseHTTPRequestHandler
from devices import shutdown_all, status_all, curfew_status, _set_budget, _get_budget, BUDGET_SECONDS, TICK_INTERVAL
import config
from devices import shutdown_all, status_all, curfew_status, _set_budget, _get_budget
class Handler(BaseHTTPRequestHandler):
@ -47,7 +48,7 @@ class Handler(BaseHTTPRequestHandler):
dev_id = data.get("device", "")
delta = int(data.get("delta", 0))
current = _get_budget(dev_id)
new_budget = max(0, min(BUDGET_SECONDS, current + delta))
new_budget = max(0, min(config.BUDGET_S, current + delta))
_set_budget(dev_id, new_budget)
self.send_response(200)
self.send_header("Content-Type", "application/json")
@ -242,7 +243,7 @@ if __name__ == "__main__":
start_timer()
server = HTTPServer(("0.0.0.0", port), Handler)
print(f"🚀 Open http://localhost:{port}")
print(f"⏱️ Budget timer running (checks every {TICK_INTERVAL}s, reset at 7:00 AM)")
print(f"⏱️ Budget timer running (checks every {config.TICK_INTERVAL}s, reset at 7:00 AM)")
try:
server.serve_forever()
except KeyboardInterrupt: