docs(home-assistant): mettre à jour la documentation de l'intégration présence
Précise l'authentification Bearer (WORKLOG_API_TOKEN), la configuration des secrets et commandes REST Home Assistant, les codes de réponse de l'API et la conservation des événements de présence. Co-authored-by: OpenAI/GPT-5.6-Terra <vibecoder@antoineve.me>
This commit is contained in:
13
AGENTS.md
13
AGENTS.md
@@ -39,6 +39,7 @@ grep -A 1 -B 1 subagent /home/antoine/.config/opencode/opencode.json
|
||||
## Variables d'environnement
|
||||
|
||||
- `SECRET_KEY` : requis en production (défaut `dev-secret-change-in-prod` en dev)
|
||||
- `WORKLOG_API_TOKEN` : requis en production pour l'authentification par jeton Bearer de l'API de présence Home Assistant (`/api/v1/workplace-presence`)
|
||||
|
||||
## Git & Conventions de Commit
|
||||
|
||||
@@ -54,10 +55,10 @@ grep -A 1 -B 1 subagent /home/antoine/.config/opencode/opencode.json
|
||||
Flask app using the factory pattern (`create_app()` in `app/__init__.py`). The DB is SQLite via SQLAlchemy, stored in `instance/worklog.db`. All vehicle/journey/tax configuration lives in `config.toml` (loaded at startup into `app.config["TOML"]`), not in the database.
|
||||
|
||||
**Data flow:**
|
||||
- `config.toml` → `app/config_loader.py` → accessed via `get_vehicles()`, `get_journeys()`, `get_bareme(year, cv)`
|
||||
- `app/models.py` defines `WorkEntry` (one row per day), `TimeSlot` (N plages horaires per entry), `LeaveBalance` (annual quotas)
|
||||
- `app/business/` contains pure functions with no Flask dependencies: `time_calc.py` (minutes/reference), `travel_calc.py` (km, CO2, frais réels), `leave_calc.py` (solde congés/RTT)
|
||||
- Routes in `app/routes/` use business functions and config_loader, then render Jinja2 templates
|
||||
- `config.toml` → `app/config_loader.py` → accessed via `get_vehicles()`, `get_journeys()`, `get_bareme(year, cv)`, `get_home_assistant_config()`
|
||||
- `app/models.py` defines `WorkEntry` (one row per day), `TimeSlot` (N plages horaires per entry), `LeaveBalance` (annual quotas), `WorkplacePresenceEvent` (presence tracking events)
|
||||
- `app/business/` contains pure functions with no Flask dependencies: `time_calc.py` (minutes/reference), `travel_calc.py` (km, CO2, frais réels), `leave_calc.py` (solde congés/RTT), `presence_service.py` (presence event processing, idempotency, arrival/departure rules)
|
||||
- Routes in `app/routes/` and API in `app/api.py` use business functions and config_loader, then render Jinja2 templates or return JSON responses
|
||||
|
||||
**Key domain rules:**
|
||||
- Day types: `WORK | TT | GARDE | ASTREINTE | FORMATION | RTT | CONGE | MALADE | FERIE`
|
||||
@@ -70,9 +71,9 @@ Flask app using the factory pattern (`create_app()` in `app/__init__.py`). The D
|
||||
|
||||
**Tailwind CDN limitation:** Dynamic Jinja2 classes (e.g. `class="{{ var }}"`) are not included by the CDN. Use `style=` inline for dynamic colors.
|
||||
|
||||
**Auth:** Handled entirely by HAProxy upstream. The app has no authentication.
|
||||
**Auth:** Web interface handled entirely by HAProxy upstream (no authentication in app). Workplace presence API (`/api/v1/workplace-presence`) uses Bearer token authentication validated via the `WORKLOG_API_TOKEN` environment variable and `hmac.compare_digest`.
|
||||
|
||||
**Tests:** `tests/conftest.py` provides `app` and `client` fixtures using an in-memory SQLite DB and a temporary TOML config file. Business logic tests (`test_time_calc.py`, `test_travel_calc.py`) have no Flask dependencies and need no fixtures.
|
||||
**Tests:** `tests/conftest.py` provides `app` and `client` fixtures using an in-memory SQLite DB and a temporary TOML config file. Business logic tests (`test_time_calc.py`, `test_travel_calc.py`, `test_presence_service.py`) and API tests (`test_api.py`) have no Flask dependencies or use client fixtures respectively.
|
||||
|
||||
## Gotchas
|
||||
|
||||
|
||||
Reference in New Issue
Block a user