Update: Battery Optimizer v3.4.0 mit allen Fixes und Features
This commit is contained in:
26
project_memory.md
Normal file
26
project_memory.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## Purpose & context
|
||||
Felix is developing an advanced Home Assistant battery optimization system for his residential energy setup, which includes a 10 kWh GoodWe battery, 10 kW inverter, and 9.2 kWp PV installation split between east and west orientations on a flat roof. The system integrates with OpenEMS energy management software running on a BeagleBone single-board computer, using dynamic electricity pricing from haStrom FLEX PRO tariff and Forecast.Solar for PV predictions. The primary goal is intelligent automated battery charging that schedules charging during the cheapest electricity price periods while considering solar forecasts and maintaining optimal battery management.
|
||||
The project represents a sophisticated energy optimization approach that goes beyond simple time-of-use scheduling, incorporating real-time pricing data (available daily at 14:00 for next-day optimization), weather forecasting, and cross-midnight optimization capabilities. Felix has demonstrated strong technical expertise throughout the development process, providing corrections and improvements to initial implementations, and has expressed interest in eventually sharing this project with the Home Assistant community.
|
||||
|
||||
## Current state
|
||||
The battery optimization system is operational with comprehensive PyScript-based automation that calculates daily charging schedules at 14:05 and executes hourly at xx:05. The system successfully integrates multiple data sources: haStrom FLEX PRO API for dynamic pricing, Forecast.Solar for PV forecasting, and OpenEMS Modbus sensors for battery monitoring. Recent work focused on dashboard optimization, moving from cluttered multi-column layouts to clean 4-column maximum designs using both traditional Home Assistant layouts and modern sections-based approaches.
|
||||
Key technical challenges have been resolved, including timezone mismatches between PyScript's UTC datetime handling and local German time storage, proper Modbus communication with FLOAT32 register handling, and controller priority conflicts in OpenEMS where balancing controllers were overriding manual charging commands. The system now uses proven manual control infrastructure with three existing automations for battery control via Modbus communication, switching between REMOTE and INTERNAL ESS modes as needed.
|
||||
|
||||
## On the horizon
|
||||
Felix is working on dashboard refinements using the new Home Assistant Sections layout, which represents the modern standard for dashboard creation in Home Assistant 2024.2+. The sections-based approach provides better organization and automatic responsive behavior compared to traditional horizontal/vertical stack configurations. Multiple dashboard variants have been created with different complexity levels to accommodate various use cases from quick status checks to detailed analysis.
|
||||
Future considerations include expanding the optimization algorithm's sophistication and potentially integrating additional data sources or control mechanisms. The system architecture is designed to be extensible, with clear separation between optimization logic, data collection, and execution components.
|
||||
|
||||
## Key learnings & principles
|
||||
Critical technical insights emerged around OpenEMS controller priority and execution order. The system uses alphabetical scheduling where controllers execute in sequence, and later controllers can override earlier ones. Manual battery control requires careful attention to controller hierarchy - using ctrlBalancing0's SET_GRID_ACTIVE_POWER channel provides highest priority and prevents override by other controllers, while direct ESS register writes can be overridden by subsequent controller execution.
|
||||
PyScript integration has specific limitations that require workarounds: generator expressions and list comprehensions with selectattr() are not supported and must be replaced with explicit for loops. Home Assistant state attributes can store unlimited JSON data while state values are limited to 255 characters, making attributes ideal for complex scheduling data storage.
|
||||
Timezone handling requires careful consideration when mixing PyScript's UTC datetime.now() with local time storage. The haStrom FLEX PRO API uses different field names (t_price_has_pro_incl_vat) than standard endpoints and supports efficient date range queries for multi-day optimization across midnight boundaries.
|
||||
|
||||
## Approach & patterns
|
||||
The system follows a conservative optimization strategy, charging only during the cheapest price periods while maintaining battery SOC between 20-100% with a 2 kWh reserve for self-consumption. The optimization algorithm uses ranking-based selection rather than threshold-based approaches, calculating needed charging hours based on battery capacity and selecting the N cheapest hours from combined today-plus-tomorrow datasets.
|
||||
Development follows a systematic troubleshooting approach with comprehensive logging and debugging capabilities. Felix emphasizes transparent operation where the system can verify planned versus actual charging execution. The architecture separates concerns cleanly: PyScript handles optimization calculations and scheduling, existing Home Assistant automations manage physical battery control, and Modbus communication provides the interface layer to OpenEMS.
|
||||
Dashboard design prioritizes readability and mobile compatibility with maximum 4-column layouts, using Mushroom Cards and custom components like Bubble Card, Plotly Graph Card, and Power Flow Card Plus for enhanced visualization.
|
||||
|
||||
## Tools & resources
|
||||
The system integrates multiple specialized components: OpenEMS for energy management with GoodWe ESS integration, InfluxDB2 for historical data storage, haStrom FLEX PRO API for dynamic electricity pricing, and Forecast.Solar for PV generation forecasting. Home Assistant serves as the central automation platform with PyScript for complex logic implementation.
|
||||
Technical infrastructure includes Modbus TCP communication on port 502 (IP 192.168.89.144), OpenEMS JSON-RPC API on port 8074 for ESS mode switching, and proper IEEE 754 FLOAT32 encoding for register value conversion. The system uses HACS custom components including Bubble Card, Plotly Graph Card, Power Flow Card Plus, and Stack-in-Card for enhanced dashboard functionality.
|
||||
Development tools include Python-based Modbus register scanning utilities, comprehensive logging systems for debugging controller execution, and Excel exports from OpenEMS for register mapping verification.
|
||||
Reference in New Issue
Block a user