Kathrein Watchdog fails
Describe the bug
Bzgl. PR https://github.com/evcc-io/evcc/pull/34784
Ich habe gestern Abend in der Wallbox die Timeout-Überwachung mit 300s aktiviert. Zunächst lief es unauffällig, der Heartbeat wurde augenscheinlich gesendet.
Um 07:47 Uhr habe ich in evcc kurz den Lademodus geändert und wieder zurückgesetzt, wodurch für einige Sekunden der Wallbox der Setpoint auf 16A gesendet wurde, anschließend wieder auf 0A.
Anschließend hat der Heartbeat nicht mehr funktioniert. Alle 5 Minuten hat die Wallbox selbsttätig den Ladestrom wieder freigegeben. evcc hat dann reagiert und den Strom wieder auf 0A gesetzt. Nach 5 Minuten erneut wieder Freigabe durch die Wallbox. Nach 3 Stunden habe ich das ganze bemerkt, waren dann insgesamt 31 ungewollte Ladestarts. Zwischenzeitlich wurde um 10:45 Uhr aufgrund des Ladeplans für 15 Minuten seitens evcc der Ladestrom freigegeben --> hier dann kein toggeln. Um 11:00 Uhr gab es dann wieder eine Ladepause --> hier hat das toggeln wieder angefangen.
Im Trace ist leider der Beginn um 07:47 Uhr nicht mehr enthalten, da er erst um 09:31 Uhr beginnt. Gegen 11:20 Uhr habe ich die EMS Timeoutüberwachung in der Wallbox wieder deaktiviert.
evcc-20261027-113123-debug.log
Steps to reproduce
- EMS Timeout-Überwachung in Wallbox auf 300s konfiguriert. Fallback-Strategie in Wallbox auf 3p, 16A gesetzt
- Kurze Ladestrom-Freigabe <15s durch evcc aufgrund "Spielen im UI".
- Heartbeat scheint auszufallen
Ob es reproduzierbar ist, kann ich nicht 100%ig sagen, ich habe es nicht weiter getestet.
Configuration details
... database only modus?
/app # evcc config
[main ] INFO 2026/10/27 11:48:17 config file not found, database-only mode
[main ] INFO 2026/10/27 11:48:17 using sqlite database: /root/.evcc/evcc.db?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=foreign_keys(1)&_pragma=auto_vacuum(INCREMENTAL)&_pragma=cache_size(-16384)&_txlock=immediate
Log details
Siehe Attachment der Beschreibung
What type of operating system or environment does evcc run on?
Home Assistant app
External automation
- [x] I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.
Nightly build
- [x] I have verified that the issue is reproducible with the latest nightly build
Version
0.318.1
Thanks for the detailed report. This concerns the Kathrein heartbeat added in #34784 (charger/kathrein.go).
The heartbeat reads the current setpoint register every timeout/2 and writes it back (together with the EMS control register). It is started in NewKathrein only if the timeout register is already >0 when evcc connects. I could not confirm a root cause from the report alone, so a few details are needed:
- The charger configuration (
evcc.yamlor the charger YAML from the UI).... database only modus?is not usable. - Whether the timeout was set in the wallbox before evcc was (re)started. If it was enabled while evcc was already running, the heartbeat goroutine was never started.
- A trace log (
kathrein: trace) covering the start at 07:47, or at least a few 5-minute cycles including anyheartbeat:error lines.
Related: #34784 (introduced the heartbeat).
🤖 Generated with Claude Code
"Whether the timeout was set in the wallbox before evcc was (re)started. If it was enabled while evcc was already running, the heartbeat goroutine was never started."
Das könnte der Grund sein. Allerdings Frage ich mich, warum das toggeln dann gestern Abend, als ich den EMS Timeout in der Wallbox gesetzt habe nicht sofort begonnen hat.
Ggf. wäre es hilfreich wenn die Logik einen
charger logic error: disabled but charging
erkennt, dass evcc den aktuellen EMS-Timeout Wert nochmal einliest um zu prüfen, dass der heartbeat aktiviert werden muss?
Thanks for the answer. Code check (charger/kathrein.go): the timeout register is read only once in NewKathrein, and the heartbeat goroutine is started only if it is >0 at that moment. If the timeout is enabled in the wallbox while evcc is running, no heartbeat exists until the next evcc restart. This is consistent with your symptom, but the report does not yet prove it, because the log starts after 07:47.
Your suggestion (re-read the timeout later) would be a possible fix. To confirm, please check:
- Was evcc restarted (or the charger re-initialised, e.g. by saving the config) after you enabled the 300 s timeout yesterday evening and before 07:47?
- Does the log show
kathrein: heartbeat:error lines? Please post a trace excerpt as text. - The charger YAML (UI: Configuration > Charger > edit > show YAML), not the output of
evcc config.
🤖 Generated with Claude Code
Was evcc restarted (or the charger re-initialised, e.g. by saving the config) after you enabled the 300 s timeout yesterday evening and before 07:47?
--> Nein
Does the log show kathrein: heartbeat: error lines? Please post a trace excerpt as text.
--> Nein
The charger YAML (UI: Configuration > Charger > edit > show YAML), not the output of evcc config.
"charger": [
{"id":20,"name":"db:20","type":"template","config":{"id":0,"template":"kathrein","baudrate":9600,"comset":"8N1","host":"192.168.10.222","modbus":"tcpip","port":502,"timeout":"5s"},"deviceProduct":"Kathrein KWB-AC35"}
],
"loadpoints": [
{"id":11,"name":"db:11","alwaysCharge":"off","batteryBoostLimit":100,"charger":"db:20","circuit":"db:52","defaultMode":"smart","limitEnergy":0,"limitSoc":0,"maxCurrent":16,"meter":"db:25","minCurrent":6,"minSoc":0,"phasesConfigured":0,"planEnergy":0,"planPrecondition":0,"planStrategy":{"continuous":false,"precondition":0},"planTime":"0001-01-01T00:00:00Z","priority":0,"smartCostLimit":0.18,"smartFeedInPriorityLimit":null,"soc":{"estimate":true,"poll":{"interval":3600000000000,"mode":"charging"}},"solarShare":1,"thresholds":{"disable":{"delay":0,"threshold":0},"enable":{"delay":0,"threshold":0}},"title":"Wallbox","ui":{"maxTemp":0,"minTemp":0},"vehicle":"db:27"}
],
Thanks, that clears it up. The answers match the code in charger/kathrein.go.
NewKathreinreads the EMS timeout register (0x00A3) once at startup. It starts theheartbeatgoroutine only if the value is>0at that moment.- You enabled the 300 s timeout in the wallbox while evcc was running and did not restart evcc. So no heartbeat goroutine existed, and there are no
heartbeat:errors in the log. - The setpoint was only rewritten when evcc changed it, for example during the 15 minute plan window or your UI test. That is why it looked fine at first.
- Once the setpoint stayed at 0 A, nothing reset the timer. After 300 s the wallbox applied its fallback (3p, 16A) and evcc set 0 A again, which repeated every 5 minutes.
So the 07:47 UI toggle was probably not the trigger. The heartbeat was most likely never running after you enabled the timeout.
Possible fixes: re-read the timeout register periodically, or run the heartbeat always and skip the write when the timeout is 0. Both look small and low-risk. For now, restart evcc after changing the timeout in the wallbox.
Related: #34784 (introduced the heartbeat).
🤖 Generated with Claude Code
Eine Theorie (nicht bestätigt): wenn der EMS Timeout in der Wallbox aktiviert wird, läuft er ggf. tatsächlich erst dann los, sobald vom EMS ein neuer Setpoint geschrieben wurde. Dies würde erklären, warum der Timeout gestern Abend aktiviert wurde, er aber bis heute früh nicht ausgelöst hat. Erst mit dem kurzen Ladestart heute um 07:47 Uhr als erstmalig seit Aktivierung des EMS Timeout durch evcc ein Setpoint geschrieben wurde, dann wurde die Timeout-Überwachung in der Wallbox tatsächlich gestartet. --> Rückfrage beim Hersteller erforderlich.
Antwort Hersteller: "Ja, erst mit dem ersten Setpoint wird der Timeout scharf geschaltet." --> Damit ist das von mir beobachtete Verhalten nachvollziehbar.
@andig Seht ihr das als Edge-Case, da es nur relevant ist bis evcc neu gestartet wird? (Vermutlich ist der ganze Heartbeat an sich ein Edge-Case da das in Kombination mit evcc wohl nicht häufig genutzt werden wird...?) Oder wäre eine Änderung, dass der Heartbeat auch ohne evcc-Neustart aktiviert wird möglich? z.B. im Rahmen des charger logic errors, wenn die Wallbox sich unerwartet verhält.
Thanks for confirming with the manufacturer. That fits the code (charger/kathrein.go): the EMS timeout register (0x00A3) is read once in NewKathrein, and the heartbeat goroutine only starts if it is >0 then. Enabling the timeout in the wallbox while evcc runs leaves the heartbeat missing until the next restart. The timer only starts after the first setpoint write, which explains why it triggered hours later.
So this is a limitation of the current heartbeat design rather than a random failure. A fix would be to run the heartbeat always and re-read the timeout register each cycle, skipping the write when it is 0. That needs a maintainer decision, as it adds a periodic register read. Workaround for now: restart evcc after changing the timeout in the wallbox.
Related: #34784 (introduced the heartbeat).
🤖 Generated with Claude Code
Seht ihr das als Edge-Case
Unbedingt, ja 👍🏻
Kann ich schwer dagegen argumentieren. 😉 Trotzdem danke fürs anschauen.
P.S.: Nach reboot passt es. Auch wenn es mich eben irritiert hat, das in keinem Log-Level zu sehen ist, dass der Heartbeat gesendet wird.