Skip to content

rfid: improve clear rfid#3197

Draft
LKuemmel wants to merge 3 commits intoopenWB:masterfrom
LKuemmel:rfid
Draft

rfid: improve clear rfid#3197
LKuemmel wants to merge 3 commits intoopenWB:masterfrom
LKuemmel:rfid

Conversation

@LKuemmel
Copy link
Contributor

@LKuemmel LKuemmel commented Mar 10, 2026

  • Tag am Display eingeben
  • RFID an Duo scannen, vor dem Anstecken, LP freischalten
  • RFID an Duo scannen, nach dem Anstecken, LP freischalten & Fahrzeug zuordnen
  • RFID scannen, 5 Min kein Auto anstecken
  • RFID scannen, danach Tag am Display eingeben

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve RFID handling around chargepoints, especially clearing RFID tags after they’ve been received/processed.

Changes:

  • Only publish /get/rfid when a non-None RFID value is present.
  • Trigger chargepoint_module.clear_rfid() automatically when a /get/rfid update is received.
  • Remove direct clear_rfid() calls from the control RFID flow and adjust typing/protocol definitions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/modules/common/store/_chargepoint.py Publish /get/rfid only when an RFID value is present.
packages/modules/chargepoints/openwb_pro/chargepoint_module.py Removes the (stub) clear_rfid() method from the OpenWB Pro chargepoint module.
packages/helpermodules/subdata.py Reuses decoded payload and triggers clear_rfid() on incoming /get/rfid.
packages/control/chargepoint/rfid.py Removes explicit module RFID clearing and adjusts method typing.
packages/control/chargepoint/chargepoint_data.py Updates ChargepointProtocol to match new RFID flow (but currently introduces typing issues).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +464 to 467
if (re.search("/chargepoint/[0-9]+/get/rfid$", msg.topic) is not None and
payload is not None):
var["cp"+index].chargepoint.chargepoint_module.clear_rfid()
self.set_json_payload_class(var["cp"+index].chargepoint.data.get, msg)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Der Aufruf von clear_rfid() passiert im MQTT-Callback-Thread von subdata. Einige Implementierungen (z.B. HTTP-Requests / pub_single zu externen Hosts) können blockieren und damit die Verarbeitung weiterer Broker-Nachrichten verzögern. Besser wäre, das Clearing asynchron (Thread/Job-Queue) auszuführen, oder zumindest sicherzustellen, dass clear_rfid() hier garantiert non-blocking ist.

Copilot uses AI. Check for mistakes.
Comment on lines 254 to +264
class ChargepointProtocol(Protocol):
@property
def template(self) -> CpTemplate: ...
def data(self) -> ChargepointData: ...
@property
def chargepoint_module(self) -> AbstractChargepoint: ...
def find_duo_partner(self) -> Optional[int]: ...
@property
def num(self) -> int: ...
@property
def data(self) -> ChargepointData: ...
def set_state_and_log(self, message: str) -> None: ...
@property
def template(self) -> CpTemplate: ...
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Im ChargepointProtocol sind find_duo_partner und set_state_and_log als @property deklariert, werden aber im Code als Methoden aufgerufen (self.find_duo_partner() / self.set_state_and_log(msg)). Das führt zu falschen Typinformationen (und ggf. MyPy/Pylance-Fehlern). Bitte beide als normale Methoden ohne @property definieren; data, num und template können Properties bleiben.

Copilot uses AI. Check for mistakes.
Comment on lines 139 to 149
def switch_phases(self, phases_to_use: int) -> None:
with SingleComponentUpdateContext(self.fault_state, update_always=False):
with self.client_error_context:
response = self.__session.get(f'http://{self.config.configuration.ip_address}/connect.php')
if response.json()["phases_target"] != phases_to_use:
self.__session.post(f'http://{self.config.configuration.ip_address}/connect.php',
data={'phasetarget': str(1 if phases_to_use == 1 else 3)})

def clear_rfid(self) -> None:
pass

def interrupt_cp(self, duration: int) -> None:
self.__session.post(f'http://{self.config.configuration.ip_address}/connect.php',
data={'cp_interrupt': True,
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

ChargepointModule erbt von AbstractChargepoint, das clear_rfid() als @abstractmethod verlangt. Durch das Entfernen der (wenn auch leeren) Implementierung ist die Klasse wieder abstrakt und lässt sich nicht mehr instanziieren (TypeError). Bitte clear_rfid() hier wieder implementieren (idealerweise mit der passenden Pro-API zum Löschen des Tags), oder die Abstraktion anpassen, falls dieses Modul RFID nicht unterstützt.

Copilot uses AI. Check for mistakes.
LKuemmel and others added 2 commits March 11, 2026 16:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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