Skip to content

Add experimental MyNISSAN EU vehicle SoC support - #4088

Open
wippofax wants to merge 3 commits into
openWB:masterfrom
wippofax:nissan-mynissan-eu
Open

wippofax wants to merge 3 commits into
openWB:masterfrom
wippofax:nissan-mynissan-eu

Conversation

@wippofax

@wippofax wippofax commented Oct 10, 2026 •

Copy link
Copy Markdown

The existing Leaf integration uses a different Nissan service. This adds nissanconnect for European MyNISSAN accounts, exposing cached battery SoC, original measurement time, and range and odometer when available through openWB's existing vehicle interfaces. The display name is Nissan – MyNISSAN EU (experimental). Only Leaf ZE1 has positive practical test reports; other models are unverified.

Odometer retrieval is automatic after successful battery retrieval, subject to retry pauses and the request budget; there is no separate user setting. A missing, invalid or failed odometer result does not invalidate valid SoC. Nissan supplies no odometer measurement time, so neither battery time nor retrieval time replaces it.

The standard-library client reuses in-memory tokens, honors backoff/rate limits and validates measurements. It sends no wakeup or charging commands. Existing Core scheduling, fallback and charge policy remain unchanged, including its zero-SoC error behavior. Diagnostics distinguish request and measurement times and exclude account identifiers and tokens; battery values/times remain private.

Scheduled-query diagnostics include HTTP request totals for the rolling last 24 hours, since local midnight and since observation started, with the start timestamp and coverage flags. History is held only in the configured vehicle module's memory and resets on restart/recreation. Separate settings tests and other vehicle instances are not combined. No new storage, MQTT topic or rate-limit policy is added.

The companion settings contribution provides a form and passive unsaved connection test. This patch owns its stdin-only Python worker; settings owns and builds both PHP endpoints. The test does not save configuration or publish battery values to charging control. Internal source, tests, tools and documentation are separated; native module and worker entry paths remain.

Validation

  • Python 3.9.2: 145 synthetic module tests passed, with two POSIX timezone cases skipped on Windows. Linux Python 3.13.5 passes all 29 diagnostic/counter tests, including the timezone cases for 23-hour and 25-hour days. Tests block real network access and cover isolated direct worker/probe startup. Changed-source Flake8, autopep8 consistency, links and whitespace pass.
  • Corresponding PHP tests passed on Linux (57 tests, one platform skip) and Windows (46 tests, 12 Linux-only skips). PHP sources now belong to the companion settings contribution.
  • A private tester reports successful settings/connection tests, good operation on a 2019 Leaf ZE1 with openWB 2.2.3, and visible request counters after the final update. This does not separately establish odometer accuracy, sustained token renewal, every charging limit or other vehicles. No private data is included.
  • Publication secret scans passed review: the sole Core finding is the unchanged public OAuth application identifier, not an account secret. No scanner suppression was added.
  • One contribution commit; its tree is identical to the tested development tree. Mergeability was verified without conflicts against Core master c477f77 on 2026-10-10.

These are local affected-area checks. The complete Core suite could not load its shared Windows fixtures because the existing ocpp dependency is absent and a broker error path requires /proc/cpuinfo. The full Nissan-module run under Linux reached 144 passing cases but three adapter fixtures lacked paho; the focused 29-case Linux run passes, and the adapter cases pass in the prepared Python 3.9 Windows environment. Normal Linux CI remains needed; no dependency or shared Core workaround is included. Hosted CI had not run before submission.

Integration and review boundaries

Review together with the companion settings PR. It delivers the endpoints from public/modules/vehicles through the normal settings build, following the existing BMW/Porsche layout. No full compiled UI archive, dependency upgrade or shared Core/theme change is included.

Specific permission for this unofficial app-API access has not been established. The source license does not settle Nissan service access. The module's docs/user-information.md explains this limit, ordinary credential storage, private logs/backups and the absence of fresh-vehicle guarantees. NOTICE retains source attribution.

Inherited Core debug-log redaction can leave account identifiers or password fragments visible. This remains a maintainer follow-up; the module excludes credentials from its own diagnostics and does not patch shared logging policy. The notices are not a security fix or a claim of GDPR compliance. Maintainer acceptance of unofficial service access and these boundaries remains a review decision.

Add the nissanconnect vehicle module with validated battery, range and
automatic odometer retrieval through the European MyNISSAN service.
Reuse tokens, honor request backoff and expose private diagnostics
with request counts without changing shared charging policy.

Include an isolated connection-test worker, synthetic tests and
documentation of service-access, privacy and tested-model limits.
The companion settings contribution owns the form and PHP endpoints.
@seaspotter

seaspotter commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Danke für die Arbeit, aber das ist für ein Fahrzeug-Modul deutlich zu viel Umfang (2570 Zeilen/22 Dateien hier, 2085 Zeilen/16 Dateien im UI-PR). Zum Vergleich lohnt sich ein Blick auf andere Fahrzeug-Module hier im Repo, z.B. myskoda, vweuda, renault oder auch byd/saic_ismart (#4085 / openWB/openwb-ui-settings#1121 bzw. den direkten SAIC-PR) - die decken ähnlich komplexe Cloud-Logins/Protokolle ab, kommen aber mit einem Bruchteil des Codes aus. Da hat deine KI echt viel zu viel Oberhead erzeugt. Konkret würde ich folgendes kürzen:

Core-Seite:

  • NOTICE.md, README.md, docs/diagnostics.md, docs/privacy.md, docs/source-map.md, docs/user-information.md (~560 Zeilen) - kein anderes Fahrzeugmodul hat eigene Doku-Dateien. Die Quellen-Attribution gehört als kurzer Docstring-Kommentar ins jeweilige File (3-4 Zeilen, siehe byd/api.py oder saic_ismart/api.py), nicht als separate Dateien.
  • src/, tools/, tests/-Unterordner inkl. CLI-probe.py: jedes andere Modul hält api.py/config.py/soc.py direkt im Modul-Root.
  • src/api.py baut den HTTP-Transport komplett neu mit urllib.request/http.client/ssl/CookieJar - bitte stattdessen modules.common.req.get_http_session() nutzen, das jedes andere Modul (inkl. myskoda, vweuda, byd, saic_ismart) verwendet.
  • Eigenes 24h-Request-Zähler-/Diagnose-System plus mehrstufige Backoff-Policy: Die Abfrage-Intervalle (request_interval_charging/request_interval_not_charging) regelt Core bereits generisch pro Fahrzeug - ein Modul sollte einfach abfragen und bei Fehler eine Exception werfen, mehr nicht.
  • NissanConnectConfiguration/NissanConnect per Hand mit __init__ statt @dataclass - alle anderen Module nutzen durchgängig @dataclass.
  • 7 Testdateien (~1080 Zeilen) sind für ein Modul dieser Größe unverhältnismäßig - wenn Tests, dann reicht ein fokussiertes api_test.py wie bei porsche oder saic_ismart.

UI-Seite (openWB/openwb-ui-settings#1123):

  • docs/, scripts/prepare-nissanconnect-2.2.3.py, die komplett neue PHP-Backend-Connection-Test-Route (connection_test_lib.php/test_connection.php) und das 512-Zeilen-Jest-Spec: kein anderes Fahrzeugmodul hat einen eigenen Connection-Test-Endpunkt - ein einfaches Formular wie bei myskoda/renault/byd reicht.
  • Änderungen an .github/workflows/node.js.yml sowie an geteilten Dateien (App.vue, ComponentState.vue, VehicleConfiguration.vue) sollten für ein einzelnes neues Fahrzeugmodul nicht nötig sein.

Insgesamt: bitte auf die Größenordnung der bestehenden Module einpendeln (ein paar hundert Zeilen Code, kurze PR-Beschreibung) statt eigener Doku-/Test-/Tooling-Infrastruktur pro Modul. Das macht es fürs Team auch deutlich leichter, das sinnvoll zu reviewen.

Use shared HTTP sessions and dataclasses in five flat module files.
Keep SoC, measurement time, range and odometer; Core owns polling.
Remove custom backoff, counters, connection tests, CLI and extra docs.
Retain inline attribution and scoped filtering of sensitive HTTP logs.
Validate with 48 focused API tests and a successful Leaf ZE1 SoC trial.
@wippofax

Copy link
Copy Markdown
Author

Valider Einwand. Ich fand die Einstellungsseite zwar schick, komfortabel und sinnvoll, aber mit der nun überarbeiteten Version ist der Code, zugegeben, schon deutlich überschaubarer.

@LKuemmel
LKuemmel self-requested a review October 13, 2026 14:28
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.

2 participants