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 dataclasses for ChargingProfile and its constituents #172

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
41 changes: 40 additions & 1 deletion ocpp/v16/call.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from decimal import Decimal
from typing import Any, Dict, List, Optional
from dataclasses import dataclass, field

from ocpp.v16.enums import (
AvailabilityType,
ChargePointErrorCode,
ChargePointStatus,
ChargingProfileKindType,
ChargingProfilePurposeType,
ChargingRateUnitType,
DiagnosticsStatus,
FirmwareStatus,
MessageTrigger,
Reason,
RecurrencyKind,
ResetType,
UpdateType,
)
Expand Down Expand Up @@ -122,10 +125,46 @@ class SendLocalListPayload:
local_authorization_list: List = field(default_factory=list)


@dataclass
class ChargingSchedulePeriod:
"""Charging schedule period structure defines a time period
in a charging schedule, as used in: ChargingSchedule."""
start_period: int
limit: Decimal
grutts marked this conversation as resolved.
Show resolved Hide resolved
number_phases: Optional[int] = None


@dataclass
class ChargingSchedule:
"""Charging schedule structure defines a list of charging periods,
as used in: GetCompositeSchedule.conf and ChargingProfile."""

charging_rate_unit: ChargingRateUnitType
charging_schedule_period: List[ChargingSchedulePeriod]
duration: Optional[int] = None
start_schedule: Optional[str] = None
min_charging_rate: Optional[Decimal] = None


@dataclass
class ChargingProfile:
"""A ChargingProfile consists of a ChargingSchedule, describing the
amount of power or current that can be delivered per time interval."""
charging_profile_id: int
stack_level: int
charging_profile_purpose: ChargingProfilePurposeType
charging_profile_kind: ChargingProfileKindType
charging_schedule: ChargingSchedule
transaction_id: Optional[int] = None
recurrency_kind: Optional[RecurrencyKind] = None
valid_from: Optional[str] = None
valid_to: Optional[str] = None


@dataclass
class SetChargingProfilePayload:
connector_id: int
cs_charging_profiles: Dict
cs_charging_profiles: ChargingProfile


@dataclass
Expand Down