odometer added for vehicles json and psacc#3291
odometer added for vehicles json and psacc#3291andlem74 wants to merge 1 commit intoopenWB:masterfrom
Conversation
There was a problem hiding this comment.
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 anodometer_patternand populateCarState.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.
| 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)))) |
There was a problem hiding this comment.
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).
| 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)) |
There was a problem hiding this comment.
Der Code funktioniert. Anmerkung kann ignoriert werden.
UI openWB/openwb-ui-settings#952