From f89a483fec3c55080edd3cae62029ef34ade4845 Mon Sep 17 00:00:00 2001 From: Filip Ekberg Date: Fri, 1 Dec 2023 13:12:26 +0100 Subject: [PATCH 1/3] Add remote start/stop using RFID --- chargeamps/base.py | 8 ++++++++ chargeamps/external.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/chargeamps/base.py b/chargeamps/base.py index ddda190..fdb1825 100644 --- a/chargeamps/base.py +++ b/chargeamps/base.py @@ -93,3 +93,11 @@ class ChargingSession(object): total_consumption_kwh: float start_time: Optional[datetime] = datetime_field() end_time: Optional[datetime] = datetime_field() + +@dataclass_json(letter_case=LetterCase.CAMEL) +@dataclass(frozen=True) +class StartAuth(object): + rfidLength: int + rfidFormat: str + rfid: str + externalTransactionId: str \ No newline at end of file diff --git a/chargeamps/external.py b/chargeamps/external.py index 88dddf6..44650b8 100644 --- a/chargeamps/external.py +++ b/chargeamps/external.py @@ -16,6 +16,7 @@ ChargePointSettings, ChargePointStatus, ChargingSession, + StartAuth ) API_BASE_URL = "https://eapi.charge.space" @@ -153,3 +154,15 @@ async def set_chargepoint_connector_settings( connector_id = settings.connector_id request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/settings" await self._put(request_uri, json=payload) + + async def remote_start(self, charge_point_id: str, connector_id: int, startAuth: StartAuth) -> None: + """Remote start chargepoint""" + payload = startAuth.to_dict() + request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestart" + await self._put(request_uri, json=payload) + + async def remote_stop(self, charge_point_id: str, connector_id: int, startAuth: StartAuth) -> None: + """Remote start chargepoint""" + payload = startAuth.to_dict() + request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestop" + await self._put(request_uri, json=payload) \ No newline at end of file From adb6d04df502c44db0146e7e611f0f681a2af200 Mon Sep 17 00:00:00 2001 From: Filip Ekberg Date: Fri, 1 Dec 2023 13:29:09 +0100 Subject: [PATCH 2/3] Fix inconsistent naming, remove StartAuth when calling remotestop --- chargeamps/base.py | 6 +++--- chargeamps/external.py | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/chargeamps/base.py b/chargeamps/base.py index fdb1825..b95cb8b 100644 --- a/chargeamps/base.py +++ b/chargeamps/base.py @@ -97,7 +97,7 @@ class ChargingSession(object): @dataclass_json(letter_case=LetterCase.CAMEL) @dataclass(frozen=True) class StartAuth(object): - rfidLength: int - rfidFormat: str + rfid_length: int + rfid_format: str rfid: str - externalTransactionId: str \ No newline at end of file + external_transaction_id: str \ No newline at end of file diff --git a/chargeamps/external.py b/chargeamps/external.py index 44650b8..49c475b 100644 --- a/chargeamps/external.py +++ b/chargeamps/external.py @@ -16,7 +16,7 @@ ChargePointSettings, ChargePointStatus, ChargingSession, - StartAuth + StartAuth, ) API_BASE_URL = "https://eapi.charge.space" @@ -155,14 +155,13 @@ async def set_chargepoint_connector_settings( request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/settings" await self._put(request_uri, json=payload) - async def remote_start(self, charge_point_id: str, connector_id: int, startAuth: StartAuth) -> None: + async def remote_start(self, charge_point_id: str, connector_id: int, start_auth: StartAuth) -> None: """Remote start chargepoint""" - payload = startAuth.to_dict() + payload = start_auth.to_dict() request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestart" await self._put(request_uri, json=payload) - async def remote_stop(self, charge_point_id: str, connector_id: int, startAuth: StartAuth) -> None: - """Remote start chargepoint""" - payload = startAuth.to_dict() + async def remote_stop(self, charge_point_id: str, connector_id: int) -> None: + """Remote stop chargepoint""" request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestop" - await self._put(request_uri, json=payload) \ No newline at end of file + await self._put(request_uri) \ No newline at end of file From d6be92ced37a7ffe35829f756377052d9dee4140 Mon Sep 17 00:00:00 2001 From: Filip Ekberg Date: Fri, 1 Dec 2023 13:48:49 +0100 Subject: [PATCH 3/3] Reformatting the code --- chargeamps/base.py | 3 ++- chargeamps/external.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chargeamps/base.py b/chargeamps/base.py index b95cb8b..4b56418 100644 --- a/chargeamps/base.py +++ b/chargeamps/base.py @@ -94,10 +94,11 @@ class ChargingSession(object): start_time: Optional[datetime] = datetime_field() end_time: Optional[datetime] = datetime_field() + @dataclass_json(letter_case=LetterCase.CAMEL) @dataclass(frozen=True) class StartAuth(object): rfid_length: int rfid_format: str rfid: str - external_transaction_id: str \ No newline at end of file + external_transaction_id: str diff --git a/chargeamps/external.py b/chargeamps/external.py index 49c475b..3446d3d 100644 --- a/chargeamps/external.py +++ b/chargeamps/external.py @@ -155,7 +155,9 @@ async def set_chargepoint_connector_settings( request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/settings" await self._put(request_uri, json=payload) - async def remote_start(self, charge_point_id: str, connector_id: int, start_auth: StartAuth) -> None: + async def remote_start( + self, charge_point_id: str, connector_id: int, start_auth: StartAuth + ) -> None: """Remote start chargepoint""" payload = start_auth.to_dict() request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestart" @@ -164,4 +166,4 @@ async def remote_start(self, charge_point_id: str, connector_id: int, start_auth async def remote_stop(self, charge_point_id: str, connector_id: int) -> None: """Remote stop chargepoint""" request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestop" - await self._put(request_uri) \ No newline at end of file + await self._put(request_uri)