Viertelstunden-Wächter (Quarter-Hour Peak Guard)
Home Assistant integration that keeps the average grid import of every quarter hour below a limit, by throttling the wallbox and switching flexible loads only as far as needed.
Status: 0.1, early test version. Runs in observe mode first. Use at your own risk.
What is this for?
- Purpose: Power-based grid tariffs (in Austria from 2027, elsewhere already) bill the highest quarter-hour average of the month. One evening with the car charging at 11 kW while the oven is on can set the price for the whole month.
- For whom: Home Assistant users with a wallbox and/or switchable loads (pool pump, water heater, heat pump boost, home battery) and a grid meter in Home Assistant.
- What you get: a guard that works with an energy budget per quarter hour instead of a hard power cap: short peaks pass, the car keeps charging (never stopped, only throttled, if allowed down to 1 phase), other devices are paused by priority and given back stepwise. Every decision is logged with its reason.
- What it is not: no replacement for the fuses and the load management required by electrical codes, no tariff calculator, no cloud service. It needs no internet and no AI.
How it decides
Every 20 seconds:
E energy imported so far in this quarter hour (meter counter, cross-checked)
allowed = (target × 0.25 h − E) / remaining time
excess = average import of the last minute − allowed
target = limit − safety margin. If there is an excess, the guard picks devices:
- Least loss of comfort (default): the cheapest set of devices (sum of priorities) that is enough. 0.8 kW too much → the pool pump alone, if it is less important than the car.
- Strict priority order: like a fixed list, priority 1 first.
Giving back happens in reverse: the most important device first, only with headroom that held for two minutes (cookers cycle), at most one step per minute, the wallbox stepwise. A switched-off device stays off at least 5 minutes and never longer than its maximum off time.
Safety:
- Observe mode: decides and logs, but switches nothing. Start with it.
- Readings missing for 90 s, guard switched off, condition off, Home Assistant restart or integration unloaded → everything the guard changed is given back.
- Only what the guard changed itself is restored; a device switched on again only if it is still off and its optional "switch on again only while" entity is on.
- A lock entity refuses active mode, e.g. while another guard still runs.
- Implausible counter jumps (after an outage) are ignored.
- Confirmation: every real intervention is checked in the readings (see Confirmation of commands).
Deutsche Anleitung: docs/ANLEITUNG.md – Einrichtung, Messung, Beispiele, Umstellen.
Grid measurement: what the guard needs
Two sensors, from any integration (no HACS needed for them):
| Sensor | Unit | Required | Note |
|---|---|---|---|
| Grid import power | W or kW | yes | updated every few seconds; a net sensor (negative = export) also works, negative counts as 0 |
| Grid import energy counter | Wh, kWh or MWh | recommended | makes the quarter-hour energy exact after restarts |
Typical sources, all with integrations built into Home Assistant:
- The inverter's own meter at the grid connection point (Fronius, SMA, Huawei, SolarEdge, …).
- The utility smart meter's customer interface (in Austria: optical/M-Bus interface, key from the grid operator) with a reader via ESPHome or MQTT. About one value per second – the best source.
- A meter in the distribution board, e.g. a 3-phase energy meter via its integration or Modbus.
Not suitable: the grid operator's web portal. Its 15-minute values arrive the next day – fine for statistics, far too late for control.
Installation
HACS → ⋮ → Custom repositories → this repository, category Integration → install → restart Home Assistant → Settings → Devices & services → Add integration → Viertelstunden-Wächter.
Then add the devices on the integration page: the buttons Add wallbox / switchable device / emergency action create one entry per device; each entry has ⋮ → Reconfigure / Delete. The gear icon opens the general settings. (Devices are config subentries; version 0.1 stored them in the options and migrates automatically.)
The device types:
| Device type | What the guard does | Needs |
|---|---|---|
| Wallbox | lowers the current (3-phase down to the minimum, then optionally 1-phase) | charging power sensor, current setting (number), optional phase selection (select) |
| Switchable device | switches off / on again | switch, optional power sensor |
| Battery | releases the home battery so it feeds the house (settings and values you enter, previous values are put back) | state of charge sensor, one or two settings (number / select / switch) |
| Change settings | changes one or two settings (block contact, operating mode ...) and puts them back | the settings (switch, select, number) and the value for "lowered" |
| Throttle power | lowers a number (percent, watts, amps) stepwise between a minimum and its normal value and gives it back stepwise |
a number entity, optional power sensor |
| Emergency action | runs a script, a second script undoes it | scripts, for anything the other types cannot do |
| Vehicle (charge plan) | plans when the car should charge; optionally pauses/allows charging accordingly | state of charge sensor, departure time, see Charge plan |
Each device has a priority (1 = restricted first, 10 = only if nothing else helps), an optional intervention only while entity, and for switches/scripts a maximum off time.
The guard knows no brands, only roles. Any wallbox whose integration offers a settable charging current works (phase switching optional); a home battery is controlled through two small scripts, because every battery is controlled differently. Wallboxes that can only be started and stopped are not supported (the car is never stopped).
Battery
The device type Battery releases the home battery in an emergency, without scripts or helper templates:
| Field | Meaning |
|---|---|
| State of charge, minimum state of charge | released only at or above the minimum, given back if it falls below |
| Setting that releases the battery + value | e.g. a number "maximum output power" with value 800, or a select "mode" with the option on; a second setting is optional |
| Expected relief (W) | how much the release lowers the import (planning, savings estimate) |
| Maximum duration | taken back after this time in any case (0 = no limit) |
| Put the previous values back | on: settings are restored to their values from before the release - only those that still hold the release value, so a value set meanwhile by another automation is left alone |
| Script after taking back | optional, e.g. to let your own automation set the battery (use it instead of restoring if your battery has its own control logic) |
The battery is offered as a measure only if at least one of its settings differs from the release value (it is
not "released" twice) and the state of charge allows it. It defaults to priority 10: last. Example:
number.battery_max_output_power → 800 and select.battery_mode → on.
Heat pumps and other devices with a power limit
Heat pumps are controlled in three ways in Home Assistant; the guard supports all three. Tested in the simulator only (no heat pump was available) - try it in observe mode first.
| Your heat pump offers | Device type | Example |
|---|---|---|
| a power limit as a number (percent, watts, kilowatts; often via Modbus) | Throttle power | number maximum compressor power 100 → 30 in steps of 10 |
| a block contact (SG-Ready / utility block) as one or two switches | Change settings | block switch → on (SG-Ready mode 1: switch 1 on, switch 2 off) |
| an operating mode as a selection | Change settings | mode select → Off or Eco |
| only an on/off switch | switchable device | always with a maximum off time |
a climate entity (setpoint) |
emergency action (script) | a script lowers the setpoint, one restores it |
Throttle power: with a power sensor the new value is calculated from the real consumption (power follows the value), without it the value is lowered by one step per cycle. The guard never goes below the lowest value and gives the value back stepwise when there is headroom.
Protecting the heat pump (all optional, for Throttle power and Change settings):
- Comfort sensor and comfort minimum: a room or hot water temperature. While it is below the minimum the device is left alone, and an intervention that is running is ended.
- Minimum duration: an intervention is kept at least this long (default 5 minutes).
- Pause after taking back: wait this long before the next intervention - keeps the compressor from short cycles (switchable devices have this field too).
- Maximum duration: taken back after this time in any case.
Change settings restores the previous values after the intervention, but only those that still hold the changed value (a value set meanwhile by another automation is left alone); switch off "put the previous values back" and use the script field if your heat pump has its own control logic.
Which actuators work
The guard can switch something on/off, lower a current (wallbox) or run a script. Whatever can be reduced to one of these works.
| Actuator | Supported | How |
|---|---|---|
| Sockets, relays, pumps, boilers | yes | switchable device (switch, input_boolean, light, fan) |
| Wallbox with a settable charging current | yes | wallbox (current number, optional phase select) |
| Heat pump / heating element with a contact (e.g. SG-Ready), air conditioner with a switch | yes | switchable device |
| Home battery, inverter modes | yes | battery (settings and values), or an emergency action (two scripts) |
| Heat pump with power limit, block contact or operating mode | yes (simulator only) | throttle power / change settings, see above |
| Anything that is an action in Home Assistant (scene, automation, mode select) | yes | emergency action (script) |
climate entities (setpoint) |
via script only | one script lowers the setpoint, one restores it |
| Devices with an adjustable power (stepless heating element, heat pump percent, charge power) | yes | throttle power (stepwise) |
| Wallbox that can only be started and stopped | possible, not recommended | as a switchable device it would stop charging |
| Blinds, lights, locks | no | save no relevant power |
Requirements: the device needs a state in Home Assistant (on/off) so the guard knows whether it runs; a power sensor is optional (otherwise the assumed power is used). The guard only touches what you configured.
What is part of the integration, and what you provide yourself
Inside the integration (nothing else to install): the decision engine, the device list with priorities and strategies, observe mode and the lock, the safety rules, the entities (mode, strategy, limit, margin, price numbers, the four feature switches, all sensors), cost and savings, "use peak already reached", the message on intervention, the load forecast, diagnostics.
Outside, in your own Home Assistant (it depends on your home, so the integration cannot ship it):
| What | Why | Typical way |
|---|---|---|
| Grid import power sensor and optional import counter | measured by your inverter or meter | the integration of your inverter, ESPHome, Modbus … |
| The entities of your devices (wallbox current, switches, power sensors) | they belong to your hardware | the integrations of the devices |
| Optional condition entities: only needed while, lock entity, intervene only while, switch on again only while | rules of your household | any on/off entity: a template helper, an input_boolean, a schedule. Example: "switch the kitchen plug on again only while its own schedule wants it on" is a template helper that reads that schedule |
| Scripts for an emergency action | only for what the other device types cannot do | two small scripts (intervene / undo); a home battery needs none: use the device type Battery |
| A dashboard | your taste | the entities above; the German guide has a card for the configuration |
So the helper entities in an installation like the author's ("kitchen may switch on again", "battery emergency possible") are not part of the integration: they are conditions and scripts you create for your own devices. The integration only asks for them where you enter a device.
Wallbox compatibility
Full list for wallboxes, batteries and heat pumps, with the test status of every integration (tested by us / entity types verified in the source / help wanted): docs/COMPATIBILITY.md. Nothing is marked "tested" for the new device types yet - reports are welcome (see the end of that page).
What the guard needs from a wallbox integration: a charging power sensor and a settable charging current
(number, A). Checked in the integrations' source code on 2026-10-25; only the Wattpilot was tried on real
hardware. Entity names change between versions - look for them in your own installation.
| Integration | Charging current as number |
Power sensor | Usable |
|---|---|---|---|
Wattpilot (HACS, wattpilot-HA) |
yes, "Max Charging Current" | yes | yes (tested; phase selection available) |
| Wallbox (Home Assistant core) | yes, "Maximum charging current" | yes (kW) | yes (no phase switching) |
| OpenEVSE (core) | yes, "Charge rate" (A) | yes | yes |
| Zaptec (HACS) | yes, "charger_max_current" | yes (W) | yes |
OCPP (HACS, lbbrhzn/ocpp) |
yes, "Maximum Current" | yes | yes (sets a charging profile; check how your charger reacts) |
| Alfen (HACS) | yes, several "max current" numbers | yes | with care - these are device settings; frequent writing was not checked |
| KEBA (core) | no, only the service keba.set_current |
yes | via helper (below) |
| Easee (HACS) | no, only services (e.g. dynamic limit) | yes | via helper (below) |
| Ohme (core) | no (numbers are target percentage etc.) | yes | no |
| Blue Current (core) | no (only start/stop switch) | yes | no |
| myenergi (HACS) | no (minimum green level, priorities) | yes | no |
| evcc (HACS) | no current number found | yes | no - regulate in evcc itself |
| go-e, openWB, Tesla Wall Connector, others | not checked | unknown |
Via helper (charger sets the current only through a service): create an input_number helper (A, step 1,
your min/max) and an automation that calls the service with the helper's value when it changes. Enter the helper
as "charging current setting". The guard then changes the helper and the automation passes it on.
Roadmap
Nothing in this list is built yet (done in 0.13: house and car apart, battery reserve, CSV export, AI explainer, English texts, the phone view Today). The order is a proposal, not a promise.
Planned
- Publishing: the installation test on a fresh Home Assistant 2026.10.3 (Docker,
tests/install) passed on 2026-10-25 - config flow from scratch, devices, observe and active mode, release, services, restart - and hassfest passes. Still open: the HACS validation (needs a public repository), repository topics, a first release, and real-world reports from other installations. - Real-hardware tests of Throttle power and Change settings (heat pumps) and of the battery release on other makes - until then they are simulator-tested only. Test reports are welcome (issue template device test report).
- Charge plan closer to the risk windows: avoid forecast peaks when placing the charging quarters, and a daily plan that combines solar forecast, departure times and the learned load pattern.
- Connectors (optional, opt-in): the CSV export exists (0.13); where a platform offers a documented interface, a connector could send the data there (for example platforms for energy communities). A connector depends entirely on the other platform's interface and is a separate optional part: nothing leaves the installation unless the user sets it up.
- Dynamic tariffs: charging by day-ahead price as one more input of the plan (only useful with such a tariff).
AI features (the explainer is built in 0.13, the others are planned; optional, off by default and off after a restart, with a daily cost limit). The AI is used through Home Assistant's AI task entity, so every user chooses the model (cloud or local) and no key is built in. The rule: the AI explains, advises and plans - what is switched now is always decided by the fixed rules (every 20 seconds, also without internet), and every AI proposal is checked against hard limits before it is used.
| Function | What it does | Risk |
|---|---|---|
| Explainer (built, 0.13) | Turns the day's interventions into a short text, optionally as a message ("Pool paused 12 min so the car is full by 7") | none, read only |
| Weekly review with suggestions | "Three tight quarter hours, all Sundays at 18:00 with oven and car. Suggestion: start charging at 20:00." Nothing changes without confirmation | low |
| Set-up by conversation | A sentence like "the pool does not matter, the freezer may be off 30 min at most" becomes a proposal for devices, priorities and maximum off time that the user confirms | low |
| Ask the guard | "Why was the wallbox throttled yesterday evening?" via Assist, chat or the Home Assistant MCP server | none |
| Daily plan | From solar forecast, weather, appointments and the learned load pattern a proposal (e.g. charge the car 11-15 h, battery reserve 30 %), validated by the rules before use | medium, therefore proposal only |
Learning of load patterns (the cooker cycles, the oven on Sundays) already needs no language model: the guard does it locally with simple statistics (see Load forecast).
Cost, savings and optional features
Three switches, all on by default (the last state is restored after a restart):
| Switch | What it does |
|---|---|
| Use peak already reached | The tariff bills the highest quarter hour of the month. If a peak above the limit has already happened this month (say 12 kW), quarter hours below it cost nothing extra – the guard then works with that peak as its limit for the rest of the month (the limit number itself stays unchanged). Only helps after a peak above the limit; with a month peak below the limit nothing changes. The month peak counts from the moment the integration measures it. |
| Message on intervention | Via the notify services of the general settings: (1) at the first real intervention a message with everything the guard did in that step (e.g. "Wallbox 16 A -> 12 A (3-phasig, 1.6 kW zu viel)"), at most every 30 minutes; (2) when the guard has given everything back a summary of all steps with times (up to 15 lines). Not sent in observe mode. |
| Calculate cost and savings | Shows what the month's peak costs and what it would have cost without the guard. |
Entering the costs: the numbers Demand charge up to the threshold and Demand charge above the threshold (EUR per kW and year) and Price threshold (kW, default 10) – from the tariff sheet of your grid operator. They default to 0 (nothing is shown until you enter them). The monthly peak is billed with one twelfth of the annual price; the part of the peak up to the threshold with the first price, the part above with the second:
cost = ( min(peak, threshol