Add one-click installer to installationspaket

Installieren.cmd (double-click) wraps install.ps1, which automates steps 1-3
of ANLEITUNG.md: find the HA config share, copy pyscript/, data/ ->
audi_dashboard/ and www/, merge the configuration.yaml snippet, optionally
write ha_token.txt. The .cmd wrapper exists because double-clicking a .ps1
opens it in an editor and the execution policy blocks it; the bypass applies
to that one call only.

Designed to be safe to re-run:
- Never overwrites fahrzeugprofil.json, fahrten.jsonl, tankvorgaenge.jsonl,
  entitaeten.json or ha_token.txt, so re-running on a live install keeps the
  vehicle profile, trips, fills and sensor mapping.
- configuration.yaml is backed up to .bak first; the inserted part sits
  between marker lines and gets replaced instead of appended twice.
- If pyscript: or panel_custom: are already there from another source, the
  file is left untouched and the script prints what to merge by hand -
  duplicate top-level keys would be invalid YAML and HA would not start.
- Aborts before writing if the target has no configuration.yaml.

Steps that cannot be automated from a Windows share (HA restart, pip install
pypdf, sensor mapping) are collected into a closing to-do list. -Pruefen shows
what would happen without writing.

install.ps1 is stored UTF-8 *with* BOM - PowerShell 5.1 reads scripts as ANSI
otherwise and mangles the umlauts; the files it writes stay BOM-less.

Verified against a fake config tree: fresh install, re-run idempotency,
existing-data preservation, foreign-key refusal, wrong-directory abort, and
the merged configuration.yaml parses as valid YAML.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-08-16 13:02:02 +02:00
co-authored by Claude Opus 5
parent fb38c297bd
commit 484f2ffe6d
3 changed files with 353 additions and 0 deletions
@@ -8,6 +8,52 @@ nur die Checkliste.
- HACS installiert, darüber **pyscript** installiert (HACS → Integrationen →
„pyscript" suchen → Download → HA neu starten)
- Das **Samba-Share-Add-on** in HA läuft, damit `\\<HA-IP>\config` vom PC aus
erreichbar ist
---
## Der schnelle Weg: `Installieren.cmd`
**Doppelklick auf `Installieren.cmd`** — das erledigt die Schritte 13 unten von
selbst: es sucht die HA-Instanz im Netz (`\\homeassistant\config` und die
üblichen Alternativen, sonst fragt es nach dem Pfad), kopiert `pyscript\`,
`data\``audi_dashboard\` und `www\`, trägt die beiden Blöcke in die
`configuration.yaml` ein und listet am Ende auf, was noch von Hand zu tun ist
(Neustart, Token, Sensoren zuordnen).
Was es dabei **nicht** tut:
- Bestehende Daten überschreiben. `fahrzeugprofil.json`, `fahrten.jsonl`,
`tankvorgaenge.jsonl`, `entitaeten.json` und `ha_token.txt` bleiben
unangetastet — ein zweiter Lauf auf einer laufenden Installation ist deshalb
gefahrlos.
- Die `configuration.yaml` blind verändern. Sie wird vorher nach
`configuration.yaml.bak` gesichert, und stehen dort schon eigene
`pyscript:`- oder `panel_custom:`-Einträge, fasst das Skript sie gar nicht an
und sagt stattdessen, was zu ergänzen ist (zwei gleiche Top-Level-Schlüssel
wären ungültiges YAML — HA würde nicht mehr starten).
Erst schauen, was passieren würde, ohne etwas zu schreiben:
```powershell
.\install.ps1 -Pruefen
```
Mit festem Ziel und Token in einem Rutsch:
```powershell
.\install.ps1 -Ziel "\\192.168.1.50\config" -Token "eyJhb..."
```
Danach weiter bei **Schritt 3** (Token, falls nicht übergeben), **4** und **5**.
---
## Der Weg von Hand
Falls `Installieren.cmd` nicht durchläuft oder lieber nachvollziehbar
Schritt für Schritt gearbeitet werden soll:
## 1. Dateien kopieren