Add ML energy consumption predictor (experimental)#34
Add ML energy consumption predictor (experimental)#34pookey wants to merge 2 commits intojohanzander:mainfrom
Conversation
Add home.consumption_strategy setting with three modes: - "sensor" (default): uses HA 48h average sensor as before - "fixed": flat rate from config.yaml consumption value - "influxdb_7d_avg": 7-day rolling average from InfluxDB power sensor data at 15-minute resolution The influxdb_7d_avg strategy queries local_load_power sensor data for the past 7 days, averages per 15-minute period, and produces a 96-value consumption profile that reflects actual household usage patterns including weekday/weekend variation. Also adds home.timezone setting and prediction caching to avoid redundant InfluxDB queries during logging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ml_prediction consumption strategy using XGBoost to generate 96 quarter-hourly energy consumption forecasts. The model trains on InfluxDB historical data with weather forecast features from Home Assistant and retrains daily at 23:00. Includes: - ML module (ml/) with trainer, predictor, data_fetcher, config - ML Report dashboard page showing model metrics, feature importance, and forecast comparison - /api/ml-report endpoint - Docker base image switch to Debian Bookworm for xgboost/sklearn - Daily retrain scheduler in app.py The ML predictor is experimental — the influxdb_7d_avg strategy is recommended for production use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Been thinking about this. I've been thinking about adding some ML for energy consumption prediction but never prioritized it because the 48h average sensor works good enough for me. I also have a heat pump and EV charger that makes prediction on a more granular level difficult I believe. But nevertheless would be great to get this working and for me to learn about ML. But what do you think, would you be open to create a separate HA AddOn for this? then that could serve as another configurable consumption strategy option... |
So far, it's been trash and after 8 days of training data, the 'weekly average' is working better for me (the other PR - that's probably good for merge BTW). I think the ML stuff currently falls into the 'cool experiment, but probably not useful' category! I hadn't seen Theria) - and I was considering doing something really similar myself! Maybe I need to hop over onto that project too and have a play! Does it support a single temperature zone? |
|
The Theria project is in a really early experiemental stage and I ran into real physical constraint wrt. my heating system which made progressing any optimization kind of useless. And there is no or little intelligence yet, it only gathers / visualizes temperature for a set of configurable zones. so im not sure you will find anything useful there, but Im sure with Claude Code you could build something useful on top of it... |
|
the other PR - that's probably good for merge BTW - here you mean #33? |
Summary
Adds an optional
ml_predictionconsumption strategy using XGBoost to predict 24h energy consumption at 15-minute resolution. Depends on #33 (configurable consumption strategies).What's included
ml/) with training, prediction, feature engineering, and standalone CLI/api/ml-reportendpoint for the dashboardHonest assessment
This is experimental. In my testing so far, the ML predictions are roughly on par with or slightly worse than the simpler
influxdb_7d_avgstrategy from #33. The model also:That said, it's a fun playground for experimenting with consumption prediction, and the ML Report page gives good visibility into how well (or poorly) the model performs compared to baselines.
I'd completely understand if this isn't something that belongs in core. The
influxdb_7d_avgstrategy in #33 is more practical for production use.Config example
Test plan
mlconfig is presentml_predictionstrategy produces 96-period forecastfixedwhenmlconfig section is missingmlsection is absent (no ML features loaded)