Repository navigation
fix ioBroker SoC - #4267
fix ioBroker SoC#4267
Conversation
…or staleness detection
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates ioBroker SoC timestamp handling to use File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/modules/vehicles/iobroker/soc.py" line_range="35" />
<code_context>
f"Ungültiger SoC-Wert {soc}% von State '{cfg.state_soc}' erhalten "
"(erwartet: 0-100). Bitte State-ID und Skalierung in ioBroker prüfen.")
- soc_timestamp = int(soc_state['ts'] / 1000) if soc_state.get('ts') else None
+ soc_timestamp = int(soc_state['lc'] / 1000) if soc_state.get('lc') else None
if cfg.state_range is None or cfg.state_range == "":
</code_context>
<issue_to_address>
**Old SoC readings appear fresh**
When the state's last-changed time is absent, zero, or differs from the request time, `fetch_soc` uses `lc` for `soc_timestamp`, so ioBroker timestamps no longer mean the documented last-request time. When `lc` is absent or zero, `fetch_soc` passes `None` to `CarState`, which substitutes the current time and lets `ConfigurableVehicle` accept stale SoC as fresh.
Use the state's request timestamp (`ts`) for `soc_timestamp` to preserve the documented meaning and avoid treating an absent `lc` as a current timestamp.
</issue_to_address>| f"Ungültiger SoC-Wert {soc}% von State '{cfg.state_soc}' erhalten " | ||
| "(erwartet: 0-100). Bitte State-ID und Skalierung in ioBroker prüfen.") | ||
| soc_timestamp = int(soc_state['ts'] / 1000) if soc_state.get('ts') else None | ||
| soc_timestamp = int(soc_state['lc'] / 1000) if soc_state.get('lc') else None |
There was a problem hiding this comment.
🟡 Medium · Old SoC readings appear fresh
When the state's last-changed time is absent, zero, or differs from the request time, fetch_soc uses lc for soc_timestamp, so ioBroker timestamps no longer mean the documented last-request time. When lc is absent or zero, fetch_soc passes None to CarState, which substitutes the current time and lets ConfigurableVehicle accept stale SoC as fresh.
Use the state's request timestamp (ts) for soc_timestamp to preserve the documented meaning and avoid treating an absent lc as a current timestamp.
Prompt for AI agents
In `packages/modules/vehicles/iobroker/soc.py` at line 35:
**Old SoC readings appear fresh**
When the state's last-changed time is absent, zero, or differs from the request time, `fetch_soc` uses `lc` for `soc_timestamp`, so ioBroker timestamps no longer mean the documented last-request time. When `lc` is absent or zero, `fetch_soc` passes `None` to `CarState`, which substitutes the current time and lets `ConfigurableVehicle` accept stale SoC as fresh.
Use the state's request timestamp (`ts`) for `soc_timestamp` to preserve the documented meaning and avoid treating an absent `lc` as a current timestamp.
Use 'lc' (last changed) instead of 'ts' (last update)
Summary by Sourcery
Bug Fixes: