Skip to main content

SmartBoiler

Intelligent water boiler controller for Home Assistant. Predicts household hot water consumption patterns and schedules heating at the lowest-cost hours — using day-ahead spot electricity prices, photovoltaic surplus, and HDO ripple-control awareness.

Originally developed as a master's thesis at FIT VUT Brno (2024). v2.0 is a complete rewrite: no LSTM, no InfluxDB, no external APIs required beyond HA itself.

GitHub Supports aarch64 Supports amd64


How it works

SmartBoiler runs two parallel workflows inside a Home Assistant add-on:

┌──────────────────────────────────────────────────────┐
│  ForecastWorkflow  (runs every hour)                 │
│                                                      │
│  HA entity history ──► Rolling histogram predictor   │
│  Spot price API    ──► Greedy scheduler              │
│  HDO learner       ──► 24-hour heating plan          │
│  PV surplus        ──►  (persisted to /data/)        │
└──────────────────────────────────────────────────────┘
         │  heating_plan[24]
         ▼
┌──────────────────────────────────────────────────────┐
│  ControlWorkflow   (runs every 60 s)                 │
│                                                      │
│  Read boiler temperature  ◄── 4-level estimator      │
│  Check legionella due?    ◄── every 21 days          │
│  Execute plan hour        ──► turn relay ON / OFF    │
│  Observe HDO patterns     ──► update HDO learner     │
└──────────────────────────────────────────────────────┘

Prediction — Rolling Histogram

Instead of an LSTM network, SmartBoiler uses a per-(weekday, hour) quantile histogram over the last 12 weeks of actual consumption data pulled from HA entity history. This approach:

  • Works from the very first weeks of data (global quantile fallback until enough per-slot samples accumulate)
  • Requires zero GPU, zero model training time
  • Adapts naturally to changing household routines (old data ages out of the 12-week window)
  • Uses p50/p75/p90 quantile — configurable via prediction_conservatism setting

Scheduling — Greedy Cost Minimisation

Every hour gets an effective cost: the real price of one kWh for the heater in that hour, from your tariff (spot + fees, one fixed price, or low/high tariff; see tariff.py). The part covered by PV surplus costs what exporting it would have earned (0 without a feed-in payment).

Step Hours Rule
1 Calendar boost always heat
1 Cost below the cheapest grid hour, or negative (PV surplus, negative prices) always heat — cheaper than anything that could be bought later
2 All other open hours add the cheapest until the minimum temperature holds
✗ HDO relay cut / vacation_off never (cost ∞)

Defaults (spot in EUR, no fees, export earns 0) give the same plan as before tariffs existed.

A standby-loss penalty adjusts the cost of heating early: a slot cheaper by 5 EUR/MWh is only preferred over a later one if that price advantage exceeds the extra energy lost to standing-by while waiting.

Temperature Estimation — 4-Level Fallback

L1  Direct NTC probe inside boiler  (most accurate)
 │  (if entity unavailable)
L2  Power feedback: relay ON + power < 50 W → T = T_set
 │  (relay energised but internal boiler thermostat cut the element — target reached)
 │  (if power > 50 W: actively heating; no inference possible from this level)
L3  Thermal model: Newton's law cooling from case sensor
 │  (if no calibration data yet)
L4  Last known value  (stale — logged as warning)

Real-time solar surplus

With a live grid-export sensor configured, the boiler also follows the real sun: it switches on when the measured export covers at least 80 % of the heater for two minutes, and off when a cloud makes it draw more than half its power from the grid. The day-ahead plan, legionella cycle and calendar events keep priority.

SolaX Cloud

Without a SolaX integration in Home Assistant, SmartBoiler can read battery SoC, solar power and grid power straight from the SolaX Cloud Developer API (Settings → Battery → SolaX Cloud: Client ID and Secret from developer.solaxcloud.com, inverter serial number). HA sensors, when set, take priority. The inverter updates the cloud about every 5 minutes, so a local Modbus integration in HA reacts faster for real-time surplus heating.

How much would it save?

python -m smartboiler.savings replays your own exported history (hot water, PV, prices) through a plain thermostat and the smart scheduler and reports the difference. See docs/SAVINGS.md.

HDO Ripple-Control Learning

Czech/Slovak low-tariff electricity uses an HDO relay that physically disconnects the boiler switch. SmartBoiler detects this automatically: when the switch entity enters the unavailable state in HA it records a blocking observation for that 5-minute slot. After data from ≥ 2 distinct ISO calendar weeks is accumulated, the slot is considered reliably blocked and excluded from scheduling.

An explicit schedule can also be set in configuration (e.g. "22:00-06:00,12:05-13:35").


Requirements

Minimum (no sensors)

Component Purpose
Home Assistant Data source + service calls
Shelly Plus 1PM (or any HA switchable relay) Boiler power control

Without sensors the system can still control heating based on time-of-use tariffs and HDO schedule — just without consumption-aware optimisation.

Component Purpose
NTC thermistor inside boiler casing Direct water temperature reading (L1 estimator)
Power monitoring relay (e.g. Shelly 1PM) Temperature feedback + HDO detection
ESPHome flow meter + outlet thermistor Accurate consumption measurement
PV inverter with HA integration Solar surplus scheduling

See DOCS.md for hardware wiring and ESPHome configuration.


Architecture

See ARCHITECTURE.md for:

  • Full module dependency diagram
  • Dual-workflow timing
  • Prediction pipeline detail
  • Scheduling algorithm walkthrough
  • Savings simulation with real example

Installation

Install via the Home Assistant add-on store:

  1. Add repository https://github.com/grinwi/smartboiler-add-on to HA Add-on Store
  2. Install Smart Boiler
  3. Start the add-on; open the web UI via Open Web UI
  4. Complete the setup wizard (entity pickers, boiler parameters, optional features)
  5. The controller starts automatically once setup is saved

No manual YAML editing required. All configuration is persisted in /data/smartboiler_setup.json inside the add-on container.


Repository structure

smartboiler/
├── src/smartboiler/
│   ├── controller.py          # Main orchestrator (ForecastWorkflow + ControlWorkflow)
│   ├── ha_client.py           # Home Assistant REST API wrapper
│   ├── state_store.py         # Persistent JSON + pickle storage (/data/)
│   ├── predictor.py           # Rolling histogram predictor
│   ├── hdo_learner.py         # HDO ripple-control pattern learner
│   ├── scheduler.py           # Greedy day-ahead heating scheduler
│   ├── spot_price.py          # energy-charts.info day-ahead price fetcher
│   ├── ha_data_collector.py   # Hourly consumption data from HA history
│   ├── temperature_estimator.py  # 4-level water temp estimation
│   ├── thermal_model.py       # Newton's law cooling model (L3 estimator)
│   ├── legionella_protector.py   # Periodic 65 °C safety cycle
│   ├── web_server.py          # Flask dashboard (HA ingress, port 8099)
│   ├── web_routes.py          # Route handlers
│   ├── web_setup.py           # Setup wizard field metadata
│   └── setup_config.py        # Configuration persistence
├── tests/                     # Unit + integration tests
├── README.md                  # This file
├── ARCHITECTURE.md            # Deep-dive with diagrams
└── setup.py

Development

pip install -e smartboiler/
python -m pytest smartboiler/tests/

Entry point (matches the add-on run script):

python -m smartboiler.controller

Metadata

Release files for smartboiler 1.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartboiler 1.7.0
File Size Uploaded Provenance Actions
smartboiler-1.7.0.tar.gz 217.7 kB Without provenance Details for smartboiler-1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smartboiler 1.7.0
File Interpreter ABI Platform Actions
smartboiler-1.7.0-py3-none-any.whl Python 3 none any Details for smartboiler-1.7.0-py3-none-any.whl

Total release size: 365.2 kB

Release files / smartboiler-1.7.0.tar.gz

Download URL smartboiler-1.7.0.tar.gz
Size 217.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1b13e0b11dba7f9b326a49f4caa627a6f74730f09460c9133229eeff5a586c92
BLAKE2b-256 checksum
How to use checksums
85c0b9f499a1243b778c8c3c0ac44ef9df9d5047117a4b82783f184c9ba6ff69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / smartboiler-1.7.0-py3-none-any.whl

Download URL smartboiler-1.7.0-py3-none-any.whl
Size 147.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fef5d411475150dce21e2c97d2cb699957b177f3c55b1caae46d7b1d57ef70af
BLAKE2b-256 checksum
How to use checksums
da612b390cd7f3d7b53335d57e4468e49a0edc7ff530fd45be4cea5287f08768
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for smartboiler 1.7.0

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.

Release history Release notifications | RSS feed

This release

1.7.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page