Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remote start/stop using RFID #14

Merged
merged 3 commits into from
Dec 1, 2023
Merged
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
9 changes: 9 additions & 0 deletions chargeamps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ 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):
fekberg marked this conversation as resolved.
Show resolved Hide resolved
rfid_length: int
rfid_format: str
rfid: str
external_transaction_id: str
14 changes: 14 additions & 0 deletions chargeamps/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ChargePointSettings,
ChargePointStatus,
ChargingSession,
StartAuth,
)

API_BASE_URL = "https://eapi.charge.space"
Expand Down Expand Up @@ -153,3 +154,16 @@ 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, 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"
await self._put(request_uri, json=payload)

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)