Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/control/chargepoint/chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,16 @@ def update(self, ev_list: Dict[str, Ev]) -> None:
# OCPP Start Transaction nach Anstecken
if ((self.data.get.plug_state and self.data.set.plug_state_prev is False) or
(self.data.set.ocpp_transaction_id is None and self.data.get.charge_state)):
self.data.set.ocpp_transaction_id = data.data.optional_data.start_transaction(
self.data.config.ocpp_chargebox_id,
self.chargepoint_module.fault_state,
self.num,
self.data.set.rfid or self.data.get.rfid or self.data.get.vehicle_id,
self.data.get.imported)
# Starte nur Transaction wenn auch die chargepoint ID im Backend gesetzt wurde
if self.data.config.ocpp_chargebox_id:
# Starte nur Transaction wenn bereits ein RFID Tag oder die Fahrzeug ID erkannt wurde
if (self.data.set.rfid or self.data.get.rfid or self.data.get.vehicle_id):
self.data.set.ocpp_transaction_id = data.data.optional_data.start_transaction(
self.data.config.ocpp_chargebox_id,
self.chargepoint_module.fault_state,
self.num,
self.data.set.rfid or self.data.get.rfid or self.data.get.vehicle_id,
self.data.get.imported)
Comment on lines 702 to +714
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

This change makes start_transaction() conditional on an RFID tag / vehicle ID being present. That’s consistent with the intent, but it will break the current unit test expectation in packages/control/ocpp_test.py::test_start_transaction (it asserts a call with id_tag=None). Please update the test (e.g., set cp.data.get.vehicle_id or cp.data.set.rfid before cp.update(...)) to reflect the new behavior.

Copilot uses AI. Check for mistakes.
if self.data.get.plug_state and self.data.set.plug_state_prev is False:
self.data.control_parameter.timestamp_chargemode_changed = create_timestamp()
# SoC nach Anstecken aktualisieren
Expand Down
2 changes: 2 additions & 0 deletions packages/control/ocpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ def transfer_values(self: OptionalProtocol,
chargebox_id: str,
fault_state: FaultState,
connector_id: int,
transaction_id: int,
imported: int) -> None:
try:
self._process_call(chargebox_id, fault_state, call.MeterValues(
connector_id=connector_id,
transaction_id=transaction_id,
meter_value=[{"timestamp": self._get_formatted_time(),
"sampledValue": [
{
Expand Down
1 change: 1 addition & 0 deletions packages/control/ocpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def mock_data() -> None:
def test_start_transaction(mock_data, monkeypatch):
cp = Chargepoint(1, None)
cp.data.config.ocpp_chargebox_id = "cp1"
cp.data.set.rfid = "ABCDEF01234567"
cp.data.get.plug_state = True
cp.template = CpTemplate()
cp.chargepoint_module = ChargepointModule(Mqtt())
Expand Down
2 changes: 1 addition & 1 deletion packages/control/optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ def _transfer_meter_values(self):
if cp.data.set.ocpp_transaction_id is not None:
self.send_heart_beat(cp.data.config.ocpp_chargebox_id, cp.chargepoint_module.fault_state)
self.transfer_values(cp.data.config.ocpp_chargebox_id,
cp.chargepoint_module.fault_state, cp.num, int(cp.data.get.imported))
cp.chargepoint_module.fault_state, cp.num, cp.data.set.ocpp_transaction_id, int(cp.data.get.imported))
except Exception:
log.exception("Fehler im OCPP-Optional-Modul")