Skip to content

Nissan: Aktive Batterieabfrage beim Anstecken und während der Ladung - #4230

Open
wippofax wants to merge 3 commits into
openWB:masterfrom
wippofax:nissan-active-battery-refresh-pr
Open

wippofax wants to merge 3 commits into
openWB:masterfrom
wippofax:nissan-active-battery-refresh-pr

Conversation

@wippofax

@wippofax wippofax commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor
  • Fragt nach jedem neu erkannten Anstecken und während der Ladung aktiv Batteriedaten vom Fahrzeug ab. Dabei kann das Fahrzeug aufgeweckt werden.
  • Jedes erkannte neue Anstecken erlaubt einen Versuch; während der Ladung höchstens stündlich. Ladepausen ohne Abstecken setzen den Abstand nicht zurück.
  • Begrenzt die Statusabfragen und liest bei Fehlern weiterhin gespeicherte Daten mit ihrem tatsächlichen Messzeitpunkt.
  • Mit einem Leaf ZE1 getestet.

Summary by Sourcery

Allow Nissan vehicles to request an active battery refresh on plug-in or while charging, while preserving normal cached-data reads when refreshes fail.

New Features:

  • Add active Nissan battery refresh on newly detected plug-in and during charging.

Bug Fixes:

  • Preserve passive battery and odometer reads when an active refresh fails, without replaying the refresh command.

Enhancements:

  • Limit active refresh attempts to once per hour during charging while allowing each newly detected plug-in to trigger an attempt, including after brief unplug/replug cycles.
  • Bound refresh-status polling and retain Nissan's actual battery measurement timestamp.

Tests:

  • Add coverage for plug-in and charging triggers, hourly throttling, bounded polling, refresh failures, and command replay prevention.

UI openWB/openwb-ui-settings#1152 (review)

Request battery updates once per newly observed plug-in and at most hourly during charging. Bound status polling, tolerate transient status transport failures, and retain passive reads with manufacturer timestamps when refresh fails.

Keep the option disabled by default, use a fresh connection for the single command, and preserve the upstream HTTP response test fixture correction.
CI enables global DEBUG logging, so requests_mock logs synthetic vehicle and action URLs that trigger the privacy assertions. Set only its adapter logger to WARNING in the HTTP fixture; caplog restores the level after each test. Real HTTP and module logging remain covered.
user_id: Optional[str] = field(default=None, repr=False)
password: Optional[str] = field(default=None, repr=False)
vin: Optional[str] = field(default=None, repr=False)
refresh_while_charging: bool = False

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.

Muss das einstellbar sein?
Wenn es bei allen Fahrzeugen funktioniert, ist es besser, es nicht einstellbar zu machen und immer anzuwenden, dann hat man ein stabileren SoC.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ich brauch das nicht einstellbar. Der ursprüngliche Gedanke war, dass es ggf. zu viele Abfragen bei der NissanCloud werden. Aber soo oft und lang lädt man auch nicht, dass das überstrapaziert würde - so zumindest die Hoffnung.
Getestet habe ich das nur auf meiner Wallbox und nur mit einem Leaf ZE1, für andere Modelle kann ich es nicht bestätigen.
Ich habe die Option entfernt, die Abfrage ist jetzt immer aktiv: einmal nach jedem neu erkannten Anstecken und während der Ladung höchstens einmal pro Stunde.

In openWB/openwb-ui-settings#1152 entfällt der Schalter, dort ändert sich nur noch der Hinweistext.

Remove the refresh_while_charging option as requested in review. The
vehicle is asked for new data once per newly observed plug-in and at most
hourly while charging; all other reads stay passive. Failed refreshes
still fall back to cached data with its original timestamp.
@wippofax wippofax changed the title Nissan: Optionale aktive Batterieabfrage Nissan: Aktive Batterieabfrage beim Anstecken und während der Ladung Nov 30, 2026
@wippofax
wippofax requested a review from LKuemmel November 30, 2026 21:10
@LKuemmel LKuemmel added this to the 2.5.0 milestone Dec 1, 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.

2 participants