Conversation
There was a problem hiding this comment.
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/rfidwhen a non-NoneRFID value is present. - Trigger
chargepoint_module.clear_rfid()automatically when a/get/rfidupdate 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.
| 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) |
There was a problem hiding this comment.
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.
| 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: ... |
There was a problem hiding this comment.
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.
| 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, |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.