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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user