Repository navigation
Feature/bmw cardata - #3322
Feature/bmw cardata#3322
Conversation
Add BMW CarData SoC module - auth wrapper scripts Add auth_start.py and auth_status.py as wrapper scripts for the BMW CarData authentication flow.
Fix auth UI: show user_code regardless of connection state, simplify auth button
Add odometer support via vehicle.vehicle.travelledDistance
…ponse.status_code
Remove ineffective general_config defaults, add kombiRemainingElectricRange fallback, sync token to all BMW CarData vehicles on refresh
There was a problem hiding this comment.
Pull request overview
This PR addresses BMW CarData edge cases after the initial merge, mainly improving multi-vehicle token handling and adding compatibility for older BMW models’ range reporting.
Changes:
- Synchronizes refreshed BMW OAuth tokens to other BMW CarData vehicles sharing the same
client_idby publishing updated configs via MQTT. - Adds a fallback for vehicle range using
kombiRemainingElectricRangewhenremainingElectricRangeis missing. - Threads the
vehicleid throughcreate_vehicle()→fetch_soc()→get_valid_token()(though it’s currently unused inget_valid_token).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| range_raw = _extract_value(td, FIELD_RANGE) | ||
| if range_raw is None: | ||
| range_raw = _extract_value(td, FIELD_RANGE_ALT) |
There was a problem hiding this comment.
FIELD_RANGE_ALT is used as a fallback when parsing telematics data, but the container is created with CONTAINER_DESCRIPTORS that currently does not include vehicle.drivetrain.electricEngine.kombiRemainingElectricRange. For vehicles that only expose the kombi field, the API may never return it, leaving range_raw as None. Add the alt descriptor to CONTAINER_DESCRIPTORS (and consider forcing a container re-create when range is missing and the container was created without this descriptor).
LKuemmel
left a comment
There was a problem hiding this comment.
Bitte noch die Copilot-Kommentare durchschauen, die Unit-Tests würde ich als optional ansehen.
Move control import to module level, add kombiRemainingElectricRange to container descriptors, auto-recreate container when range is missing
Add test for kombiRemainingElectricRange range fallback
* Add initial BMW CarData vehicle module with UI * Add files via upload Add BMW CarData SoC module - auth wrapper scripts Add auth_start.py and auth_status.py as wrapper scripts for the BMW CarData authentication flow. * Add files via upload * Add files via upload * Create bmw_cardata * Delete web/bmw_cardata * Create bmw_cardata_auth_start.php * Add files via upload * Add files via upload * Delete packages/modules/vehicles/bmw_cardata/auth.py * Delete packages/modules/vehicles/bmw_cardata/auth_start.py * Delete packages/modules/vehicles/bmw_cardata/auth_status.py * Add files via upload Fix auth UI: show user_code regardless of connection state, simplify auth button * Add files via upload Add odometer support via vehicle.vehicle.travelledDistance * Add files via upload * Add unit tests for BMW CarData SoC module * Remove test mode, add auth status fields for broker integration * Replace urllib with req.get_http_session(), remove test mode * Remove test mode UI, simplify settings, update API limit hints * Store auth data in broker via updateConfiguration, send to PHP on poll * Update Remove status file, return all auth data to UI for broker storage Remove status file, return all auth data to UI for broker storage * Fix unit tests: use requests mock, add container_id to test config * Improve auth status error handling, add explicit error cases * Refactor soc.py: extract helper functions, improve error handling * Update soc_test.py * Update soc_test.py * Remove legacy CLI path, improve container recovery with HTTPError.response.status_code * Add tests for token refresh, container auto-create and retry flow * Add CURLOPT_SSL_VERIFYHOST=2 for TLS hostname validation * Add CURLOPT_SSL_VERIFYHOST=2 for TLS hostname validation * Return HTTP 400 on missing client_id * Remove vehicle.vue - moved to openwb-ui-settings repo * Move PHP auth files to public/modules/vehicles/bmw_cardata/ * Move PHP auth files to public/modules/vehicles/bmw_cardata/ * Fix W292: add newline at end of file * Fix W292: add newline at end of file * Fix W292: add newline at end of file * Fix W292: add newline at end of file * Add files via upload * Update soc_test.py * Remove unused imports HTTPError and store * ix W292/W391 whitespace issues * Add default request intervals to prevent API rate limit * Add kombiRemainingElectricRange as fallback for range field (BMW i3 compatibility) * Update soc.py Remove ineffective general_config defaults, add kombiRemainingElectricRange fallback, sync token to all BMW CarData vehicles on refresh * Update soc.py Move control import to module level, add kombiRemainingElectricRange to container descriptors, auto-recreate container when range is missing * Update soc_test.py Add test for kombiRemainingElectricRange range fallback --------- Co-authored-by: Dennis <[email protected]>
BMW CarData – Bugfixes und Erweiterungen
Folgende fixes nach dem initialen Merge:
Token-Synchronisation bei mehreren Fahrzeugen
Bei zwei BMW Fahrzeugen auf demselben Account (gleiche Client ID) wurde beim Token-Refresh der alte Token invalidiert. Nach einem erfolgreichen Token-Refresh werden die neuen Tokens jetzt automatisch an alle anderen BMW CarData Fahrzeuge mit derselben Client ID weitergegeben.
Reichweite für ältere BMW Modelle (i3)
Der BMW i3 liefert
kombiRemainingElectricRangestattremainingElectricRange. Dieses Feld wird jetzt als Fallback unterstützt.Hinweis für Nutzer mit zwei Fahrzeugen
Nur Fahrzeug 1 muss gekoppelt werden. Fahrzeug 2 erhält die Tokens automatisch beim nächsten Token-Refresh von Fahrzeug 1.