Skip to content

Feature fix charge costs - #4035

Merged
LKuemmel merged 41 commits into
openWB:feature_fix_charge_costsfrom
AlexanderHa98:feature_fix_charge_costs
Sep 30, 2026
Merged

LKuemmel merged 41 commits into
openWB:feature_fix_charge_costsfrom
AlexanderHa98:feature_fix_charge_costs

Conversation

@AlexanderHa98

Copy link
Copy Markdown
Contributor

No description provided.

LKuemmel and others added 30 commits September 18, 2026 12:42
…WB#3868)

* dimm kit: improve error handling, handle deleted output devices

* review, complete logging

* Apply batched suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fixes

* add pytest

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…hr (openWB#3968)

Nach PR openWB#3966 blockierte ein eingesteckter, aber unterhalb der Einschaltschwelle wartender Ladepunkt (Zustand NO_CHARGING_ALLOWED) weiterhin dauerhaft den
Reset von reserved_surplus/released_surplus - das ist aber der mit Abstand häufigste, langlebigste Zustand eines PV-ladenden Fahrzeugs. Jede Reservierung
wird jedoch bereits beim Übergang in diesen Zustand freigegeben (siehe zB Counter.reset_switch_on_off()), sodass er nie mit einer noch offenen Reservierung erreicht wird - er gehörte also nie in die Blockierliste.

Betroffen war zB ein Fall, in dem eine verwaiste reserved_surplus-Reservierung aus einem unterbrochenen Vorgang nie mehr zurückgesetzt wurde, wodurch die
Einschaltschwelle dauerhaft nicht mehr erreicht werden konnte (PV-Laden startet gar nicht mehr) - siehe Diskussion.

Ersetzt die 5 Einzelvergleiche + Chargepoint/Consumer-Fallunterscheidung + plug_state-Sonderfall durch eine einzige Zustandsliste der tatsächlich
reservierungshaltenden Zustände (PERFORMING_PHASE_SWITCH, PHASE_SWITCH_DELAY, SWITCH_OFF_DELAY, SWITCH_ON_DELAY), verifiziert gegen jede +=/-=-Stelle in
counter.py/ev.py/chargepoint.py.

references openWB#3908 (reply in thread)
…ssing (openWB#3970)

get_values() indexed received_topics[fault_state] directly, including
inside its own KeyError handler - if the paired internal chargepoint
hadn't published fault_state yet (startup, reconnect), the fallback
crashed on the exact same missing key instead of handling it.
* consumer: fix hierarchy, default usage

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…oad (openWB#3976)

start_finite_loop()'s fixed 1s collection window left little margin for
connection/handshake overhead when the paired internal chargepoint was
busy (eg mid-charge), occasionally causing get_values() to miss a
retained topic despite retain=True. Made the timeout configurable
(default unchanged for the other 17 call sites) and doubled it for
external_openwb specifically, which has to reliably collect ~20 topics
over a real network hop rather than one or two local values.
* add consumers; reorganize structure

* improve
)

calc_switch_off_threshold() liest fuer alle Lasten surplus.consumer.switch_off_threshold. surplus.vehicle.switch_off_threshold ist konfigurierbar, wird migriert und in der Debug-Ausgabe angezeigt, aber im Regelalgorithmus nirgends gelesen.

Die Migration verschiebt den alten pv_charging/switch_off_threshold nach surplus/vehicle/switch_off_threshold. Damit regeln bestehende Anlagen seit dem Update mit dem neu angelegten Consumer-Default 0 statt mit dem konfigurierten Wert.
)

* removing meter-only consumers from load management priority

* review

* extend for self_controlled

* Potential fix for pull request finding 'Preserve pre-existing empty groups during migration'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* EVU auf Auto entspricht Ja

* fix
* Add Bidi to instant-charging

* Update Koala-UI min/max DC-Sollleistung

* fix
)

ensure_valid_session_id() erneuerte die Session nur, wenn
check_valid_session_id() False war - die Funktion liefert aber "ist
ungültig" zurück, nicht "ist gültig". Dadurch wurde nie erneuert,
sobald session_id einmal None oder abgelaufen war: alle Anfragen
liefen dauerhaft mit sid=None und schlugen mit HTTP 403 fehl.

Umbenannt zu session_id_expired(), passend zum tatsächlichen
Rückgabewert.
… warten (openWB#4007)

* Peak Filter: bei Rückwärtssprüngen auf Wert größer/gleich Höchststand warten

* review
* Add Daikin, EGO and EMS-ESP consumer modules

* daikin: Air2Air-Fixes aus Review (Lena, PR openWB#3969) + neues Altherma-Modul

Air2Air: Name korrigiert ("Daikin Air2Air (HomeHub EKRHH)"), METER_ONLY entfernt
(keine Leistungsmessung verfügbar).

Neu: daikin_homehub_altherma - eigenes Modul für Daikin Altherma, da eigene
Modbus-Register (EKRHH Installer Reference Guide 4PDE744838, Kap. 9, separat von
Air2Air/Kap. 10). Register gegen das offizielle Handbuch geprüft:
- switch_on/off: Reg 56 (Smart-Grid-Modus), analog zu Air2Airs Reg 1000
- set_power_limit: Reg 58 (Allgemeine Leistungsbegrenzung, gilt laut Handbuch
  unabhängig vom Smart-Grid-Modus, anders als Reg 57)
- update: Input-Reg 51 (Stromverbrauch Wärmepumpe) - Altherma kann im Gegensatz
  zu Air2Air tatsächlich Leistung melden, daher METER_ONLY hier sinnvoll
* Add Mitsubishi and Gree AC consumer modules

* Mitsubishi/Gree: METER_ONLY entfernt, da keine Leistungsmessung

Beide Module haben keine update()-Funktion und liefern somit keine
Leistungsmessung; ConsumerUsage.METER_ONLY war daher nicht zutreffend.

* Gree: tcid im Bind-Request ergänzt (Review Lena)

cid muss beim Binden konstant "app" sein, tcid identifiziert das
Zielgerät per MAC - bestätigt gegen tomikaa87/gree-remote und
cmroche/greeclimate.
* Hierarchie: Entferne mit Verbraucher verknüpften Zähler

* flake8
* bat_all: restore Speicher-Vorrang beim Erholen von Mindest-SoC bis Maximal-SoC

* bat_all: Speicherleistung nicht ans Fahrzeug weitergeben, wenn Entladung nicht erlaubt ist
* Add acls

* Add load management prio to status
* Add Kermi, LG Therma V and Luxtronik consumer modules

* kermi, luxtronik: Skalierungsfaktoren korrigiert (Review openWB#3971)

Kermi Reg 301 (PV-Überschuss): war /10, muss *10 sein.
Luxtronik Reg 10301 (el. Leistung): war *10, muss *100 sein.
Reg 108 (Kermi) war bereits korrekt.
* add Mode Optimization

* check for valid OperatingMode
…penWB#4012)

* Lastmanagement: eigenen Ladestrom bei ein-/zweiphasigem Laden nicht mehr als Fremdlast zählen

_set_current_left() entschied per min(element_current) < 0, ob der Strom
eines Ladepunkts als Verbrauch oder Einspeisung zählt. Bei ein-/zweiphasigem
Laden reicht dafür schon minimales negatives Messrauschen auf einer
ungenutzten Phase - der eigene Ladestrom wurde dann nirgends vom
Zähler-Rohwert abgezogen, das Lastmanagement hielt die eigene Ladung für
Fremdlast (falsche "Maximalstromstärke erreicht"/Schieflast-Meldungen,
siehe Discussion openWB#3908). _set_power_left() hat exakt dasselbe Problem
nicht, da dort schon die Gesamtleistung statt einzelner Phasenströme
geprüft wird - jetzt angeglichen.

* Bidi-Entladung: eigene Hardware-Stromgrenze des Ladepunkts durchsetzen

check_min_max_current() rief check_cp_max_current() (setzt dc_max_current
des Ladepunkt-Templates durch) nur im Lade-Zweig auf, nicht beim Entladen
(BIDI_CHARGING, required_current < 0) - die vom Fahrzeug gemeldete
max_discharge_power wurde beachtet, die eigene Hardwaregrenze des
Ladepunkts nicht. Bug in openWB#3795, check_cp_max_current() behandelt negative
Werte bereits korrekt (Vorzeichen wird erhalten).
LKuemmel and others added 8 commits September 28, 2026 14:36
* Improve Log

* Move generate_totals-Logger in logger.py

* Fix

* Fix Circular Import

* Update .gitignore

* fix

* Ensure ramdisk folder exists

* retrigger Copilot

* Add Copilot suggestions

* fix
…oop (openWB#3232)

* tesla/powerwall: implement load management, add fail-fast handling and gateway diagnostics

- add structured HTTP error handling in PowerwallHttpClient
  - distinguish transport, HTTP and JSON parsing failures
  - support fail_fast=False for non-critical requests
  - track cycle_failed and cookie_renewed state across one polling cycle

- add fail-fast handling in device.py
  - stop remaining Tesla component updates once a critical Powerwall request fails
  - log native TCP connection state diagnostics via /proc/net/tcp(/tcp6)
  - emit periodic session / connection health logs
  - keep cookie reuse, but mark startup + reauth cycles explicitly

- reduce /api/status traffic in counter.py
  - fetch firmware only after startup or after a new auth cookie was negotiated
  - treat /api/status as non-critical so it cannot fail the whole cycle

- keep import/export counters based on aggregate["site"]["energy_imported/exported"]
  - do not use summed per-phase energy counters as meter source
  - keep /api/meters/site for phase details only
  - add derived fallback currents and signed power factors from P/Q/U when Tesla/Neurio currents are 0
  - expose additional diagnostics such as frequency / serial number
  - add throttled debug logging to compare aggregate counters with per-phase sums
  - restore aggregate-based site counters so load management works correctly again

* tesla/powerwall: simplify device/http client and keep cookie reauth handling

- remove session / connection diagnostics and analysis-only helpers
- remove /proc-based connection stats and periodic session logging
- keep fail-fast handling for the Tesla update cycle
- keep cookie reuse and 401/403 reauthentication flow
- keep support for non-critical requests via fail_fast=False
- reduce implementation closer to upstream while preserving Powerwall-specific fixes

* tesla/powerwall: simplify device/http client and keep local current fallback

- remove analysis-only diagnostics and session tracking from device.py
- remove connection stats and other debug-only helpers
- simplify http_client.py to a minimal request wrapper
- keep cookie reuse and 401/403 reauthentication flow in device.py
- use fail-fast handling in device.py via SingleComponentUpdateContext(..., reraise=True)
- move Tesla-specific robustness back into the counter module only
- keep aggregate["site"]["energy_imported/exported"] as sole source for EVU counters
- keep local current and power factor calculation when Neurio/Tesla returns only 0 currents
- remove /api/status handling from counter.py
- fix formatting / lint issues (newline at EOF, spaces instead of tabs)

* Fix Tesla error handling and compatibility note

- use central openWB component error handling
- remove Tesla-specific fail-fast handling
- rely on the shared HTTP response hook
- remove obsolete local API compatibility warning

* se standard error handling in Tesla counter

- remove _safe_float and module-specific defaults
- propagate HTTP errors to central error handling
- keep compatibility fallback for missing phase data
- calculate phase currents from P/Q/U when Tesla reports zero currents

* Fix Tesla module lint errors

* Adjust Tesla API compatibility note
* add error and warning icons to chargepoint table

* Align warning icons - remove extra warning column

* No tooltip for mobile - ellipsis title only if truncated
* add consumer temperature readings to consumer card

* check if temperature data is present

* use getValueObject for formatting
* Add M-TEC, Weishaupt and Xtherma consumer modules

* M-TEC: Reg 707 durch evcc-Quelle bestätigt, Kommentar aktualisiert

Reg 707 (elektrische Leistungsaufnahme) ist in evcc's mtec.yaml als
holding register mit scale 1 gelistet, identisch zu unserer Implementierung.

* Weishaupt: Reg 33126 entfernt (nicht verifizierbar), Xtherma: SG-Ready on/off ergänzt

Weishaupt: Reg 33126 (el. Leistungsaufnahme) ist weder in der offiziellen
Datenpunktliste (83807301) noch in einer ausgereiften Community-Implementierung
(OStrama/weishaupt_modbus) zu finden - update()/METER_ONLY entfernt,
SollwertPV (Reg 40002, offiziell dokumentiert) bleibt unverändert.

Xtherma: Reg 60 (SG-Ready-Modus) ergänzt switch_on/switch_off
(SUSPENDABLE_ONOFF), eigener 30min-Throttle laut Protokoll.
@AlexanderHa98
AlexanderHa98 force-pushed the feature_fix_charge_costs branch 2 times, most recently from 73b6aaa to 204981e Compare September 29, 2026 13:12
@AlexanderHa98
AlexanderHa98 force-pushed the feature_fix_charge_costs branch from 204981e to 685a68e Compare September 29, 2026 13:48
@AlexanderHa98
AlexanderHa98 force-pushed the feature_fix_charge_costs branch 7 times, most recently from 11e5889 to c894e6b Compare September 30, 2026 06:32
@LKuemmel
LKuemmel merged commit 440aaca into openWB:feature_fix_charge_costs Sep 30, 2026
3 checks passed
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.

8 participants