documentation: profiles feature

This commit is contained in:
2026-08-07 21:36:08 +02:00
parent b90b2f9ba1
commit 3a2d803788
3 changed files with 47 additions and 21 deletions
+4 -1
View File
@@ -11,7 +11,7 @@ MVG Departures Monitor: FastAPI-App für Münchner U-/S-Bahn-Abfahrtsanzeige. Mo
| `app/main.py` | FastAPI-App, Endpunkte, Caching, MVG-API-Aufrufe | | `app/main.py` | FastAPI-App, Endpunkte, Caching, MVG-API-Aufrufe |
| `app/config.py` | Config-Loader: YAML → Dataclasses | | `app/config.py` | Config-Loader: YAML → Dataclasses |
| `app/templates/index.html` | Jinja2-HTML-Template (Mobile-UI) | | `app/templates/index.html` | Jinja2-HTML-Template (Mobile-UI) |
| `config.yaml` | Stationskonfiguration (User-Input) | | `config.yaml` | Profil- und Stationskonfiguration (User-Input) |
| `requirements.txt` | Python-Dependencies | | `requirements.txt` | Python-Dependencies |
| `Dockerfile` | Container-Build | | `Dockerfile` | Container-Build |
| `.github/workflows/build.yml` | CI/CD | | `.github/workflows/build.yml` | CI/CD |
@@ -60,6 +60,9 @@ Kein Linter konfiguriert. Bei Bedarf: `ruff check app/` oder `black app/`
### Neue Station hinzufügen ### Neue Station hinzufügen
→ Nur `config.yaml` editieren, kein Code nötig → Nur `config.yaml` editieren, kein Code nötig
### Neues Profil hinzufügen
`config.yaml` unter `profiles:` neuen Eintrag mit `name:` und `stations:` ergänzen
### Neuen Transporttyp hinzufügen ### Neuen Transporttyp hinzufügen
`TYPE_MAP` und `ICON_MAP` in `main.py` erweitern, CSS-Klasse `.icon-X` in `index.html` hinzufügen `TYPE_MAP` und `ICON_MAP` in `main.py` erweitern, CSS-Klasse `.icon-X` in `index.html` hinzufügen
+24 -13
View File
@@ -7,6 +7,9 @@ Kompakter Abfahrtsmonitor fuer MVG U-Bahn und S-Bahn (Muenchen), primaer fuer mo
- Konfigurierbare Stationsliste (`config.yaml`) mit Typ (UBAHN/SBAHN/TRAM/BUS) - Konfigurierbare Stationsliste (`config.yaml`) mit Typ (UBAHN/SBAHN/TRAM/BUS)
- Ausschluss-Filter pro Station: nur unerwuenschte Zielrichtungen werden ausgeblendet, - Ausschluss-Filter pro Station: nur unerwuenschte Zielrichtungen werden ausgeblendet,
neue/unbekannte Ziele werden automatisch weiter angezeigt neue/unbekannte Ziele werden automatisch weiter angezeigt
- Profile zur Gruppierung von Stationen (z.B. "Hinfahrt" und "Rückfahrt")
- Klickbare Kacheln zum Profilwechsel (nur bei >1 Profil)
- URL-Param `?profile=<name>` + Auto-Refresh
- Zwei Endpunkte: - Zwei Endpunkte:
- `/` — mobile-optimierte HTML-Ansicht mit Auto-Refresh (alle 60s per Meta-Refresh) - `/` — mobile-optimierte HTML-Ansicht mit Auto-Refresh (alle 60s per Meta-Refresh)
- `/api/departures` — JSON-Ausgabe derselben Daten - `/api/departures` — JSON-Ausgabe derselben Daten
@@ -24,18 +27,24 @@ refresh_seconds: 60
cache_seconds: 20 cache_seconds: 20
departures_limit: 10 departures_limit: 10
stations: profiles:
- name: "Josephsburg, München" - name: "Hinfahrt"
type: "UBAHN" stations:
exclude_destinations: - name: "Josephsburg, München"
- "Messestadt Ost" type: "UBAHN"
- "Messestadt West" exclude_destinations:
- "Messestadt Ost"
- name: "Berg am Laim, München" - "Messestadt West"
type: "SBAHN" - name: "Berg am Laim, München"
exclude_destinations: type: "SBAHN"
- "Erding" exclude_destinations:
- "Markt Schwaben" - "Erding"
- "Markt Schwaben"
- name: "Rückfahrt"
stations:
- name: "Grosshadern, München"
type: "UBAHN"
exclude_destinations: []
``` ```
`exclude_destinations` filtert per exaktem `destination`-Stringvergleich. Alles was `exclude_destinations` filtert per exaktem `destination`-Stringvergleich. Alles was
@@ -102,7 +111,9 @@ https://www.mvg.de/api/bgw-pt/v3/departures?globalId=de:09162:910&limit=10&trans
| Route | Beschreibung | | Route | Beschreibung |
|---|---| |---|---|
| `/` | HTML-Ansicht, mobile-optimiert, Auto-Refresh alle 60s | | `/` | HTML-Ansicht, mobile-optimiert, Auto-Refresh alle 60s |
| `/api/departures` | JSON-Liste aller gefilterten Abfahrten | | `/?profile=<name>` | HTML-Ansicht für ein bestimmtes Profil |
| `/api/departures` | JSON-Liste aller gefilterten Abfahrten (erstes Profil als Fallback) |
| `/api/departures?profile=<name>` | JSON-Liste für ein bestimmtes Profil |
| `/healthz` | Healthcheck fuer Docker/Watchtower | | `/healthz` | Healthcheck fuer Docker/Watchtower |
## Projektstruktur ## Projektstruktur
+19 -7
View File
@@ -42,7 +42,9 @@ config.yaml
load_config() → AppConfig (Dataclass) load_config() → AppConfig (Dataclass)
Für jede Station: Profile auswählen (?profile= param oder erstes Profil)
Für jede Station im aktiven Profil:
resolve_station_id(name) → station_id (mit Memory-Cache) resolve_station_id(name) → station_id (mit Memory-Cache)
MvgApi(station_id).departures(limit, transport_types) MvgApi(station_id).departures(limit, transport_types)
@@ -61,7 +63,9 @@ Response: JSON oder HTML-Template
| Route | Methode | Beschreibung | | Route | Methode | Beschreibung |
|---|---|---| |---|---|---|
| `/` | GET | Mobile HTML-Ansicht, Auto-Refresh alle 60s | | `/` | GET | Mobile HTML-Ansicht, Auto-Refresh alle 60s |
| `/api/departures` | GET | JSON-Liste aller gefilterten Abfahrten | | `/?profile=<name>` | GET | HTML-Ansicht für ein bestimmtes Profil |
| `/api/departures` | GET | JSON-Liste aller gefilterten Abfahrten (erstes Profil als Fallback) |
| `/api/departures?profile=<name>` | GET | JSON-Liste für ein bestimmtes Profil |
| `/healthz` | GET | Healthcheck (`{"status": "ok"}`) | | `/healthz` | GET | Healthcheck (`{"status": "ok"}`) |
## 6. Konfiguration (`config.yaml`) ## 6. Konfiguration (`config.yaml`)
@@ -71,11 +75,18 @@ refresh_seconds: 60 # Meta-Refresh-Intervall (HTML)
cache_seconds: 20 # API-Cache pro Station cache_seconds: 20 # API-Cache pro Station
departures_limit: 10 # Max. Abfahrten pro Station departures_limit: 10 # Max. Abfahrten pro Station
stations: profiles:
- name: "Station Name, München" - name: "Hinfahrt" # Profilname (einzigartig)
type: "UBAHN" # UBAHN | SBAHN | TRAM | BUS stations:
exclude_destinations: # Exakter Stringvergleich - name: "Station Name, München"
- "Zielstation" type: "UBAHN" # UBAHN | SBAHN | TRAM | BUS
exclude_destinations: # Exakter Stringvergleich
- "Zielstation"
- name: "Rückfahrt"
stations:
- name: "Andere Station"
type: "SBAHN"
exclude_destinations: []
``` ```
### Filter-Logik ### Filter-Logik
@@ -93,6 +104,7 @@ stations:
## 8. UI ## 8. UI
- Dunkles Theme (`#111417` Background) - Dunkles Theme (`#111417` Background)
- Profil-Kacheln (nur bei >1 Profil): 50% Breite, Basis `#1e242b`, aktiv `#005ca9` (MVG-Blau)
- Farbliche Unterscheidung: U-Bahn (blau `#005ca9`), S-Bahn (grün `#00933b`), Tram (rot `#e2001a`), Bus (grau `#55545a`) - Farbliche Unterscheidung: U-Bahn (blau `#005ca9`), S-Bahn (grün `#00933b`), Tram (rot `#e2001a`), Bus (grau `#55545a`)
- Anzeige: Linie, Ziel, Abfahrtszeit, Verspätung (gelb/rot), Entfall, Störungsmeldungen - Anzeige: Linie, Ziel, Abfahrtszeit, Verspätung (gelb/rot), Entfall, Störungsmeldungen
- Responsive, für Smartphone-First optimiert - Responsive, für Smartphone-First optimiert