Repository navigation
Add vehicle BYD - #4085
Open
seaspotter wants to merge 6 commits into
Open
Add vehicle BYD#4085seaspotter wants to merge 6 commits into
seaspotter wants to merge 6 commits into
Conversation
…stream protocol issue)
_fetch_realtime() checked elecPercent is not None to detect real data, but the vehicleRealTimeRequest trigger response is a placeholder that already contains elecPercent=0 (not absent), so it was accepted immediately instead of waiting for the vehicleRealTimeResult poll. Confirmed via a clean upstream-pybyd-only test against the affected account: the backend returns real telemetry fine, so this was a bug in our own readiness check, not a BYD-side restriction. Ports pyBYD's own is_ready_raw() heuristic (onlineState/time/tire-pressure/ enduranceMileage) instead of the elecPercent check.
- Bisher hat jede openWB-Installation beim Login denselben hart codierten (und ungültig formatierten) Geräte-Fingerprint an BYD geschickt - aus Sicht des Backends ein klassisches Bot/Credential-Stuffing-Signal und ein plausibler Mitverursacher der beobachteten Login-Sperren. Jeder konfigurierte Account bekommt jetzt einen eigenen, zufälligen aber plausiblen Android-Fingerprint (gültige IMEI per Luhn-Prüfziffer, zufällige MAC, aus einem kleinen Pool echter Geräte), einmalig generiert und über den bestehenden retained-MQTT-Mechanismus dauerhaft gespeichert (analog zu key_expires_at bei myskoda), damit der Account immer als dasselbe Gerät auftritt. Pool/Generator von https://github.com/TA2k/ioBroker.byd (MIT) übernommen. - Ein fehlgeschlagener Login (falsches Passwort, Sperre durch gleichzeitig aktive Session, etc.) verbraucht einen von wenigen Versuchen, bevor der BYD-Account gesperrt wird. Neuer Cooldown von 1h nach jedem Login-Fehler, damit das reguläre Polling (alle 5min während des Ladens) den Account nicht einfach weiter verbrennt. - Veralteten Kommentar korrigiert, der behauptete, der VIN-Cache würde wie key_expires_at bei myskoda dauerhaft gespeichert - tut er nicht (kein Pub()-Aufruf dafür), nur der Geräte-Fingerprint jetzt tatsächlich.
vehicle ist zwar als int typisiert, wird vom Aufrufer (subdata.py, direkt aus dem MQTT-Topic geparst) aber tatsächlich als str übergeben - bestätigt durch einen echten Crash beim ersten Live-Test. Betraf sowohl die neue Fingerprint-Logzeile in soc.py als auch eine bereits bestehende Logzeile in api.py (Session-Ablauf-Meldung). Beide auf %s umgestellt.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Authentication recovery, concurrent multi-vehicle accounts, account-scoped fingerprints, VIN ambiguity, and upstream license notices need correction.
7 open findings
Reject ambiguous VIN omission for multi-vehicle accounts · New Serialize per-account session login and cache updates · New Authentication errors are swallowed during poll retries · New Retry authentication during VIN resolution · New Persist device fingerprints at account scope · New Include pyBYD copyright and MIT notice · New Include ioBroker.byd MIT notice · New
What changed in this PR
Adds an unofficial BYD Cloud vehicle module for retrieving SoC, range, and odometer data.
Changes:
- Implements encrypted BYD API authentication and polling.
- Adds session caching, login cooldowns, and device fingerprints.
- Integrates BYD configuration and vehicle-state updates.
| File | Description |
|---|---|
packages/modules/vehicles/byd/__init__.py |
Defines the BYD package. |
packages/modules/vehicles/byd/api.py |
Implements Cloud API communication and state extraction. |
packages/modules/vehicles/byd/bangcle_tables.bin |
Provides Bangcle cipher lookup tables. |
packages/modules/vehicles/byd/config.py |
Defines module configuration. |
packages/modules/vehicles/byd/crypto.py |
Implements encryption, signing, and key derivation. |
packages/modules/vehicles/byd/device_fingerprint.py |
Generates Android device identities. |
packages/modules/vehicles/byd/soc.py |
Connects the module to openWB vehicle updates. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



UI: openWB/openwb-ui-settings#1121
Neues Fahrzeug-(SoC)-Modul
byd: liest SoC, Reichweite und Kilometerstand über die BYD-Cloud-API. Protokoll reverse-engineered von pyBYD (MIT) und ioBroker.byd (MIT), synchron mitrequestsnachgebaut (pyBYD selbst braucht Python ≥3.11, openWB läuft auf 3.9).official=False.Wichtig: BYD erlaubt nur eine aktive Sitzung pro Account – ein zweiter/geteilter Account ist nötig (Workaround in der UI dokumentiert, siehe separater UI-PR). Ein fehlgeschlagener Login wird daher 1h pausiert, um keine Login-Versuche zu verbrennen. Jeder Account bekommt außerdem einen eigenen, zufälligen Geräte-Fingerprint statt eines global geteilten (wirkte sonst wie ein Bot-Signal).
Live getestet über den normalen Control-Loop: Login, Fingerprint-Generierung, VIN-Auflösung und SoC-Abruf erfolgreich. flake8 sauber, volle Testsuite ohne Regressionen. Hybrid-Fahrzeuge (
energy_type) technisch unterstützt, aber nur an einem reinen EV-Account getestet.