Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/modules/vehicles/iobroker/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def fetch_soc(config: IoBrokerSocSetup) -> CarState:
raise ValueError(
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.


if cfg.state_range is None or cfg.state_range == "":
range = None
Expand Down