Self-hosted on Kubernetes with Home Assistant integration -- findings from v0.0.5
Self-hosted on Kubernetes with Home Assistant integration -- findings from v0.0.5
Hi Adrian,
first of all: great project! I'm running EpexPredictor self-hosted on a 3-node RKE2 Kubernetes cluster alongside evcc and Home Assistant. Everything works, the forecast quality looks promising even without ENTSO-E data.
I wanted to share my deployment setup and a few findings that might help other self-hosters.
Setup
- Image:
ghcr.io/b3nn0/epexpredictor:v0.0.5 - Platform: RKE2 (Kubernetes), namespace
evcc - Storage: CephFS 1Gi for
/data/(training cache) - Consumers: evcc (native
epex-predictortemplate) and Home Assistant (REST sensors) - Region: DE, Nordhessen
[screenshot: HA ApexCharts card showing prediction vs evaluation]
Findings for v0.0.5
1. API differences between v0.0.5 and the hosted service / README
The README and HA example reference endpoints and parameters that don't exist in v0.0.5:
| README / hosted service | v0.0.5 (actual) |
|---|---|
/prices_short |
only /prices exists |
region=DE |
country=DE |
surcharge=13.70 |
fixedPrice=13.70 |
Response: {s: [...], t: [...]} |
Response: {prices: [{startsAt, total}], knownUntil} |
This tripped me up when setting up HA sensors -- the example from the README returns 404.
2. ENTSO-E API key is documented but not used in v0.0.5
The compose.yaml references EPEXPREDICTOR_ENTSOE_API_KEY as an environment variable, and the README recommends it for better DE performance. However, the v0.0.5 code does not contain any reference to ENTSO-E (grep -r "entsoe\|ENTSOE" across all .py files returns nothing). The key is loaded into the environment but silently ignored.
Not a bug per se, but confusing for self-hosters who pin to a release tag instead of main.
3. First request hangs if aborted
The first /prices call after a fresh start triggers data fetching + model training (3-10 minutes). If the client aborts (Ctrl-C, HTTP timeout), the single Uvicorn worker gets stuck -- no further requests are served, no TCP connections shown in ss -tnp, no log output. A pod restart fixes it.
This might be worth a note in the README, or a Uvicorn timeout configuration.
Contributions (if useful)
I've put together a few files that might be useful for other self-hosters:
Kubernetes manifests
5 files for a complete deployment (no Helm chart needed):
- PVC (CephFS or any RWX/RWO storage, 1Gi)
- Secret (ENTSO-E API key, optional)
- Deployment + ClusterIP Service (with generous startupProbe for first-start training)
- VPA (VerticalPodAutoscaler)
- CiliumNetworkPolicies (Ingress from consumers, Egress to DNS + external APIs on 443)
Home Assistant REST sensor config for v0.0.5
Working rest.yaml with the correct v0.0.5 API format:
- resource_template: "http://epexpredictor-api.evcc.svc.cluster.local/prices?country=DE&fixedPrice=16.19&taxPercent=19&unit=EUR_PER_KWH&hours=120&startTs={{ as_timestamp(today_at('00:00')) | timestamp_custom('%Y-%m-%dT%H:%M:%S', false) }}"
scan_interval: 900
sensor:
- name: "EPEX Price Prediction"
unique_id: epex_price_prediction
value_template: >
{% set ns = namespace(price='unknown') %}
{% set now_ts = as_timestamp(now()) %}
{% for p in value_json.prices %}
{% set start_ts = as_timestamp(p.startsAt) %}
{% if start_ts <= now_ts < start_ts + 3600 %}
{% set ns.price = p.total | round(4) %}
{% endif %}
{% endfor %}
{{ ns.price }}
unit_of_measurement: "EUR/kWh"
device_class: monetary
json_attributes:
- prices
- knownUntil
Key differences from the README example:
- Uses
resource_template(notresource) for dynamicstartTscalculation startTsconverted to UTC via Jinja2 (the API interprets timestamps as UTC)value_templateiterates thepricesarray to find the current hour's pricejson_attributesstores the full forecast array for charting
ApexCharts card for Lovelace
Shows prediction (area) and evaluation (line) overlay for visual forecast quality assessment, with prices in ct/kWh.
Happy to submit any of this as a PR if you'd like it in the repo (e.g. as examples/kubernetes/ and an updated HA section in the README). Thanks for building this!
ApexCharts card for Lovelace (click to expand)
type: custom:apexcharts-card
header:
title: EPEX Strompreis-Prognose
show: true
graph_span: 120h
span:
start: day
now:
show: true
label: Jetzt
color: orange
yaxis:
- id: price
min: 0
apex_config:
tickAmount: 6
labels:
formatter: |
EVAL:function(val) { return val.toFixed(1) + ' ct'; }
series:
- entity: sensor.epex_price_prediction
name: Prognose
unit: ct/kWh
data_generator: |
const prices = entity.attributes.prices;
if (!prices) return [];
return prices.map(p => [new Date(p.startsAt).getTime(), p.total * 100]);
type: area
curve: stepline
yaxis_id: price
color: '#4FC3F7'
opacity: 0.3
stroke_width: 2
float_precision: 2
- entity: sensor.epex_price_prediction_evaluation
name: Evaluation (Modell)
unit: ct/kWh
data_generator: |
const prices = entity.attributes.prices;
if (!prices) return [];
return prices.map(p => [new Date(p.startsAt).getTime(), p.total * 100]);
type: line
curve: stepline
yaxis_id: price
color: '#FF8A65'
stroke_width: 1.5
opacity: 1
float_precision: 2
Oh, regarding the API differences etc: I recommend running latest instead of v0.0.5. I kinda forgot to tag new versions a long time ago. Latest master is muuuuch better wrt. Forecasting performance and stability. And it matches the README.
Other than that: nice writeup.
I'll tag a new version so others don't run into these issues.