Quick overview:
goodwe-manager.mp4
- Create venv
python3 -m venv venvand activate it. venv/bin/activate - Install dependencies
pip install -r requirements.txt - Copy
.env.exampleto.envand fill in the values - Replace the rest of
poor-man's configinmain.py - Run with
python main.py(TODO: instructions for gunicorn) - Run with
--dry-runparameter to disable communication with the inverter (used for testing)
Data is pulled every few seconds from the inverter in the local network using the Goodwe API
and streaming data to the frontend using Server Sent Events (SSE) for real-time updates.
Data is written into data-xxxx-xx-xx_xx-xx-xx.csv files and can be processed later by some scripts calculating the cost savings
(planned to save it into SQLite in the future).
Scripts starting from underscore _ are not used by the main application, they are some drafts, experiments or utils.
Dates for script input can be specified in formats: YYYY-MM-DD or DD.MM.YYYY.
There are a lot of poor-man's solutions, quick hacks and bad conventions in the code that should be fixed. Some of them include:
- mixing async (Goodwe API) and sync (Flask) code - async code runs in a separate thread, this might cause unexpected problems, although a special care has been taken to ensure proper synchronization between them and finalizing on exit - a solution would be to use an alternative to Flask that supports async (and also supports Server Sent Events)
- RCE price chart is generated as a PNG image by matplotlib - it should be generated on the client side using JS
- current hour import/export energy is not persisted across service restarts
- PV forecast assumes that there are two PV strings with the same peak power and tilt but with a different orientation angle (basically east-west configuration) and that logic is quite hard-coded even though it looks like it's configurable
- too much code in main.py - needs to be extracted for readability and maintainability
- Jinja templates use a lot of code repetition - needs to extract meta-templates and macros
TODO: instructions for running as a linux service