Metadata-Version: 2.4
Name: hems
Version: 0.2.0
Summary: An OUTUS v1 engine: plans, the usage ledger, dynamic prices and explainable bills; battery wear, forecasts and HEMS loads
License-Expression: MIT
Project-URL: Homepage, https://github.com/david2069/hems
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tzdata
Provides-Extra: schema
Requires-Dist: jsonschema>=4.18; extra == "schema"
Requires-Dist: referencing; extra == "schema"
Requires-Dist: rfc3339-validator; extra == "schema"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: jsonschema>=4.18; extra == "test"
Requires-Dist: referencing; extra == "test"
Requires-Dist: rfc3339-validator; extra == "test"
Dynamic: license-file

# hems

An engine for [OUTUS](https://github.com/david2069/outus), the Open Utility Tariff & Usage
Specification. It reads OUTUS plans and price series, keeps the usage ledger, and writes
OUTUS bills with every line explained.

- **Implements:** OUTUS v1 (electricity). The spec is published separately; hems is one
  implementation of it.
- **Python ≥ 3.11, no I/O.** One dependency, `tzdata`, so time zones work on any image.
  Callers supply readings, prices and the plan, and store the results. I/O adapters (such as
  Open-Meteo) are separate modules under `hems.adapters`.
- **Used by:** the FranklinWH Direct Connect and Modbus bridges.

| Module | Job |
|---|---|
| `hems.ledger` | grid readings from the devices behind a meter → 5-minute usage intervals |
| `hems.prices` | a price series: price at an interval's start, later kinds replace earlier ones |
| `hems.billing` | an OUTUS bill from a plan and the ledger, with formulas; provisional bills project to the period's end; `now_rates` for the live band and rate |
| `hems.periods` | billing period bounds (monthly, bimonthly, quarterly) |
| `hems.plans` | checks a schema can't express (overlapping plans, wrong charge class, unpriced gaps) |
| `hems.setup` | setup steps in order: site → meter → plan → tariffs |
| `hems.profile_v1` | imports a `franklinwh-bridge/tariff-profile` v1 file as an OUTUS plan |
| `hems.wear` | battery wear: warranty setup fields, wear cost per kWh, throughput pace budget, dispatch events, round-trip efficiency from SoC-matched cycles |
| `hems.forecast` | solar (irradiance × kWp, cell temperature, self-calibration), the load model (calendar × season, comfort band, cold start), battery temperature limit, walk-forward backtest, HAEO publishing |
| `hems.loads` | HEMS setup: always-on load and usage periods to confirm, heavy loads and EV charger checked against capabilities, expected hours, soak trigger |
| `hems.adapters.open_meteo` | Open-Meteo forecast and archive: irradiance and temperature rows (does network I/O) |

```
pip install -e ".[test]"
pytest
```

The tests check every bill hems writes against the OUTUS v1 schemas, copied in
`tests/outus-v1/`.

## Licence
MIT
