Affiche la batterie de la Kobo (push via params /image.png) en pied de page

This commit is contained in:
jerem
2026-06-15 16:01:09 +02:00
parent 0178f596ef
commit ba7ea0af3f
5 changed files with 88 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ from fastapi.responses import HTMLResponse
import render
from config import config
from integrations import kobo
app = FastAPI(title="Monitorink", docs_url=None, redoc_url=None)
@@ -26,7 +27,9 @@ async def health() -> dict:
@app.get("/image.png")
async def image(fresh: int = 0) -> Response:
async def image(fresh: int = 0, bat: int | None = None, chg: int = 0) -> Response:
# La Kobo pousse sa batterie ici (bat=0-100, chg=1 si en charge) à chaque fetch.
kobo.record(bat, bool(chg))
now = time.time()
cached = _cache["png"]
age = now - float(_cache["ts"])