Skip to main content

Distributed Energy Optimizer for Home Automation

Project description

HEMM — Distributed Energy Optimizer for Home Automation

CI CodeQL Release License Python

Beta. The manifest schema, constraint vocabulary, and solver interface may still change 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; a central solver reads all manifests and produces 24-hour power plans in 15-minute slots.

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). The solver has no device-specific code.
  • 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 reason field (pv_surplus, cheap_grid, constraint, idle, manual, safety_default) explaining why the solver chose that power level.
  • Two solver backends — Central MILP (Pyomo + HiGHS, default) and distributed optimization (experimental, price iteration / ADMM). Both read identical manifests.
  • 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 260+ tests across three levels:

  • Unit tests cover manifest schema, constraint vocabulary, solver correctness, and forecast adapters. Run with make test in 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hemm-2026.5.2.tar.gz (134.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hemm-2026.5.2-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file hemm-2026.5.2.tar.gz.

File metadata

  • Download URL: hemm-2026.5.2.tar.gz
  • Upload date:
  • Size: 134.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hemm-2026.5.2.tar.gz
Algorithm Hash digest
SHA256 3c7ad40bf5d4fca690a9a7d7a9b3d26966d870ae123365032a82b47059bfa12b
MD5 aea0ad93e4571ee838abab9b3e426e39
BLAKE2b-256 bf82e58519f27d3df06445b52b658a2f4eaec45cdbdd3aec3aeb345a7bf61372

See more details on using hashes here.

Provenance

The following attestation bundles were made for hemm-2026.5.2.tar.gz:

Publisher: release.yml on hemm-ems/hemm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hemm-2026.5.2-py3-none-any.whl.

File metadata

  • Download URL: hemm-2026.5.2-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hemm-2026.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6bdf10b2466c95c03deacfbef71b975cfd922b21a628efb5d825db2ab38b2df
MD5 5122d478e275c1a8f89d89f7be029c00
BLAKE2b-256 3535d933232863e2aa0318594960480ba5a34fb8271de879032ef5b449efed59

See more details on using hashes here.

Provenance

The following attestation bundles were made for hemm-2026.5.2-py3-none-any.whl:

Publisher: release.yml on hemm-ems/hemm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page