Viessmann API status changed fired on every single failed poll (67 of 71 vicare_up=0 phases in 30 days lasted under 10 min), each producing an alert plus a resolved push. It now waits 5 min, about 3 failed polls. Gas per heating degree day fired for three days (up to +160%) right after Prometheus history started, because the offset week's 7d outside temperature average was built from a partly empty window. Both windows now need a similar sample count, and both weeks need more than 20 heating degree days so shoulder-season weeks don't swing the ratio. README: describe the updated rules and fix the no-burner-despite-cold threshold (5 °C, not the 15 °C heating limit).
vicare-exporter
SvelteKit app that polls the official Viessmann IoT API and exposes the values
as a Prometheus /metrics endpoint, so a Viessmann heating system can be graphed
in Grafana.
No reverse engineering of the ViCare app is involved — it uses the public Viessmann Developer API with your own OAuth client.
How it works
Viessmann API ──(1 call every VICARE_POLL_INTERVAL_MS)──▶ in-memory cache
│
Grafana ──▶ Prometheus ──scrape /metrics (any interval)──▶ this app
The background poller is the only thing that talks to Viessmann. Prometheus only ever reads the cache, so the scrape interval is independent of the API rate limit.
- Free tier limits: 1450 calls / 24 h, 120 calls / 10 min — shared for the whole account, so the ViCare app counts against the same budget as this exporter.
- One poll = one API call per gateway. Do not go below ~60 s
(
VICARE_POLL_INTERVAL_MS=60000≈ 1440 calls/day, basically no headroom left).90000(default) ≈ 960 calls/day, leaving ~490/day of headroom for normal ViCare app usage. If Grafana is your main view and you barely open the app, you can push closer to the floor — e.g.65000≈ 1330 calls/day, ~120/day of headroom for retries and the odd manual app check. - On HTTP 429 the poller backs off until the limit window resets.
Register an API client
https://app.developer.viessmann-climatesolutions.com
- Google reCAPTCHA: off (required for the headless login below)
- Redirect URI:
http://localhost:4200/ - PKCE is used, so there is no client secret.
cp .env.example .env # put your Client ID in
npm install
Authentication — pick one
A. Fully automatic (recommended for a container)
Put your ViCare account into .env:
VICARE_USERNAME=you@example.com
VICARE_PASSWORD=…
The app logs in on its own using Viessmann's Basic-auth authorize endpoint
(same mechanism PyViCare / Home Assistant use — no browser). It refreshes the
access token hourly and re-runs the full login by itself once the refresh
token gets close to its 180-day expiry (VICARE_RELOGIN_AFTER_DAYS, default
150). Nothing manual, ever.
Requirements: reCAPTCHA disabled on the client, and no 2FA on the Viessmann account (Basic-auth login can't do a second factor).
B. Refresh token only (no password stored)
npm run login
Opens the browser login once, then prints VICARE_REFRESH_TOKEN=…. Put that in
.env / the container env. Valid 180 days; Viessmann does not extend or
rotate it, so you must repeat this by hand every ~180 days. Alert on
vicare_up == 0 so you notice.
Run
npm run dev # local, http://localhost:4200
# or
npm run build && node build # production; env vars from the environment
.tokens.json (or $VICARE_TOKEN_FILE) caches the current token so restarts
don't trigger a fresh login. In Docker it lives on a named volume.
npm test # unit tests (vitest) — also gates the Docker build, see below
Endpoints
| Path | Purpose |
|---|---|
/ |
status page (auth state, last poll, error, counts) |
/auth/login |
starts the browser OAuth flow (mode B only) |
/metrics |
Prometheus exposition format |
/features |
raw cached feature objects as JSON, for debugging (?q= filters by feature name); not for scraping |
Docker
The image is built by Gitea Actions on every push to main and pushed to
git.mars3142.dev/mars3142/vicare (linux/amd64), tagged latest and the short
commit SHA.
On the host (e.g. Hetzner):
docker login git.mars3142.dev
cp .env.example .env # fill in VICARE_CLIENT_ID + VICARE_USERNAME/PASSWORD
docker compose up -d
docker-compose.yml pulls the registry image and runs the exporter plus its own
Prometheus, both with no published ports. They talk over a shared external
network monitoring (create it once with docker network create monitoring) so
an existing Grafana container can join and reach Prometheus at
http://vicare-prometheus:9090.
CI setup
The workflow needs two Actions secrets (already set at the mars3142 user
level, shared by all repos):
| Secret | Purpose |
|---|---|
REGISTRY_USER |
Gitea user for docker login |
REGISTRY_PASSWORD |
token / password for that user |
DEPLOY_WEBHOOK_URL |
optional — POSTed to right after the image push, to trigger your own redeploy (e.g. Watchtower's HTTP API). Unset by default; the step no-ops if it's empty, so nothing needs to change for repos without one. |
Every push to main replaces :latest; each build is also kept as :<sha>.
npm test runs inside the Docker build itself (see Dockerfile), before
npm run build — a failing test fails the image build, so docker.yaml
never pushes a broken image. pr-check.yaml runs the same tests separately
so a PR fails fast without waiting for a full image build.
docker.yaml also runs the built image once before pushing it (deliberately
without any Viessmann credentials) and checks that /metrics comes back with
vicare_up 0 in valid Prometheus format — a smoke test for the container/
adapter-node packaging itself, the kind of break the unit tests can't see. It
intentionally does not exercise a real poll: that would need real
credentials as a CI secret and would eat into the same 1450-calls/24h budget
as the production instance.
Metric naming
Each feature property becomes vicare_<feature>_<property>, by type:
| Property type | Output |
|---|---|
| number | vicare_heating_sensors_temperature_outside_value{unit="celsius"} 12.4 |
| boolean | vicare_heating_burners_0_active 1 |
| array (gas/power consumption) | …_day = current period, …_day_previous = last completed periodvicare_heating_gas_consumption_heating_day{unit="cubicMeter"} 4.2 |
| string (mode / status enum) | vicare_heating_circuits_0_operating_modes_active_value_info{value="dhwAndHeating"} 1 |
All carry gateway and device labels. Consumption arrays are newest-first, so
_day climbs through the day and resets at midnight; _day_previous is
yesterday's final total.
Two exceptions to the vicare_<feature>_<property> rule get a _total
suffix and TYPE counter, because they're real counters even though
Viessmann doesn't name them that way — the suffix follows Prometheus' own
naming convention so rate()/increase() on them don't trip Grafana's
counter-naming linter:
- a
currentDayproperty (gas/powerconsumption.summaryfeatures) —vicare_<feature>_currentday_total. Climbs through the day and resets at midnight, just like the arrays above. - any property under a
*.statisticsfeature (e.g.heating.burners.0.statistics→starts,hours) —vicare_<feature>_<property>_total. A lifetime count that only ever increases, e.g.vicare_heating_burners_0_statistics_starts_total.
Meta metrics: vicare_up, vicare_status_info, vicare_last_poll_timestamp_seconds,
vicare_api_calls_total, vicare_feature_property_count,
vicare_feature_property_baseline, vicare_device_info (static
installation/gateway/device metadata — model, gateway type, installation
description — refreshed only on gateway (re)discovery, not every poll).
vicare_up isn't just "did the HTTP call succeed" — Viessmann can answer
with 200 but a near-empty feature set (no exception to catch). The poller
tracks the highest property count it's seen from a healthy poll
(vicare_feature_property_baseline) and treats a poll as low if the current
one (vicare_feature_property_count) comes in under half of that, even
though the request itself didn't error. A single low poll that recovers on
the very next one is routine Viessmann API noise and is logged
([vicare] low property count: ...) but does not flip vicare_up — only two
low polls in a row do. Once it actually recovers from that degraded state,
the poller logs [vicare] recovered: ... so you don't have to infer it from
the absence of further warnings.
vicare_up stays a plain boolean on purpose (every alert rule gates on it),
but it collapses two different failure modes into one 0. vicare_status_info
carries the breakdown as an enum ("info metric", same pattern as
vicare_device_info/kube_pod_info): {value="ok"}, {value="degraded"}
(up but implausibly little data, see above), or {value="error", reason="rate_limit"|"other"} (the poll itself threw). Use it on the
dashboard to see why vicare_up is 0 without digging through container
logs.
Prometheus config
scrape_configs:
- job_name: vicare
scrape_interval: 60s # cache-only, cheap; can be lower
static_configs:
- targets: ['localhost:4200']
Weather-normalized gas consumption (Heizgradtage)
Raw consumption deltas are useless without weather context — a colder week alone explains most swings. The dashboard's Wetterbereinigung (Gas) row turns the outside temperature sensor and the daily gas gauges into a weather-normalized figure (m³ per heating degree day, VDI 2067 basis G20/15, Heizgrenze 15 °C), computed inline in each panel's PromQL — no extra Prometheus config, just plain queries against the existing metrics:
- outside temperature → rolling mean:
avg_over_time(vicare_heating_sensors_temperature_outside_value[1d|7d]) - heating degree days:
clamp_min(15 − Ø-temp, 0)(7-day figure:7 × clamp(15 − 7d-avg-temp), an approximation of "sum of 7 independently-clamped days" that slightly under-counts weeks mixing very warm and very cold days) - gas volume, 7-day figures: Viessmann's own heating-only
..._heating_lastsevendaysrolling scalar - gas volume, daily figure:
increase()on the midnight-resetting heating-only..._heating_currentday_totalgauge, which turns its daily sawtooth reset into a rolling 24h total - normalized figure: gas volume ÷ heating degree days
Domestic hot water is deliberately excluded from the normalized figure —
DHW gas keeps flowing year-round regardless of weather, so it has its own
"Warmwasser (Grundlast, 7 Tage)" stat instead. Mixing it into the numerator
would both skew the ratio and turn the summer months, when heating degree
days go to 0 but DHW gas doesn't, into a guaranteed division by (near) zero
rather than a rare edge case — every ratio query is guarded with and hgt > 0.5 for exactly that reason, so the panels show "no data" instead of +Inf
once the heating limit (15 °C) isn't undercut anymore.
The 7-day figures deliberately go back to Viessmann's own lastsevendays
field instead of increase() on our own scrape history: increase() treats
every drop in a gauge as a counter reset and adds the pre-drop value back,
which only gives a correct total if the gauge is a perfectly clean sawtooth.
Over a 14-day span (this week + the same window a week earlier, for the
week-over-week comparison) that assumption broke in practice — a plain
increase()-based rewrite of the (non-normalized) "Gas 7-Tage-Vergleich"
panel briefly produced a 515 % reading. lastsevendays is a Viessmann-side
blackbox (we don't know its exact window definition), but it proved more
reliable than reimplementing the rolling sum ourselves. The daily figure
still uses increase() — over a 1-day window it only ever crosses one
midnight boundary, so a false reset is far less costly than over 14 days —
but treat it with some skepticism until it's been checked against a real
heating period; if it looks implausible, compare the raw
heating_currentday_total series in Explore against a clean sawtooth.
Grafana
This stack does not ship a Grafana — you plug the files under grafana/ into
an existing instance. Everything is namespaced so nothing of yours is touched:
a separate datasource (uid: vicare-prometheus), its own Vicare folder for the
dashboard and rules, an added contact point vicare-pushover, and each rule
pinned to that contact point via notification_settings (no notification-policy
override).
| File | What it does |
|---|---|
provisioning/datasources/prometheus.yaml |
adds the vicare-prometheus datasource |
provisioning/dashboards/vicare.yaml |
loads heizung-dashboard.json into the Vicare folder |
provisioning/alerting/contactpoints.yaml |
adds the vicare-pushover contact point (optional, see below) |
provisioning/alerting/rules.yaml |
12 alert rules → vicare-pushover |
Wire it into your Grafana
Assuming the vicare stack and Grafana are on the same host and both on the
monitoring network:
grafana:
networks:
- traefik # your existing network(s)
- monitoring # add this — reaches http://vicare-prometheus:9090
environment:
PUSHOVER_API_TOKEN: ${PUSHOVER_API_TOKEN:?}
PUSHOVER_USER_KEY: ${PUSHOVER_USER_KEY:?}
volumes:
- grafana:/var/lib/grafana
# vicare provisioning (repo checkout on the host), mounted read-only:
- /opt/docker/vicare/grafana/provisioning/datasources/prometheus.yaml:/etc/grafana/provisioning/datasources/vicare.yaml:ro
- /opt/docker/vicare/grafana/provisioning/dashboards/vicare.yaml:/etc/grafana/provisioning/dashboards/vicare.yaml:ro
- /opt/docker/vicare/grafana/provisioning/alerting/contactpoints.yaml:/etc/grafana/provisioning/alerting/vicare-contactpoints.yaml:ro
- /opt/docker/vicare/grafana/provisioning/alerting/rules.yaml:/etc/grafana/provisioning/alerting/vicare-rules.yaml:ro
- /opt/docker/vicare/grafana/heizung-dashboard.json:/var/lib/grafana/dashboards/vicare/heizung-dashboard.json:ro
networks:
monitoring:
external: true
Adding read-only mounts and restarting Grafana does not remove anything you
created in the UI — provisioning is additive, and it only manages the vicare
items above. Those show as read-only in the UI; edit the files, then restart
Grafana or POST /api/admin/provisioning/{dashboards,alerting}/reload.
Requires Grafana ≥ 10.4 (notification_settings per rule). On older versions,
drop notification_settings from every rule and instead add a route for
{ grafana_folder = "Vicare" } → vicare-pushover in your notification policy.
Contact point — file-provisioned vs. manual: contactpoints.yaml pulls
the Pushover credentials from the environment via Grafana's $__env{VARNAME}
syntax (not ${VARNAME} — that's shell/Compose syntax and Grafana never
expands it, it ends up as a literal string and fails contact point
validation). If that env-var plumbing gives you trouble, skip the file
entirely — don't mount contactpoints.yaml — and create the contact point by
hand instead: Grafana → Alerting → Contact points → Add contact point,
integration Pushover, paste in the token/key. The name must be exactly
vicare-pushover, since rules.yaml references a receiver by that name
regardless of whether it was provisioned from a file or created in the UI.
The alert rules
- exporter down (
vicare_up == 0, sustained 10 min) and stale poll data - Viessmann API status changed — fires after 5 min of
vicare_up=0(about 3 failed polls in a row), earlier than the 10 min critical exporter-down alert; single failed polls no longer trigger a push - supply temperature too high, system pressure out of 1.0–2.5 bar
- burner short-cycling (> 20 starts/h) and burner running continuously (> 95 % over 3 h) while the supply stays > 5 K below the burner demand temperature — long runs alone are normal in winter
- domestic hot water cold for 2 h
- API quota near the 1450/24h limit (> 1380 calls/24h)
- weather-normalized gas consumption per heating degree day > 50% above the same figure a week ago (see Weather-normalized gas consumption); only with > 20 heating degree days in both weeks and complete temperature history for both 7-day windows
- no burner activity despite a 3h average outside temperature below 5 °C — the inverse failure mode of "burner running continuously"
- boiler self-consumption electricity > 50% above the same week last week
All rules except the two exporter/API-health ones above are gated with
and on() vicare_up == 1 and set noDataState: OK, so a failed or degraded
poll (missing sensor values) can't itself trigger a spurious alert on one of
the value-based rules — you get exactly one notification (from the API status
rule) instead of a pile of unrelated "no data" alerts.
contactpoints.yaml sends alert pushes at priority: 1 (loud, bypasses
quiet hours — you want to notice) but resolved pushes at okPriority: 0
(visible, but respects quiet hours). Don't drop okPriority to -1: Pushover
delivers that silently with no popup, so the "back to normal" push is easy to
miss entirely next to the loud alert push, and it ends up feeling like
nothing ever resolves.
Thresholds in rules.yaml are starting points — tune them against your own
history. Test delivery in Grafana → Alerting → Contact points → vicare-pushover
→ Test.
To see everything your device exposes: open /metrics, or in Grafana Explore
run {__name__=~"vicare_.+"} against vicare-prometheus.