collect: fix stale vehicle ref after token re-login; increase update verbosity

After a full re-login (doLogin), the library rebuilds its vehicle list with
new objects. The old vehicle reference in the collect loop was never updated
again, causing data to silently freeze. Re-select the vehicle from wc.vehicles
after every update() call to stay on the current object.

Also: update() now returns and logs its bool result; the record log line shows
which top-level keys changed each cycle (or "none" when the backend returned
identical data).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 12:31:30 +02:00
co-authored by Claude Sonnet 4.6
parent b75c4fe411
commit 6fb9e624e4
2 changed files with 28 additions and 4 deletions
+8 -2
View File
@@ -60,5 +60,11 @@ def select_vehicle(wc: _Session, vin: str | None):
return vehicles[0], None
def update(wc: _Session) -> None:
wc.run(wc.connection.update())
def update(wc: _Session) -> bool:
"""Run one update cycle. Returns True if the library reported success."""
ok = wc.run(wc.connection.update())
if not ok:
log.warning("connection.update() returned False — data may not have refreshed")
else:
log.debug("connection.update() succeeded")
return bool(ok)