Skip to content

Conversation

@ohAnd
Copy link
Owner

@ohAnd ohAnd commented Dec 22, 2025

This pull request introduces a comprehensive dynamic battery price calculation feature, including configuration options, backend logic, API extensions, and UI documentation updates. The main goal is to enable EOS Connect to analyze historical charging events and calculate the real cost of energy stored in the battery, using an inventory valuation (LIFO) model. This allows for more accurate optimization decisions and provides detailed battery cost analytics in the dashboard.

Key changes include:

Dynamic Battery Price Calculation: Core Logic & Configuration

  • Added new configuration options in src/config.py and documented them in src/CONFIG_README.md to enable and customize dynamic battery price calculation, including historical lookback, update interval, and relevant sensor/entity IDs. The default config and YAML comments are updated accordingly. [1] [2] [3] [4]
  • Implemented the BatteryPriceHandler and integrated it into BatteryInterface to perform historical charging event analysis, attribute energy sources (PV/grid), and calculate the stored energy price using a LIFO model. The handler is initialized in battery_interface.py, and the price is updated dynamically if enabled. [1] [2] [3] [4]
  • Exposed a new API field stored_energy with detailed analysis results (price, charging sessions, PV/grid ratio, etc.) in the system state endpoint, and provided a getter method in BatteryInterface. [1] [2] [3]

Data Acquisition Enhancements

  • Added a public method fetch_historical_energy_data to LoadInterface to support fetching historical energy data from Home Assistant or OpenHAB, enabling the dynamic price calculation logic to retrieve necessary data.

Documentation & UI Updates

  • Updated README.md and src/CONFIG_README.md to document the new dynamic battery price calculation feature, its configuration, and its impact on the optimizer. Added sections describing the inventory valuation method, dashboard enhancements, and API changes. [1] [2] [3] [4] [5] [6]
  • Added new CSS styles in src/web/css/style.css for the battery overview dashboard, supporting the display of battery cost analytics and improving mobile responsiveness.

Integration & Wiring

  • Passed load_interface and timezone to BatteryInterface in eos_connect.py to facilitate dynamic price calculation.

These changes collectively enable EOS Connect to provide users with actionable insights into the real-time value of their stored battery energy and optimize system behavior based on true storage costs.

@ohAnd ohAnd merged commit f7288a1 into develop Dec 22, 2025
6 checks passed
@ohAnd ohAnd deleted the 185-calculating-price-for-stored-energy-in-battery-and-using-dynamically-for-optimization branch December 22, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants