-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from kirei/local_api
Prepare for local API
- Loading branch information
Showing
4 changed files
with
154 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,52 @@ | ||
"""Base class and data classes for ChargeAmps API""" | ||
|
||
from abc import ABCMeta | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import List, Optional | ||
|
||
from dataclasses_json import LetterCase, dataclass_json | ||
|
||
from .utils import datetime_field | ||
|
||
|
||
class ChargeAmpsClient(metaclass=ABCMeta): # noqa | ||
pass | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointConnector: | ||
charge_point_id: str | ||
connector_id: int | ||
type: str | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePoint: | ||
id: str | ||
name: str | ||
password: str | ||
type: str | ||
is_loadbalanced: bool | ||
firmware_version: str | ||
hardware_version: str | ||
connectors: List[ChargePointConnector] | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointMeasurement: | ||
phase: str | ||
current: float | ||
voltage: float | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointConnectorStatus: | ||
charge_point_id: str | ||
connector_id: int | ||
total_consumption_kwh: float | ||
status: str | ||
measurements: Optional[List[ChargePointMeasurement]] | ||
start_time: Optional[datetime] = datetime_field() | ||
end_time: Optional[datetime] = datetime_field() | ||
session_id: Optional[str] = None | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointStatus: | ||
id: str | ||
status: str | ||
connector_statuses: List[ChargePointConnectorStatus] | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=False) | ||
class ChargePointSettings: | ||
id: str | ||
dimmer: str | ||
down_light: bool | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=False) | ||
class ChargePointConnectorSettings: | ||
charge_point_id: str | ||
connector_id: int | ||
mode: str | ||
rfid_lock: bool | ||
cable_lock: bool | ||
max_current: Optional[float] = None | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargingSession: | ||
id: str | ||
charge_point_id: str | ||
connector_id: int | ||
session_type: str | ||
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: | ||
rfid_length: int | ||
rfid_format: str | ||
rfid: str | ||
external_transaction_id: str | ||
"""Base class for ChargeAmps API""" | ||
|
||
from abc import ABCMeta, abstractmethod | ||
|
||
from .models import ( | ||
ChargePoint, | ||
ChargePointConnectorSettings, | ||
ChargePointSettings, | ||
ChargePointStatus, | ||
) | ||
|
||
|
||
class ChargeAmpsClient(metaclass=ABCMeta): | ||
@abstractmethod | ||
async def shutdown(self): | ||
pass | ||
|
||
@abstractmethod | ||
async def get_chargepoints(self) -> list[ChargePoint]: | ||
"""Get all owned chargepoints""" | ||
pass | ||
|
||
@abstractmethod | ||
async def get_chargepoint_status(self, charge_point_id: str) -> ChargePointStatus: | ||
"""Get charge point status""" | ||
pass | ||
|
||
@abstractmethod | ||
async def get_chargepoint_settings( | ||
self, charge_point_id: str | ||
) -> ChargePointSettings: | ||
"""Get chargepoint settings""" | ||
pass | ||
|
||
@abstractmethod | ||
async def set_chargepoint_settings(self, settings: ChargePointSettings) -> None: | ||
"""Set chargepoint settings""" | ||
pass | ||
|
||
@abstractmethod | ||
async def get_chargepoint_connector_settings( | ||
self, charge_point_id: str, connector_id: int | ||
) -> ChargePointConnectorSettings: | ||
"""Get all owned chargepoints""" | ||
pass | ||
|
||
@abstractmethod | ||
async def set_chargepoint_connector_settings( | ||
self, settings: ChargePointConnectorSettings | ||
) -> None: | ||
"""Get all owned chargepoints""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
"""Base class and data classes for ChargeAmps API""" | ||
|
||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import Optional | ||
|
||
from dataclasses_json import LetterCase, dataclass_json | ||
|
||
from .utils import datetime_field | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointConnector: | ||
charge_point_id: str | ||
connector_id: int | ||
type: str | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePoint: | ||
id: str | ||
name: str | ||
password: str | ||
type: str | ||
is_loadbalanced: bool | ||
firmware_version: str | ||
hardware_version: str | ||
connectors: list[ChargePointConnector] | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointMeasurement: | ||
phase: str | ||
current: float | ||
voltage: float | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointConnectorStatus: | ||
charge_point_id: str | ||
connector_id: int | ||
total_consumption_kwh: float | ||
status: str | ||
measurements: Optional[list[ChargePointMeasurement]] | ||
start_time: Optional[datetime] = datetime_field() | ||
end_time: Optional[datetime] = datetime_field() | ||
session_id: Optional[str] = None | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargePointStatus: | ||
id: str | ||
status: str | ||
connector_statuses: list[ChargePointConnectorStatus] | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=False) | ||
class ChargePointSettings: | ||
id: str | ||
dimmer: str | ||
down_light: bool | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=False) | ||
class ChargePointConnectorSettings: | ||
charge_point_id: str | ||
connector_id: int | ||
mode: str | ||
rfid_lock: bool | ||
cable_lock: bool | ||
max_current: Optional[float] = None | ||
|
||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass(frozen=True) | ||
class ChargingSession: | ||
id: str | ||
charge_point_id: str | ||
connector_id: int | ||
session_type: str | ||
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: | ||
rfid_length: int | ||
rfid_format: str | ||
rfid: str | ||
external_transaction_id: str |