185 calculating price for stored energy in battery and using dynamically for optimization #186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
src/config.pyand documented them insrc/CONFIG_README.mdto 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]BatteryPriceHandlerand integrated it intoBatteryInterfaceto perform historical charging event analysis, attribute energy sources (PV/grid), and calculate the stored energy price using a LIFO model. The handler is initialized inbattery_interface.py, and the price is updated dynamically if enabled. [1] [2] [3] [4]stored_energywith detailed analysis results (price, charging sessions, PV/grid ratio, etc.) in the system state endpoint, and provided a getter method inBatteryInterface. [1] [2] [3]Data Acquisition Enhancements
fetch_historical_energy_datatoLoadInterfaceto support fetching historical energy data from Home Assistant or OpenHAB, enabling the dynamic price calculation logic to retrieve necessary data.Documentation & UI Updates
README.mdandsrc/CONFIG_README.mdto 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]src/web/css/style.cssfor the battery overview dashboard, supporting the display of battery cost analytics and improving mobile responsiveness.Integration & Wiring
load_interfaceandtimezonetoBatteryInterfaceineos_connect.pyto 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.