Solar Forecast LangGraph
LangGraph workflow for solar forecasting with:
- Weather data agent — OpenMeteo API (free, no key required)
- Historical generation loader — From inverter-monitoring webhook
- Panel configuration schema — Azimuth, tilt, capacity, losses
- Forecast model — Physical (clear-sky + clouds) + Statistical (ML) + LLM reasoning
- Inverter-control integration — Pre-charge battery before cloudy periods
- Accuracy tracking — Feedback loop for continuous improvement
Release process
See the release strategy for validation, nightly, beta, RC and stable promotion rules, and the operator runbook for local commands.
Architecture
graph TD
A[User Request] --> B[LangGraph Workflow]
B --> C[Fetch Weather<br/>OpenMeteo API]
B --> D[Fetch History<br/>inverter-monitoring]
C --> E[Train Statistical Model]
D --> E
E --> F[Generate Forecast<br/>Physical + Statistical Ensemble]
F --> G[LLM Enhancement<br/>Weather pattern analysis]
G --> H[Inverter-Control Hook<br/>Pre-charge decision]
H --> I[Final Forecast Output]
I --> J[Accuracy Tracking<br/>Feedback Loop]
J -.-> K[Model Retraining - Scheduler]
subgraph "Data Sources"
C
D
end
subgraph "Models"
E
F
G
end
subgraph "Integrations"
H
end
Installation
From PyPI (recommended)
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install from PyPI
pip install solar-forecast-langgraph
After installing, check the CLI is available:
solar-forecast --help
From source (for development)
git clone git@github.com:4alvit/solar-forecast-langgraph.git
cd solar-forecast-langgraph
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install
Quick Start
# Copy example config and customize
cp site_config.example.py site_config.local.py
# Edit site_config.local.py with your panel details
# Run forecast (48h horizon, 30 days history)
solar-forecast --config site_config.local.py --horizon 48 --output forecast.json
Output example:
Forecast Summary:
Site: my-solar-site
Panel: south-roof
Method: ensemble
Horizon: 48 hours
Total Energy: 42500 Wh
Generated: 2024-01-15T10:30:00+00:00
Next 12 hours:
2024-01-15 11:00: 1200W (1200Wh) [960-1440]
2024-01-15 12:00: 2800W (2800Wh) [2240-3360]
2024-01-15 13:00: 3500W (3500Wh) [2800-4200]
Configuration
Panel Configuration
from solar_forecast.config import PanelConfig, SiteConfig
panel = PanelConfig(
name="South Roof",
panel_id="south-roof",
azimuth=180, # 0=N, 90=E, 180=S, 270=W
tilt=35, # Degrees from horizontal
capacity_kw=5.0, # DC capacity
module_count=14,
latitude=52.37,
longitude=4.90,
# Optional losses
shading_loss=0.0,
soiling_loss=0.02,
wiring_loss=0.01,
module_efficiency=0.20,
temperature_coefficient=-0.0035,
inverter_efficiency=0.96,
dc_ac_ratio=1.2,
)
site = SiteConfig(
site_name="my-site",
latitude=52.37,
longitude=4.90,
timezone="Europe/Amsterdam",
panels=[panel],
)
See site_config.example.py for full example.
Forecast Methods
| Method | Description | Use Case |
|---|---|---|
physical |
Clear-sky model + cloud adjustment | No historical data |
statistical |
ML model on historical data | Sufficient history (30+ days) |
ensemble |
Weighted: 60% physical + 40% statistical | Default, best accuracy |
llm_enhanced |
LLM analyzes weather patterns | Future: complex weather |
Inverter-Control Integration
The workflow publishes forecast data and pre-charge requests to the Cerbo GX MQTT broker (Venus OS N/ namespace):
sequenceDiagram
participant WF as LangGraph Workflow
participant FC as Forecast
participant CB as Cerbo GX MQTT
participant IC as Inverter-Control
WF->>FC: Generate 48h forecast
FC->>WF: Forecast points with confidence
WF->>CB: Publish solar_forecast/{site}/forecast_json (retain=True)
WF->>WF: After 00:01 local, compare today's calendar-day kWh to threshold
alt Low generation (< threshold for today)
WF->>CB: Publish solar_forecast/{site}/pre_charge_request (retain=False)
Note over CB,IC: Delivery adapter and controller safety policy must be configured separately
end
Topics published:
The workflow suppresses pre-charge when there are no points for the panel's current local calendar day; it still publishes the available daily summary. A present zero-generation forecast remains distinct from missing data. MQTT publication alone does not prove controller delivery or physical charging. Repeated workflow runs can publish repeated requests: the integration must establish deduplication and an actuator-side safety gate before enabling automatic charging. This workflow does not provide that end-to-end guarantee.
| Topic | retain | Payload |
|---|---|---|
solar_forecast/{site_id}/forecast_json |
True | Daily kWh summary (today_kwh, tomorrow_kwh) |
solar_forecast/{site_id}/pre_charge_request |
False | Pre-charge trigger for low today forecast (horizon_hours=24, day=today) |
Environment variables:
INVERTER_CONTROL_ENABLED=true # Enable the hook
MQTT_BROKER=localhost # Cerbo GX MQTT broker host
MQTT_PORT=1883 # MQTT port
SITE_ID=default # Site identifier used in topic paths
PRE_CHARGE_THRESHOLD_WH=6000 # Pre-charge if today's calendar-day forecast < this (Wh)
TOU_EXPENSIVE_START_HOUR=22 # Optional: suppress pre-charge during expensive grid window
TOU_EXPENSIVE_END_HOUR=6
The expensive tariff window uses the selected panel's timezone, including its
daylight-saving rules. The container's TZ does not change this decision. Start
hours are inclusive and end hours are exclusive; 22 to 6 spans midnight, and
an end hour of 24 ends at midnight. For example, a panel in Europe/Amsterdam
suppresses pre-charge from 22:00 to 06:00 Amsterdam time even when the container
runs in UTC. Forecast publication continues while pre-charge is suppressed.
Accuracy Tracking
Feedback loop for continuous improvement:
graph TD
A[Forecast] --> B[Actual Generation]
B --> C[Error Metrics]
C --> D{Error > Threshold?}
D -->|Yes| E[Flag for Review]
D -->|No| F[Update Training Data]
F --> G[Retrain Model]
E --> H[Human Analysis]
H --> G
Metrics tracked per panel:
- MAE (Mean Absolute Error)
- RMSE (Root Mean Square Error)
- MAPE (Mean Absolute Percentage Error)
- Bias (Systematic over/under prediction)
Development
Run Tests
pytest tests/ -v --cov=solar_forecast
Lint & Format
ruff check .
ruff format .
Type Check
mypy solar_forecast/
Project Structure
solar-forecast-langgraph/
├── solar_forecast/
│ ├── __init__.py # Public exports
│ ├── config.py # Panel/Site configuration schemas
│ ├── weather.py # OpenMeteo client
│ ├── history.py # Historical data loaders
│ ├── model.py # Physical/Statistical/LLM models
│ ├── workflow.py # LangGraph workflow
│ └── main.py # CLI entry point
├── tests/
│ ├── test_config.py
│ ├── test_weather.py
│ ├── test_model.py
│ └── test_workflow.py
├── .github/workflows/ci.yml # CI/CD pipeline
├── pyproject.toml # Package config
├── site_config.example.py # Example configuration
└── README.md
Roadmap
- LLM-enhanced forecasting (weather pattern analysis)
- Automated model retraining scheduler
- Prometheus metrics export
- Grafana dashboard template
- Multi-site support in single workflow
- Battery SoC optimization (not just pre-charge)
- Shadow modeling from 3D terrain
Docker
Multi-arch images (linux/amd64, linux/arm64) publish to GHCR on main, v* tags, and workflow_dispatch:
docker pull ghcr.io/4alvit/solar-forecast-langgraph:latest
After the first publish, set the GHCR package visibility to public (Packages → package settings) so Synology/Portainer can pull without a registry login — same pattern as other public 4alvit images.
Portainer compose should use ghcr.io/4alvit/solar-forecast-langgraph:${IMAGE_TAG:-latest} with pull_image enabled once the package is public.
Related Projects
- inverter-monitoring — Generation data webhook
- inverter-control — Grid-zero feed-in control
License
MIT License — see LICENSE for details.
Metadata
Release files for solar-forecast-langgraph 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solar_forecast_langgraph-0.1.4.tar.gz | 50.7 kB | With provenance | Details for solar_forecast_langgraph-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solar_forecast_langgraph-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for solar_forecast_langgraph-0.1.4-py3-none-any.whl |
Total release size: 80.1 kB
Release files / solar_forecast_langgraph-0.1.4.tar.gz
| Download URL | solar_forecast_langgraph-0.1.4.tar.gz |
|---|---|
| Size | 50.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65445689f693a03649404166fd7b119d96d24cf2acb7782a55836ac4872fa814
|
|
BLAKE2b-256 checksum How to use checksums |
f38cb1877a657e44254952e9a04f44c5a7cce7b2085fd6bb428f74ca23ccdef2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / solar_forecast_langgraph-0.1.4-py3-none-any.whl
| Download URL | solar_forecast_langgraph-0.1.4-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6ece9d36cd3a78535cc73b9eb142e742f823c4264df20984323382a42cd4ca9
|
|
BLAKE2b-256 checksum How to use checksums |
4ea1cc937675361343129b4fefdc6924196e60212b372d18af28e674cac972e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for solar-forecast-langgraph 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for solar_forecast_langgraph-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.