HEMM — Distributed Energy Optimizer for Home Automation
Beta. The manifest schema is stable (existing manifests validate unchanged); the constraint vocabulary may still gain types and the solver interface may refine before 1.0. Contributions and code reviews are welcome.
Home Assistant users: see ha-hemm for the HA integration. This repository is the core Python library — no HA dependency, standalone testable.
HEMM optimizes energy consumption across heterogeneous home devices (PV, battery, heat pump, EV charger, hot water) using declarative device manifests and MILP optimization. Each device declares its constraints, cost function, and actions in a JSON manifest; the solver compiles every manifest down to a handful of physics primitives and produces 24-hour power plans in 15-minute slots. Adding a new device type is a manifest, not a code change.
Developer Quick Start
uv venv
uv pip install -e ".[dev]"
make test # unit tests
make ci # lint + type check + test
hemm --help
hemm schema # list manifest types
hemm validate <manifest.json>
hemm sim run <scenario.yaml>
hemm sim compare <scenario_a.yaml> <scenario_b.yaml>
Development Setup
HEMM is developed alongside ha-hemm, the Home Assistant integration. Both repos live under one parent directory:
~/dev/hemm/
├── hemm/ # this repo (core library, PyPI package)
└── ha-hemm/ # HA custom component
The integration uses an editable install of the core during development:
cd ha-hemm
uv pip install -e ../hemm
Architecture
- Declarative manifests — devices describe themselves via a versioned JSON schema (constraints, cost functions, efficiency maps, actuator contracts with expected-outcome verification).
- Primitive component model — every manifest compiles (
to_components()) to a small, fixed set of physics primitives: source, sink, storage, converter, node. The solvers build from these primitives, never from device types, so teaching HEMM a new device means writing a manifest that composes existing primitives — not editing a solver. Apool_pump, for example, plans correctly with zero lines changed in either solver file. - Control classes — each manifest declares
control_class(planned / reactive / passive). Planned devices get full 15-min scheduling; reactive devices follow second-by-second setpoints; passive devices are monitored but never actuated. - Reason annotation — every plan slot carries a
reasonfield (pv_surplus,cheap_grid,constraint,idle,manual,safety_default) explaining why the solver chose that power level. - Two backends, one contract — a central MILP (Pyomo + HiGHS; the default, provably optimal) and a distributed price-iteration backend. Both read the same manifests and build from the same primitives, so device knowledge lives in the manifest layer rather than in either solver — the second backend adds little to maintain. On the standard scenarios the distributed backend now tracks the optimal plan within ~1.2% average cost and converges on all of them; the MILP stays the default because it is exact. See solver-decision for the A/B gate.
- Forecast adapters — pluggable sources for PV and price forecasts (Solcast, Forecast.Solar, template fallback).
- Simulation harness — run scenarios against historical data, compare solver backends, generate Markdown reports.
- No vendor knowledge in core — device quirks belong in HA automations, not here.
Testing
The test suite has 350+ tests across three levels:
- Unit tests cover manifest schema, constraint vocabulary, solver correctness, and forecast adapters. Run with
make testin under 60 seconds. - Slow tests (
-m slow) run multi-day simulations and A/B comparisons between solver backends. - Onboarding scenario tests (
tests/test_onboarding_examples.py) verify that the canonical worked examples in the ha-hemm onboarding guide solve correctly on every commit. If these tests pass, the guide is accurate.
CI runs on Python 3.12 and 3.13 on every push.
Contributing
Issues, pull requests, and code reviews are welcome. The project is in early-access beta — feedback on the manifest schema and constraint vocabulary is particularly useful because those are the interfaces that future manifest types and the HA integration depend on.
See CONTRIBUTING.md for workflow details.
License
MIT
Metadata
Release files for hemm 2026.7.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 |
|---|---|---|---|---|
| hemm-2026.7.3.tar.gz | 279.9 kB | With provenance | Details for hemm-2026.7.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hemm-2026.7.3-py3-none-any.whl | Python 3 | none | any | Details for hemm-2026.7.3-py3-none-any.whl |
Total release size: 349.8 kB
Release files / hemm-2026.7.3.tar.gz
| Download URL | hemm-2026.7.3.tar.gz |
|---|---|
| Size | 279.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a850b056ad8fac899a945741618b33d53886ade2a418dd8e6b38e40c14c6e40c
|
|
BLAKE2b-256 checksum How to use checksums |
2647d7798c6e1c94ec84c97700c62826fc0de3cfe611654b35926fb46e416f1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 16, 2026.
Transparency logRelease files / hemm-2026.7.3-py3-none-any.whl
| Download URL | hemm-2026.7.3-py3-none-any.whl |
|---|---|
| Size | 70.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14538875c6184b0a33c1cd880064247eda3bc7a824ae2a4b58e856a5e411eeae
|
|
BLAKE2b-256 checksum How to use checksums |
dfe53c0929d08c6ff9f07c323a29ed2a81043eaf48e6d95f250f5c04a96ff4ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 16, 2026.
Transparency logSecurity for hemm 2026.7.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hemm-2026.7.3.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 Jul 16, 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.