A deterministic Home Assistant custom integration for optimising Tesla Powerwall battery usage. Uses a Linear Programming solver to minimise daily electricity costs based on real-time Amber Electric or Flow Power spot pricing, Solcast or forecast.solar solar forecasts, and historical load patterns.
FlowPower Pricing, Manual Control, Plan Graphs, Import Price Limit, Export Priority Threshold.
Every 5 minutes, HBC collects your current energy tariffs, solar production forecast, and household load history. It feeds this data into an LP solver that calculates the mathematically optimal battery charge/discharge schedule for the next 24 hours, then sends the appropriate command to your Powerwall.
| Requirement | Purpose | Integration |
|---|---|---|
| Home Assistant 2024.1+ | Platform | — |
| HACS | Installation | hacs.xyz |
| Amber Electric | 5-minute spot pricing (Supports Standard & Amber Express) | Amber Electric |
| FlowPower HA | 5-minute spot pricing | FlowPower HACS |
| Solcast | Solar production forecast | Solcast HACS |
| Tesla Powerwall | Battery control | Teslemetry or similar |
| Weather | Temperature forecast (optional) | Any HA weather entity |
- Open HACS in Home Assistant
- Click the ⋮ menu → Custom repositories
- Add:
https://github.com/dw0011/home-battery-control(Category: Integration) - Search for House Battery Control and click Download
- Restart Home Assistant
- Go to Settings → Devices & Services → Add Integration → House Battery Control
cp -r custom_components/house_battery_control /config/custom_components/
ha core restartThe integration uses a 3-step config flow. For full details on every field, see docs/configuration.md.
| Step | What You Configure |
|---|---|
| 1. Telemetry | Battery SoC, Battery Power, Solar Power, Grid Power sensors (with inversion options) |
| 2. Energy & Metrics | Cumulative energy sensors, temperature thresholds, battery specs, tariff & weather entities |
| 3. Control | Charge/discharge scripts, panel visibility toggle |
You can also configure via YAML import on Step 1.
After configuration:
- Sidebar — Look for the HBC entry (battery icon) in the sidebar
- Panel — Click it to see the power flow diagram and system status
- Sensors — Check Settings → Devices → House Battery Control for
sensor.hbc_stateandsensor.hbc_projected_cost - API — Visit
/hbc/api/status(requires admin auth) for full diagnostic JSON
| Document | Description |
|---|---|
| Configuration Reference | Every config option explained |
| How It Works | Data pipeline, solver objectives, I/O detail |
| Troubleshooting | Common issues and fixes |
| Architecture | Module map and contributor guide |
pip install -r requirements_test.txt
python -m pytest tests/ -v # 213 tests
ruff check custom_components/ tests/


