From ef7b99e7e85250578e4dae648b62f0f69baab851 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 26 May 2026 20:29:08 +0200 Subject: [PATCH] collect: re-login on AuthentificationError after weconnect exhausts its own retry Co-Authored-By: Claude Sonnet 4.6 --- collect.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/collect.py b/collect.py index 0f015a3..4d28476 100644 --- a/collect.py +++ b/collect.py @@ -53,6 +53,7 @@ from datetime import datetime, timezone from pathlib import Path from server import log_config, network, we_connect +from weconnect.errors import AuthentificationError from server.data_model import ALL_DOMAINS, collect_snapshot, apply_procedural from server.storage_helpers import auto_out_path, load_last_24h_records, load_store, save_store from utils.jay_diff import jay_diff_full @@ -145,6 +146,12 @@ def run(args: argparse.Namespace) -> None: log.info("Record #%d saved at %s", len(store["records"]), snapshot["ts"]) except KeyboardInterrupt: raise + except AuthentificationError: + log.warning("Authentication error — re-logging in before next interval") + try: + wc.login() + except Exception: + log.exception("Re-login failed") except Exception: log.exception("Collection failed — will retry at next interval")