Update: Battery Optimizer v3.4.0 mit allen Fixes und Features

This commit is contained in:
felix.zoesch
2025-12-12 08:20:19 +01:00
commit d2a41aad2d
78 changed files with 18053 additions and 0 deletions

View File

@@ -0,0 +1,338 @@
# ===================================================================
# Batterie-Optimierung Dashboard - SECTIONS LAYOUT (KOMPAKT)
# Modernes Home Assistant Sections-Layout mit max. 4 Spalten
# ===================================================================
type: sections
max_columns: 4
title: Batterie Optimierung
path: battery-optimizer
icon: mdi:battery-charging
sections:
# ===================================================================
# SECTION 1: HAUPTSTATUS & STEUERUNG
# ===================================================================
- type: grid
cards:
- type: heading
heading: Status & Steuerung
icon: mdi:view-dashboard
# Power Flow Visualisierung
- type: custom:power-flow-card-plus
entities:
battery:
entity: sensor.ess0_activepower
state_of_charge: sensor.esssoc
display_state: two_way
grid:
entity: sensor.grid_activepower
solar:
entity: sensor.production_activepower
home:
entity: sensor.consumption_activepower
clickable_entities: true
display_zero_state:
transparency: 50
w_decimals: 0
kw_decimals: 2
# Steuerung & Quick-Status
- type: grid
cards:
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.battery_optimizer_enabled
name: Auto-Optimierung
icon: mdi:robot
show_state: true
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.goodwe_manual_control
name: Manuelle Steuerung
icon: mdi:hand-back-right
show_state: true
- type: custom:bubble-card
card_type: button
entity: sensor.esssoc
name: Batterie SOC
icon: mdi:battery
show_state: true
- type: custom:bubble-card
card_type: button
entity: sensor.hastrom_flex_ext
name: Strompreis
icon: mdi:currency-eur
show_state: true
# ===================================================================
# SECTION 2: LADEPLAN-ÜBERSICHT
# ===================================================================
- type: grid
cards:
- type: heading
heading: Ladeplanung
icon: mdi:calendar-clock
- type: custom:bubble-card
card_type: button
entity: sensor.battery_charging_plan_status
name: Plan-Status
icon: mdi:calendar-check
show_state: true
show_last_changed: true
- type: custom:bubble-card
card_type: button
entity: sensor.battery_next_charge_time
name: Nächste Ladung
icon: mdi:clock-start
show_state: true
# Kompakte Plan-Anzeige
- type: markdown
content: |
{% set schedule = state_attr('pyscript.battery_charging_plan', 'schedule') %}
{% set stats = state_attr('pyscript.battery_charging_plan', 'plan_statistics') %}
{% if schedule and stats %}
**📊 Plan-Übersicht:**
• {{ stats.total_charging_hours }}h Ladung geplant
• {{ stats.total_energy_kwh | round(1) }} kWh Energie
• Ø {{ stats.average_price | round(2) }} ct/kWh
**📅 Nächste Ladungen:**
{% for slot in schedule %}
{% if slot.action == 'charge' %}
• **{{ slot.time[11:16] }}** Uhr - {{ slot.power }}W ({{ slot.price }}ct/kWh)
{% endif %}
{% endfor %}
{% else %}
⚠️ Kein Plan verfügbar
{% endif %}
# ===================================================================
# SECTION 3: STROMPREIS-VISUALISIERUNG
# ===================================================================
- type: grid
cards:
- type: heading
heading: Strompreis & Planung
icon: mdi:chart-line
- type: custom:plotly-graph
title: Strompreis 48h mit Ladeplan
hours_to_show: 48
refresh_interval: 300
layout:
height: 280
showlegend: true
legend:
orientation: h
y: -0.15
margin:
t: 10
b: 40
l: 50
r: 20
xaxis:
title: ''
yaxis:
title: ct/kWh
entities:
# Strompreis-Linie
- entity: sensor.hastrom_flex_ext
name: Strompreis
line:
color: '#FF9800'
width: 2
fill: tozeroy
fillcolor: 'rgba(255, 152, 0, 0.15)'
# Geplante Ladungen als Marker
- entity: ''
internal: true
name: Geplante Ladung
mode: markers
marker:
color: '#4CAF50'
size: 14
symbol: star
line:
color: '#2E7D32'
width: 2
# ===================================================================
# SECTION 4: BATTERIE-ÜBERSICHT
# ===================================================================
- type: grid
cards:
- type: heading
heading: Batterie-Verlauf
icon: mdi:battery-charging
- type: custom:plotly-graph
title: SOC & Leistung 24h
hours_to_show: 24
refresh_interval: 60
layout:
height: 280
showlegend: true
legend:
orientation: h
y: -0.15
margin:
t: 10
b: 40
l: 50
r: 50
yaxis:
title: SOC (%)
side: left
range: [0, 100]
yaxis2:
title: Leistung (W)
side: right
overlaying: y
entities:
# SOC
- entity: sensor.esssoc
name: SOC
yaxis: y
line:
color: '#2196F3'
width: 3
fill: tozeroy
fillcolor: 'rgba(33, 150, 243, 0.15)'
# Batterie-Leistung
- entity: sensor.ess0_activepower
name: Leistung
yaxis: y2
line:
color: '#4CAF50'
width: 2
# ===================================================================
# SECTION 5: DETAILLIERTER PLAN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Detaillierter Plan
icon: mdi:format-list-bulleted
# Plan-Statistiken als Bubble Cards
- type: horizontal-stack
cards:
- type: custom:bubble-card
card_type: button
entity: ''
name: |
{{ state_attr('pyscript.battery_charging_plan', 'plan_statistics').total_charging_hours or 0 }}h
sub_button:
- name: Ladedauer
icon: mdi:timer
show_background: false
- type: custom:bubble-card
card_type: button
entity: ''
name: |
{{ state_attr('pyscript.battery_charging_plan', 'plan_statistics').total_energy_kwh | round(1) or 0 }}kWh
sub_button:
- name: Energie
icon: mdi:lightning-bolt
show_background: false
- type: custom:bubble-card
card_type: button
entity: ''
name: |
{{ state_attr('pyscript.battery_charging_plan', 'plan_statistics').average_price | round(2) or 0 }}ct
sub_button:
- name: Ø Preis
icon: mdi:currency-eur
show_background: false
# Vollständige Plan-Tabelle
- type: markdown
content: |
{% set schedule = state_attr('pyscript.battery_charging_plan', 'schedule') %}
{% set stats = state_attr('pyscript.battery_charging_plan', 'plan_statistics') %}
{% if schedule and stats %}
| Zeit | Aktion | Leistung | Preis | Grund |
|------|--------|----------|-------|-------|
{% for slot in schedule %}
| {{ slot.time[11:16] }} | {{ '🔋 Laden' if slot.action == 'charge' else '⏸️ Warten' }} | {{ slot.power if slot.power else '-' }}W | {{ slot.price }}ct | {{ slot.reason }} |
{% endfor %}
{% else %}
⚠️ **Kein Ladeplan verfügbar**
Der Plan wird täglich um 14:05 Uhr neu berechnet.
{% endif %}
# ===================================================================
# SECTION 6: PARAMETER & EINSTELLUNGEN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Einstellungen
icon: mdi:cog
- type: entities
entities:
- entity: input_number.battery_optimizer_min_soc
name: Minimaler SOC
- entity: input_number.battery_optimizer_max_soc
name: Maximaler SOC
- entity: input_number.battery_optimizer_max_charge_power
name: Ladeleistung
- entity: input_number.battery_optimizer_reserve_capacity
name: Reserve-Kapazität
- entity: input_number.battery_optimizer_price_threshold
name: Preis-Schwelle
# ===================================================================
# SECTION 7: SYSTEM-STATUS
# ===================================================================
- type: grid
cards:
- type: heading
heading: System
icon: mdi:information
- type: glance
entities:
- entity: sensor.openems_state
name: OpenEMS
- entity: sensor.battery_capacity
name: Kapazität
- entity: sensor.forecast_solar_energy_today
name: PV Heute
- entity: sensor.forecast_solar_energy_tomorrow
name: PV Morgen
- type: glance
entities:
- entity: automation.battery_charging_schedule_calculation
name: Tägliche Berechnung
- entity: automation.battery_charging_schedule_execution
name: Stündliche Ausführung

View File

@@ -0,0 +1,213 @@
# ===================================================================
# Batterie-Optimierung Dashboard - SECTIONS LAYOUT (MINIMAL)
# Fokus auf das Wesentliche mit modernem Sections-Layout
# ===================================================================
type: sections
max_columns: 3
title: Batterie Quick
path: battery-quick
icon: mdi:battery-lightning
sections:
# ===================================================================
# SECTION 1: QUICK STATUS
# ===================================================================
- type: grid
cards:
- type: heading
heading: Status
icon: mdi:gauge
- type: custom:bubble-card
card_type: button
entity: sensor.esssoc
name: Batterie
icon: mdi:battery
show_state: true
- type: custom:bubble-card
card_type: button
entity: sensor.hastrom_flex_ext
name: Strompreis
icon: mdi:currency-eur
show_state: true
- type: custom:bubble-card
card_type: button
entity: sensor.production_activepower
name: PV Aktuell
icon: mdi:solar-power
show_state: true
# ===================================================================
# SECTION 2: STEUERUNG
# ===================================================================
- type: grid
cards:
- type: heading
heading: Steuerung
icon: mdi:toggle-switch
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.battery_optimizer_enabled
name: Auto-Optimierung
icon: mdi:robot
show_state: true
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.goodwe_manual_control
name: Manuelle Steuerung
icon: mdi:hand-back-right
show_state: true
# ===================================================================
# SECTION 3: ENERGIE-FLUSS
# ===================================================================
- type: grid
cards:
- type: heading
heading: Energie-Fluss
icon: mdi:transmission-tower
- type: custom:power-flow-card-plus
entities:
battery:
entity: sensor.ess0_activepower
state_of_charge: sensor.esssoc
grid:
entity: sensor.grid_activepower
solar:
entity: sensor.production_activepower
home:
entity: sensor.consumption_activepower
w_decimals: 0
kw_decimals: 1
min_flow_rate: 0.5
# ===================================================================
# SECTION 4: GEPLANTE LADUNGEN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Geplante Ladungen
icon: mdi:calendar-clock
- type: markdown
content: |
{% set schedule = state_attr('pyscript.battery_charging_plan', 'schedule') %}
{% if schedule %}
{% set charging_slots = schedule | selectattr('action', 'equalto', 'charge') | list %}
{% if charging_slots | length > 0 %}
{% for slot in charging_slots[:5] %}
### {{ '🟢 JETZT' if loop.index == 1 and slot.time[:13] == now().strftime('%Y-%m-%d %H') else '⏰' }} {{ slot.time[11:16] }} Uhr
**{{ slot.power }}W** bei **{{ slot.price }}ct/kWh**
{{ slot.reason }}
{% endfor %}
{% else %}
### ✅ Keine Ladung geplant
Aktuell sind keine Ladezyklen erforderlich.
{% endif %}
{% else %}
### ⚠️ Kein Plan
Berechnung erfolgt täglich um 14:05 Uhr.
{% endif %}
# ===================================================================
# SECTION 5: PREIS-TREND
# ===================================================================
- type: grid
cards:
- type: heading
heading: Strompreis 48h
icon: mdi:chart-line-variant
- type: custom:plotly-graph
hours_to_show: 48
refresh_interval: 600
layout:
height: 200
showlegend: false
margin:
t: 10
b: 30
l: 40
r: 10
yaxis:
title: ct/kWh
entities:
- entity: sensor.hastrom_flex_ext
line:
color: '#FF9800'
width: 2
shape: spline
fill: tozeroy
fillcolor: 'rgba(255, 152, 0, 0.15)'
# ===================================================================
# SECTION 6: SOC-TREND
# ===================================================================
- type: grid
cards:
- type: heading
heading: Batterie SOC 24h
icon: mdi:battery-charging-80
- type: custom:plotly-graph
hours_to_show: 24
refresh_interval: 120
layout:
height: 180
showlegend: false
margin:
t: 10
b: 30
l: 40
r: 10
yaxis:
title: '%'
range: [0, 100]
entities:
- entity: sensor.esssoc
line:
color: '#2196F3'
width: 3
shape: spline
fill: tozeroy
fillcolor: 'rgba(33, 150, 243, 0.2)'
# ===================================================================
# SECTION 7: SCHNELLEINSTELLUNGEN (Conditional)
# ===================================================================
- type: grid
cards:
- type: heading
heading: Einstellungen
icon: mdi:tune
- type: conditional
conditions:
- entity: input_boolean.battery_optimizer_enabled
state: 'on'
card:
type: entities
entities:
- entity: input_number.battery_optimizer_min_soc
name: Min. SOC
- entity: input_number.battery_optimizer_max_soc
name: Max. SOC
- entity: input_number.battery_optimizer_max_charge_power
name: Ladeleistung

View File

@@ -0,0 +1,411 @@
# ===================================================================
# Batterie-Optimierung Dashboard - SECTIONS LAYOUT (STANDARD)
# Vollversion mit allen Details und Sections-Layout
# ===================================================================
- type: sections
max_columns: 4
title: Batterie Detail
path: battery-detail
icon: mdi:battery-charging-100
sections:
# ===================================================================
# SECTION 1: ÜBERSICHT & POWER FLOW
# ===================================================================
- type: grid
cards:
- type: heading
heading: Energie-Übersicht
icon: mdi:home-lightning-bolt
- type: custom:power-flow-card-plus
entities:
battery:
entity: sensor.essactivepower
state_of_charge: sensor.esssoc
display_state: two_way
grid:
entity: sensor.gridactivepower
solar:
entity: sensor.productionactivepower
home:
entity: sensor.consumptionactivepower
clickable_entities: true
display_zero_state:
transparency: 50
w_decimals: 0
kw_decimals: 2
# ===================================================================
# SECTION 2: STEUERUNG
# ===================================================================
- type: grid
cards:
- type: heading
heading: Steuerung
icon: mdi:controller
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.battery_optimizer_enabled
name: Automatische Optimierung
icon: mdi:robot
show_state: true
- type: custom:bubble-card
card_type: button
button_type: switch
entity: input_boolean.goodwe_manual_control
name: Manuelle Steuerung
icon: mdi:hand-back-right
show_state: true
- type: entities
title: Wichtige Parameter
entities:
- entity: input_number.battery_optimizer_min_soc
name: Min. SOC
- entity: input_number.battery_optimizer_max_soc
name: Max. SOC
- entity: input_number.battery_optimizer_max_charge_power
name: Ladeleistung
- entity: input_number.battery_optimizer_reserve_capacity
name: Reserve
- type: divider
- entity: sensor.hastrom_flex_ext
name: Aktueller Preis
icon: mdi:currency-eur
- entity: sensor.esssoc
name: Aktueller SOC
icon: mdi:battery
# ===================================================================
# SECTION 3: LADEPLAN-STATUS
# ===================================================================
- type: grid
cards:
- type: heading
heading: Ladeplan
icon: mdi:calendar-clock
- type: custom:bubble-card
card_type: button
entity: pyscript.battery_charging_schedule
name: Plan-Status
icon: mdi:calendar-check
show_state: true
show_last_changed: true
- type: markdown
content: |
{% set attrs = state_attr('pyscript.battery_charging_schedule', 'schedule') %}
{% if attrs %}
**Nächste Ladung:**
{% set ns = namespace(found=false) %}
{% for entry in attrs %}
{% if entry.action == 'charge' and not ns.found %}
🔋 **{{ entry.datetime[11:16] }} Uhr**
{{ entry.price }} ct/kWh · {{ entry.power_w }}W
{% set ns.found = true %}
{% endif %}
{% endfor %}
{% if not ns.found %}
Keine Ladung geplant
{% endif %}
{% else %}
⚠️ Kein Plan
{% endif %}
- type: markdown
content: |
{% set schedule = state_attr('pyscript.battery_charging_schedule', 'schedule') %}
{% set last_updated = state_attr('pyscript.battery_charging_schedule', 'last_update') %}
{% if schedule %}
**Plan erstellt:** {{ last_updated[:16] if last_updated else 'Unbekannt' }}
**Geplante Ladestunden:**
{% for slot in schedule %}
{% if slot.action == 'charge' %}
- **{{ slot.datetime[:16] }}**
🔋 {{ slot.power_w }}W · 💶 {{ slot.price }}ct/kWh
*{{ slot.reason }}*
{% endif %}
{% endfor %}
{% else %}
⚠️ Kein Plan verfügbar
{% endif %}
# ===================================================================
# SECTION 4: STROMPREIS & LADEPLAN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Strompreis & Ladeplanung
icon: mdi:chart-bell-curve-cumulative
- type: custom:plotly-graph
title: Strompreis 48h mit geplanten Ladezeiten
hours_to_show: 48
refresh_interval: 300
layout:
height: 300
showlegend: true
legend:
orientation: h
y: -0.2
margin:
t: 20
b: 50
l: 60
r: 20
xaxis:
title: Zeit
yaxis:
title: Preis (ct/kWh)
entities:
# Strompreis
- entity: sensor.hastrom_flex_ext
name: Strompreis
line:
color: '#FF9800'
width: 2
fill: tozeroy
fillcolor: 'rgba(255, 152, 0, 0.1)'
# Geplante Ladezeiten (als Marker)
- entity: ''
name: Geplante Ladung
internal: true
mode: markers
marker:
color: '#4CAF50'
size: 14
symbol: star
line:
color: '#2E7D32'
width: 2
# ===================================================================
# SECTION 5: BATTERIE SOC & LEISTUNG
# ===================================================================
- type: grid
cards:
- type: heading
heading: Batterie SOC & Leistung
icon: mdi:battery-charging-outline
- type: custom:plotly-graph
title: Batterie-Übersicht 24h
hours_to_show: 24
refresh_interval: 60
layout:
height: 300
showlegend: true
legend:
orientation: h
y: -0.2
margin:
t: 20
b: 50
l: 60
r: 60
xaxis:
title: Zeit
yaxis:
title: SOC (%)
side: left
range: [0, 100]
yaxis2:
title: Leistung (W)
side: right
overlaying: y
entities:
# SOC
- entity: sensor.esssoc
name: SOC
yaxis: y
line:
color: '#2196F3'
width: 3
fill: tozeroy
fillcolor: 'rgba(33, 150, 243, 0.1)'
# Batterie-Leistung
- entity: sensor.essactivepower
name: Ladeleistung
yaxis: y2
line:
color: '#4CAF50'
width: 2
dash: dot
# ===================================================================
# SECTION 6: ENERGIE-FLÜSSE
# ===================================================================
- type: grid
cards:
- type: heading
heading: Energie-Flüsse
icon: mdi:transmission-tower
- type: custom:plotly-graph
title: PV, Netz & Batterie 24h
hours_to_show: 24
refresh_interval: 60
layout:
height: 300
showlegend: true
legend:
orientation: h
y: -0.2
margin:
t: 20
b: 50
l: 60
r: 20
xaxis:
title: Zeit
yaxis:
title: Leistung (W)
entities:
- entity: sensor.productionactivepower
name: PV-Produktion
line:
color: '#FFC107'
width: 2
fill: tozeroy
fillcolor: 'rgba(255, 193, 7, 0.2)'
- entity: sensor.gridactivepower
name: Netzbezug
line:
color: '#F44336'
width: 2
- entity: sensor.essactivepower
name: Batterie
line:
color: '#4CAF50'
width: 2
# ===================================================================
# SECTION 7: PLAN-STATISTIKEN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Plan-Statistiken
icon: mdi:chart-box
- type: markdown
content: |
{% set attrs = state_attr('pyscript.battery_charging_schedule', 'schedule') %}
{% set num_charges = state_attr('pyscript.battery_charging_schedule', 'num_charges') or 0 %}
{% set total_energy = state_attr('pyscript.battery_charging_schedule', 'total_energy_kwh') or 0 %}
{% set avg_price = state_attr('pyscript.battery_charging_schedule', 'avg_charge_price') or 0 %}
{% set num_tomorrow = state_attr('pyscript.battery_charging_schedule', 'num_charges_tomorrow') or 0 %}
| Metrik | Wert |
|--------|------|
| 🕐 **Geplante Ladungen** | {{ num_charges }} Stunden |
| ⚡ **Gesamt-Energie** | {{ total_energy | round(1) }} kWh |
| 💶 **Durchschnittspreis** | {{ avg_price | round(2) }} ct/kWh |
| 📅 **Davon Morgen** | {{ num_tomorrow }} Ladungen |
# ===================================================================
# SECTION 8: DETAILLIERTE PLAN-TABELLE
# ===================================================================
- type: grid
cards:
- type: heading
heading: Stunden-Details
icon: mdi:table-large
- type: markdown
title: Vollständiger Ladeplan
content: |
{% set schedule = state_attr('pyscript.battery_charging_schedule', 'schedule') %}
{% if schedule %}
| Zeit | Aktion | Leistung | Preis | Grund |
|------|--------|----------|-------|-------|
{% for slot in schedule[:20] %}
| {{ slot.datetime[11:16] }} | {{ '🔋 Laden' if slot.action == 'charge' else '⏸️ Auto' }} | {{ slot.power_w if slot.power_w else '-' }}W | {{ slot.price }}ct | {{ slot.reason }} |
{% endfor %}
{% else %}
⚠️ **Kein Ladeplan verfügbar**
Der Plan wird täglich um 14:05 Uhr neu berechnet.
{% endif %}
# ===================================================================
# SECTION 9: ALLE EINSTELLUNGEN
# ===================================================================
- type: grid
cards:
- type: heading
heading: Alle Einstellungen
icon: mdi:cog-outline
- type: entities
title: Batterie-Parameter
entities:
- entity: input_number.battery_optimizer_min_soc
name: Minimaler SOC (%)
- entity: input_number.battery_optimizer_max_soc
name: Maximaler SOC (%)
- entity: input_number.battery_optimizer_max_charge_power
name: Ladeleistung (W)
- entity: input_number.battery_optimizer_reserve_capacity
name: Reserve-Kapazität (kWh)
- entity: input_number.battery_optimizer_price_threshold
name: Preis-Schwelle (ct/kWh)
# ===================================================================
# SECTION 10: SYSTEM-INFORMATIONEN
# ===================================================================
- type: grid
cards:
- type: heading
heading: System-Status
icon: mdi:information-outline
- type: markdown
content: |
**System-Informationen:**
**Batterie:**
- Kapazität: {{ states('input_number.battery_capacity_kwh') }} kWh
- Aktueller SOC: {{ states('sensor.esssoc') }}%
- Leistung: {{ states('sensor.essactivepower') }}W
**PV-Prognose:**
- Heute Ost: {{ states('sensor.energy_production_today') }} kWh
- Heute West: {{ states('sensor.energy_production_today_2') }} kWh
- Morgen Ost: {{ states('sensor.energy_production_tomorrow') }} kWh
- Morgen West: {{ states('sensor.energy_production_tomorrow_2') }} kWh
**Optimizer Status:**
- Aktiviert: {{ states('input_boolean.battery_optimizer_enabled') }}
- Manueller Modus: {{ states('input_boolean.goodwe_manual_control') }}
- Letztes Update: {{ state_attr('pyscript.battery_charging_schedule', 'last_update')[:16] if state_attr('pyscript.battery_charging_schedule', 'last_update') else 'Unbekannt' }}
**PyScript Trigger:**
- Tägliche Berechnung: 14:05 Uhr
- Stündliche Ausführung: xx:05 Uhr