Commit 3c9af4d
committed
fix(eu-data-act): mileage stuck at lower of two reported values
Real-world dataset (VW_connect.json) showed VW emitting two mileage.value
slots in the same /list payload:
idx=11 uuid=69d437d3... value=82 (current odometer)
idx=60 uuid=30cc36fd... value=71 (lagging snapshot from older report)
The previous 'smallest UUID wins' tie-break inherited from the original
HA reference picked 30cc36fd → state stayed at 71 even after a fresh
download. Tibber and the in-car display showed 82; the adapter would
not update until the lagging UUID disappeared from the portal (didn't
happen on its own, even across Adapter Stop/Start).
Fix mirrors what mikrohard/HA_VAG-EU-Data-Act does in its fork:
- Generic case: pick the LAST occurrence in the ZIP array. The portal
bundles minute-level snapshots in array order, so the last duplicate
is the best proxy for the freshest value.
- Monotonic fields (mileage.value, mileage): pick the LARGEST numeric
value. Lagging snapshots can never read higher than the true current
odometer, so the max is correct by construction. Sequence number ties
break equal values.
Verified against the user's real dataset:
before fix: mileage.value = 71
after fix: mileage.value = 82 (correct)
No timestampUtc per item to read (verified: 0 / 113 items in the sample
carry one), so we don't use the timestamp-based ranking the HA fork
adds — array position is the only signal available.1 parent b51826d commit 3c9af4d
1 file changed
Lines changed: 43 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
320 | 329 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
325 | 342 | | |
326 | 343 | | |
327 | 344 | | |
328 | 345 | | |
| 346 | + | |
329 | 347 | | |
330 | 348 | | |
331 | 349 | | |
332 | 350 | | |
333 | 351 | | |
| 352 | + | |
334 | 353 | | |
335 | | - | |
| 354 | + | |
336 | 355 | | |
337 | 356 | | |
338 | 357 | | |
339 | 358 | | |
340 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
341 | 377 | | |
342 | 378 | | |
| 379 | + | |
343 | 380 | | |
344 | 381 | | |
345 | 382 | | |
| |||
0 commit comments