This repo contains the output of team section77 at the #blackforesthackathon in May 2025 in Freiburg. The chosen challenge was BalkonSolar: "Optimizing Small-Scale Storage and Plug-In Solar for Grid Stability and Cost Savings"
🔍 Problem Statement: Small-scale battery storage for plug-in solar systems is not optimized for grid demand. Users charge batteries based on electricity prices rather than grid conditions, possibly overloading the grid at peak solar production times while missing opportunities to use excess renewable energy. There are no dynamic incentives for prosumers to adjust their energy use, leading to inefficiencies in balancing supply and demand.
🎯 HACKATHON CHALLENGE: How might we develop an innovative solution that helps prosumers (users with solar and storage) optimize their energy consumption and feed-in behavior to support grid stability, reduce CO₂ emissions, and maximize financial benefits?
📊 Available Data & Resources: Real-time electricity prices & grid demand APIs, Weather forecasts for solar power predictions, Battery & inverter data for energy flow insights, Smart home hardware (sockets, sensors, tablets, etc.) for prototyping
🏆 Success Criteria: A successful solution should balance the grid by optimizing consumption and feed-in based on demand, reduce CO₂ impact by using green electricity efficiently, maximize financial benefits for prosumers and be simple, user-friendly, low-cost, open-source, and scalable.
💡 Key Considerations: The solution should prioritize simplicity, low costs, ease of implementation, open-source accessibility, and clear documentation to ensure widespread adoption and usability.
On the basis of readily avaible components (cheap off the shelf hardware like Raspberry Pi, optical readout head, smart sockets, ...) and open source software (HomeAssistant, Tasmota, ...) we have created a solution that tightly integrates into HomeAssistant (HomeAssistant integration) and is easy to install even for a less tech-savy user.
- download HomeAssistant SD card image and install on SD card for Raspberry Pi
- start HomeAssistant and do basic configuration
- install integrations for the components
- Mosquitto MQTT broker
- HACS (HomeAssistant Community Store)
- EcoFlowCloud
- Power Flow Card Plus
- install the integration from the directory
code/custom_components/basosmart-integration/
- install the blueprint
basosmart-blueprint.yaml
- configure and save blueprint and fill in the data:
- PV Peak power of your PV system
- ZIP code of your location
- Latitude of your geo position
- Longitude of your geo position
- Angle at which your PV system is setup
- Alignment of your PV system
- Presentation
- HomeAssistant specific
- how to install integrations
- integration "Forecast.Solar"
- log into HomeAssistant
- Settings
- Devices & services
- Add integration
- Search "Forecast.Solar"
- integration "Python Scripts"
- edit your configuration.yaml
- add "python_script:"
- create the folder /python_scripts
- Create a file /python_scripts/hello_world.py in the folder and give it this content:
# `data` is available as builtin and is a dictionary with the input data. name = data.get("name", "world") # `logger` and `time` are available as builtin without the need of explicit import. logger.info("Hello {} at {}".format(name, time.time()))
- Start Home Assistant to reload the script configuration.
- Call your new python_script.hello_world action (with parameters) from the Actions, using the YAML mode.
action: python_script.hello_world data: name: "Input-Text"
- integration "Forecast.Solar"
- how to generate a long lived access token
- log into HomeAssistant
- click on your profile icon on the bottom left
- click on the tab "Security"
- section: "Long-lived access tokens"
- create token
- how to integrate python scripts into HomeAssistant
- how to install integrations
- Forecast.Solar
- this API gives a region specific prediction of the energy you can expect for the next two days
- battery charing algorithm
- optimized buffer use (to be included in the control): The charging and discharging process should be carried out as follows: At midnight, the battery storage system should be half charged so that it can serve the load until the start of the day. After sunrise, solar production quickly exceeds the load and the storage system, which is empty at this point, is gradually charged. If the daily yield corresponds to the annual average, the battery storage is filled to its capacity limit by the surplus electricity at sunset. On very high-yield days, the additional surplus electricity must be curtailed or utilised elsewhere once the capacity limit is exceeded. After darkness falls, the load is covered by the discharging current. At midnight, the battery is exactly half charged again and the cycle can begin anew. On low-yield days, the battery is only charged to a fraction of its capacity. The daily balance is negative and in this case must be compensated for by residual power plants or load reductions.
- predictions are driven by parameters in sensors (Stromgedach, Forecast.Solar, and Historical Power Consumption*)
- Check balance-sensors.md & see photos/mindmap{1,2,3}.png
-
configuration details for HomeAssistant
- Rasperry Pi
- Radio-controlled sockets
- Optical Readout Head for Smartmeter
- create a more generic solution, that is independent of HomeAssistant
- use APIs that provide a CO2 index and energy flow like
- Grünstromindex(preferred)
- Energy Charts
- Add more sophisticated prediction models e.g. AC charging, forecast with nonlinear-optimization algorithm and intraday optimization.
- access to the ecoflow api not provided
- requires a developer account; activation takes a few days
- registration is tricky (codes valid for 1 minute only, mail takes around 1 minute)
- EcoFlowCloud plugin had a bug, switched over to
v1.3.0-beta4
(the HA interface allows picking betas or any git tag at its '...' menu.) - Password for Wifi Router unknown -> reset password
- Password for HomeAssistant unknown -> reinstall ha os
- Optical readout head (by hichi) configured to only present total energy consumption -> edit script (and provide feedback to hichi, so he can change the default config to be more useful)
- Missing labels on the devices -> a job for EtikettierJuergen: print labels