microgrid
microgrid is a library that models a solar + battery plant (microgrid.plant) and
produces marginal energy prices from it (microgrid.engine): what one more kWh
costs, slot by slot over a horizon, and the value of energy by source.
You describe the plant (plant/2: PV of either coupling, a battery on its own inverter
or on a hybrid's DC bus, loads on either bus, the grid's limits and charge windows) and
give it its inputs as time series (prices, PV and load forecasts, the meters); it returns
prices, regimes, certainties and surplus for each slot.
The documentation is in docs/,
published with each release at https://eman.github.io/microgrid/:
how the prices are made, the concepts, how-to guides and the reference.
Install
pip install microgrid # or: uv add microgrid
pip install "microgrid[sources]" # with the readers of live sources (Home Assistant)
Python 3.14 or later. Before 1.0 a minor release may change a format, the API or the
model: pin the minor release you tested with (microgrid ~= 0.1.0,
Versions).
The command
microgrid (microgrid.cli, installed with the library) runs it on a dataset
(dataset/1: a directory of series and the plant's and engine's files), so it needs no
plant at hand. The example
dataset (examples/dataset) is one synthetic week of the library's example plant in
Europe/Berlin, the DST change on 2026-10-25 inside it:
uv run microgrid value --data examples/dataset --at 2026-10-22T13:00 # one valuation
uv run microgrid live --data examples/dataset --from 2026-10-22T06:00 --to 2026-10-22T20:00
uv run microgrid replay --data examples/dataset --from 2026-10-22 --to 2026-10-25
# valuations scored against the meters
uv run microgrid check-plant --data examples/dataset --from 2026-10-21 --to 2026-10-27
# the plant model against its meters
uv run microgrid ledger --data examples/dataset --from 2026-10-21 --to 2026-10-27
# the battery's lots and their cost split
uv run microgrid fit-battery --data examples/dataset --end 2026-10-28 --days 7
# the battery's conversion, fitted
uv run microgrid config check --data examples/dataset # its plant/2 and engine/2
uv run microgrid schema # the outputs' schema
With a sources/1 file naming a provider per input (any of several, none assumed; the
sources extra, microgrid[sources]), it reads live inputs instead of a dataset:
uv run microgrid sources --sources sources.toml # what each input is read from, or why not
uv run microgrid now --sources sources.toml # a valuation now; --save DIR keeps the inputs
uv run microgrid fetch --sources sources.toml --from 2026-10-01 --to 2026-10-08 --out DIR
# what was measured, as a dataset
A time without an offset is the plant's local time (an hour that repeats, the first time; one the clocks skip is refused).
Development
Python 3.14, uv. See AGENTS.md for the rules and conventions.
uv sync # .venv with the library and the dev tools
scripts/install-hooks.sh # pre-push runs the local gate
scripts/ci_local.sh # ruff, format, mypy --strict, the docs, pytest + coverage
License
MIT: see LICENSE.
Metadata
Release files for microgrid 0.1.3
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 |
|---|---|---|---|---|
| microgrid-0.1.3.tar.gz | 448.9 kB | Without provenance | Details for microgrid-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| microgrid-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for microgrid-0.1.3-py3-none-any.whl |
Total release size: 672.2 kB
Release files / microgrid-0.1.3.tar.gz
| Download URL | microgrid-0.1.3.tar.gz |
|---|---|
| Size | 448.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b14ff3846fc14d88e8a70e8ce505a44b36a00c779d7543d83a319645b132936c
|
|
BLAKE2b-256 checksum How to use checksums |
90c613194ca960a454fa9b98baf6646bf1bef9ce5918ffdf1be10f15f196ed41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / microgrid-0.1.3-py3-none-any.whl
| Download URL | microgrid-0.1.3-py3-none-any.whl |
|---|---|
| Size | 223.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
768d3dbb0560f25d01b973c47679123b1296c0902f785a1a6ddaeb5f2dda567d
|
|
BLAKE2b-256 checksum How to use checksums |
65c5a2d47037adf616360b5d87e52b86fc44209befc30942a94e6e06c5392d4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for microgrid 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.