Skip to content

odometer added for vehicles json and psacc#3291

Open
andlem74 wants to merge 1 commit intoopenWB:masterfrom
andlem74:psacc-json-odometer
Open

odometer added for vehicles json and psacc#3291
andlem74 wants to merge 1 commit intoopenWB:masterfrom
andlem74:psacc-json-odometer

Conversation

@andlem74
Copy link
Copy Markdown
Contributor

@andlem74 andlem74 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds odometer support to the JSON vehicle SOC integration and wires a default odometer JQ pattern for the PSACC vehicle configuration.

Changes:

  • Extend JsonSocConfiguration / JSON SOC flow to accept + compile an odometer_pattern and populate CarState.odometer.
  • Add JSON SOC unit tests covering odometer extraction and the “no odometer pattern” case.
  • Configure PSACC to provide an odometer JQ pattern (.timed_odometer.mileage).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/modules/vehicles/psacc/config.py Adds an odometer JQ pattern to the PSACC JSON-based configuration.
packages/modules/vehicles/json/config.py Extends JSON SOC configuration with odometer_pattern.
packages/modules/vehicles/json/soc.py Compiles/uses odometer_pattern and returns CarState(..., odometer=...); updates CLI logging/signature.
packages/modules/vehicles/json/test_json_soc.py Updates and extends tests to assert CarState.odometer behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 110 to 116
store.get_car_value_store(charge_point).store.set(
fetch_soc(JsonSocSetup(configuration=JsonSocConfiguration(url=url,
soc_pattern=soc_pattern,
range_pattern=range_pattern,
timestamp_pattern=timestamp_pattern,
odometer_pattern=odometer_pattern,
calculate_soc=calculate_soc))))
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

json_update calls fetch_soc(...) without passing a compiled_queries dict, but fetch_soc requires it and indexes keys like compiled_queries["soc"]/["odometer"]. This will raise a TypeError at runtime. Consider creating a local compiled_queries dict in json_update, calling initialize_vehicle(...), and then calling fetch_soc(config, compiled_queries) (or alternatively adjust fetch_soc to compile queries internally when none are provided).

Suggested change
store.get_car_value_store(charge_point).store.set(
fetch_soc(JsonSocSetup(configuration=JsonSocConfiguration(url=url,
soc_pattern=soc_pattern,
range_pattern=range_pattern,
timestamp_pattern=timestamp_pattern,
odometer_pattern=odometer_pattern,
calculate_soc=calculate_soc))))
vehicle_config = JsonSocSetup(configuration=JsonSocConfiguration(url=url,
soc_pattern=soc_pattern,
range_pattern=range_pattern,
timestamp_pattern=timestamp_pattern,
odometer_pattern=odometer_pattern,
calculate_soc=calculate_soc))
compiled_queries = {
'soc': None,
'range': None,
'timestamp': None,
'odometer': None
}
initialize_vehicle(vehicle_config, compiled_queries)
store.get_car_value_store(charge_point).store.set(fetch_soc(vehicle_config, compiled_queries))

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Der Code funktioniert. Anmerkung kann ignoriert werden.

@LKuemmel LKuemmel added this to the 2.2.1 milestone Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants