10 KiB
Installation Guide - OpenEMS Battery Optimizer
Vollständige Schritt-für-Schritt-Anleitung zur Installation des Battery Charging Optimizers.
Inhaltsverzeichnis
- Voraussetzungen
- PyScript Installation
- Script-Dateien kopieren
- Konfiguration
- Automationen einrichten
- Dashboard installieren
- Erste Inbetriebnahme
- Verifizierung
Voraussetzungen
Home Assistant
- Home Assistant 2024.2 oder neuer
- Zugriff auf
/config/Verzeichnis (via File Editor oder SSH) - HACS installiert
Hardware
- OpenEMS auf BeagleBone (oder vergleichbar)
- GoodWe Batterie & Inverter
- Netzwerkverbindung zu OpenEMS (Modbus TCP Port 502, JSON-RPC Port 8074)
Erforderliche Integrationen
-
PyScript (via HACS)
- Settings → Devices & Services → Add Integration → PyScript
-
Forecast.Solar (Standard Integration)
- Settings → Devices & Services → Add Integration → Forecast.Solar
- Konfiguriere deine PV-Arrays (Azimut, Neigung, kWp)
-
Modbus (Standard Integration)
- Wird in
configuration.yamlkonfiguriert (siehe unten)
- Wird in
1. PyScript Installation
Via HACS
- HACS → Integrations → "Explore & Download Repositories"
- Suche nach "PyScript"
- Download & Install
- Home Assistant neu starten
Konfiguration
Füge zu configuration.yaml hinzu:
pyscript:
allow_all_imports: true
hass_is_global: true
Neustart erforderlich!
2. Script-Dateien kopieren
Kopiere die folgenden Dateien nach /config/pyscript/:
/config/pyscript/
├── battery_charging_optimizer.py # Haupt-Optimizer
├── hastrom_flex_extended.py # Strompreis-Fetcher
└── ess_set_power.py # Modbus Power Control
Via File Editor
- Settings → Add-ons → File Editor
- Navigiere zu
/config/pyscript/ - Erstelle neue Dateien und kopiere den Inhalt
Via SSH/Terminal
cd /config/pyscript
wget https://gitea.ges4.net/felix/openems-battery-optimizer/raw/branch/main/pyscripts/battery_charging_optimizer.py
wget https://gitea.ges4.net/felix/openems-battery-optimizer/raw/branch/main/pyscripts/hastrom_flex_extended.py
wget https://gitea.ges4.net/felix/openems-battery-optimizer/raw/branch/main/pyscripts/ess_set_power.py
3. Konfiguration
3.1 Input Helper erstellen
Kopiere config/battery_optimizer_config.yaml und füge den Inhalt zu deiner configuration.yaml hinzu:
Input Helper Konfiguration (Klicken zum Ausklappen)
input_boolean:
battery_optimizer_enabled:
name: "Batterie-Optimierung aktiviert"
icon: mdi:battery-charging
goodwe_manual_control:
name: "Manuelle Batteriesteuerung"
icon: mdi:battery-sync
battery_optimizer_manual_override:
name: "Manueller Override (Automatik pausieren)"
icon: mdi:pause-circle
input_number:
battery_capacity_kwh:
name: "Batteriekapazität"
min: 1
max: 50
step: 0.1
unit_of_measurement: "kWh"
icon: mdi:battery
initial: 10 # ← DEINE KAPAZITÄT
battery_optimizer_min_soc:
name: "Minimum SOC"
min: 0
max: 100
step: 1
unit_of_measurement: "%"
initial: 20
battery_optimizer_max_soc:
name: "Maximum SOC"
min: 0
max: 100
step: 1
unit_of_measurement: "%"
initial: 100
battery_optimizer_max_charge_power:
name: "Maximale Ladeleistung"
min: 1000
max: 10000
step: 100
unit_of_measurement: "W"
initial: 5000 # ← DEINE MAX LADELEISTUNG
charge_power_battery:
name: "Ziel-Ladeleistung"
min: -10000
max: 10000
step: 100
unit_of_measurement: "W"
icon: mdi:flash
# ... weitere Input Helper aus battery_optimizer_config.yaml
3.2 REST Commands
Füge config/rest_requests.yaml zu deiner configuration.yaml hinzu:
rest_command:
set_ess_remote_mode:
url: "http://x:admin@192.168.89.144:8074/jsonrpc" # ← DEINE OPENEMS IP
method: POST
payload: '{"method": "updateComponentConfig", "params": {"componentId": "ess0","properties":[{"name": "controlMode","value": "REMOTE"}]}}'
set_ess_internal_mode:
url: "http://x:admin@192.168.89.144:8074/jsonrpc" # ← DEINE OPENEMS IP
method: POST
payload: '{"method": "updateComponentConfig", "params": {"componentId": "ess0","properties":[{"name": "controlMode","value": "INTERNAL"}]}}'
3.3 Modbus Konfiguration
Füge zu configuration.yaml hinzu:
modbus:
- name: openEMS
type: tcp
host: 192.168.89.144 # ← DEINE OPENEMS IP
port: 502
sensors:
- name: "EssSoc"
address: 802
slave: 1
scan_interval: 5
unit_of_measurement: "%"
device_class: battery
- name: "EssActivepower"
address: 806
slave: 1
scan_interval: 5
unit_of_measurement: "W"
device_class: power
- name: "GridActivepower"
address: 2822
slave: 1
scan_interval: 5
unit_of_measurement: "W"
device_class: power
- name: "ProductionActivepower"
address: 2837
slave: 1
scan_interval: 5
unit_of_measurement: "W"
device_class: power
- name: "ConsumptionActivepower"
address: 2827
slave: 1
scan_interval: 5
unit_of_measurement: "W"
device_class: power
Nach jeder Änderung: Configuration → Reload YAML Configuration (oder Neustart)
4. Automationen einrichten
4.1 Optimizer Automationen
Importiere automations/battery_optimizer_automations.yaml:
Option A: Via UI
- Settings → Automations & Scenes
- Rechts unten: "⋮" → "Edit in YAML"
- Kopiere jede Automation einzeln
Option B: Via automations.yaml
Füge alle Automations aus der Datei zu deiner /config/automations.yaml hinzu.
Wichtig: Passe IDs an, falls Konflikte:
- id: battery_optimizer_daily_calculation # ← Muss unique sein
alias: "Batterie Optimierung: Tägliche Planung"
...
4.2 Keep-Alive & ESS-Modus Automationen
Importiere die drei Automations aus automations/:
speicher_manuell_laden.yaml- Keep-Alive (30s)manuelle_speicherbeladung_aktivieren.yaml- ESS → REMOTEmanuelle_speicherbeladung_deaktivieren.yaml- ESS → INTERNAL
5. Dashboard installieren
Empfohlen: Sections Dashboard (Standard)
- Settings → Dashboards → "+ ADD DASHBOARD"
- Name: "Batterie Optimierung"
- Icon:
mdi:battery-charging - "⋮" → "Edit Dashboard" → "Raw configuration editor"
- Kopiere Inhalt von
dashboards/battery_optimizer_sections_standard.yaml
Alternative Dashboards
- Compact:
battery_optimizer_sections_compact.yaml - Minimal:
battery_optimizer_sections_minimal.yaml
Erforderliche Custom Cards (HACS)
HACS → Frontend → Explore & Download Repositories:
- Mushroom Cards
- Bubble Card
- Plotly Graph Card
- Power Flow Card Plus
- Stack-in-Card
6. Erste Inbetriebnahme
6.1 PyScript neu laden
Developer Tools → Services
Service: pyscript.reload
6.2 Optimizer aktivieren
Developer Tools → States
Suche: input_boolean.battery_optimizer_enabled
Set State: on
6.3 Ersten Plan erstellen
Developer Tools → Services
Service: pyscript.calculate_charging_schedule
Prüfe die Logs:
Settings → System → Logs
Filter: "battery"
7. Verifizierung
7.1 Schedule prüfen
Developer Tools → States
Entity: pyscript.battery_charging_schedule
Attributes sollten enthalten:
schedule: Array mit Stundennum_charges: Anzahl Ladestundenlast_update: Timestamp
7.2 Preis-Sensor prüfen
Developer Tools → States
Entity: sensor.hastrom_flex_pro_ext
Attributes:
prices_today: Array mit 24 Preisendatetime_today: Array mit Timestampstomorrow_available: true/falseprices_tomorrow: Array (ab 14:00)
7.3 Modbus-Verbindung prüfen
Developer Tools → States
Entity: sensor.esssoc
Sollte aktuellen SOC anzeigen (z.B. 65%).
7.4 Test-Ladung
Vorsicht: Startet echte Batterieladung!
Developer Tools → Services
# 1. Ladeleistung setzen
Service: input_number.set_value
Target: input_number.charge_power_battery
Data:
value: -3000 # Negativ = Laden mit 3000W
# 2. Manuellen Modus aktivieren
Service: input_boolean.turn_on
Target: input_boolean.goodwe_manual_control
Prüfe:
- OpenEMS sollte "REMOTE" Modus zeigen
- Batterie sollte mit ~3000W laden
- Nach 30s wieder stoppen:
Service: input_boolean.turn_off
Target: input_boolean.goodwe_manual_control
Troubleshooting
PyScript startet nicht
# Prüfe Syntax-Fehler
cd /config/pyscript
python3 battery_charging_optimizer.py
Keine Strompreise
- Prüfe Internet-Verbindung
- URL testen:
http://eex.stwhas.de/api/spotprices/flexpro?start_date=20250126&end_date=20250127 - Log prüfen:
grep -i hastrom /config/home-assistant.log
Modbus Fehler
# Test Modbus Verbindung
Developer Tools → Services
Service: modbus.write_register
Data:
hub: openEMS
slave: 1
address: 706
value: [0, 0] # 0W (Test)
Batterie lädt nicht
- Prüfe
input_boolean.goodwe_manual_controlist ON - Prüfe OpenEMS ESS Mode (sollte REMOTE sein)
- Prüfe Keep-Alive Automation läuft
- Prüfe OpenEMS Logs:
tail -f /var/log/openems/openems.log
Nächste Schritte
Nach erfolgreicher Installation:
- Monitoring: Beobachte den ersten Ladezyklus
- Feintuning: Passe
min_soc,max_charge_poweran - Dashboard: Experimentiere mit verschiedenen Dashboard-Varianten
- Automationen: Erweitere mit eigenen Automationen
Support
Bei Problemen:
- Prüfe TROUBLESHOOTING.md
- Schaue in die Issues
- Erstelle ein Issue mit:
- Home Assistant Version
- OpenEMS Version
- Relevante Logs
- Konfiguration (ohne Passwörter!)