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

Use dataclasses for ChargingProfile usage #648

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
86a773d
Add dataclasses for ChargingProfile and it's constituents
grutts Jan 26, 2021
3b91490
Fix flake8 line length
grutts Jan 26, 2021
689cd1e
Merge branch 'master' into adrian/add_charging_profile_types
grutts Feb 28, 2021
19bfe11
remove_nones now handles nested dicts and lists of dicts
grutts Feb 28, 2021
10c968f
Fix flake8
grutts Feb 28, 2021
282e99e
Accept Dict for backwards compatibility
grutts Feb 28, 2021
9a714e4
Address review comments
grutts Mar 11, 2021
4c82c8c
Fix flake8 line too long
grutts Mar 11, 2021
9429467
Merge branch 'master' into adrian/add_charging_profile_types
grutts Mar 29, 2021
dc17b77
Merge branch 'master' of https://github.com/mobilityhouse/ocpp into a…
jerome-benoit Jun 12, 2024
10e25ae
fix merge issues
jerome-benoit Jun 12, 2024
4fa2727
Merge branch 'master' into charging_profile_types
jerome-benoit Jun 18, 2024
8a954ec
Merge branch 'master' into charging_profile_types
proelke Oct 15, 2024
5fee7c0
Merge branch 'master' into charging_profile_types
jerome-benoit Nov 26, 2024
3e5ab68
Merge branch 'master' into charging_profile_types
jerome-benoit Dec 9, 2024
5be966a
fix: use already defined charging profile types
jerome-benoit Dec 9, 2024
401b78b
Merge branch 'master' into charging_profile_types
jerome-benoit Dec 9, 2024
f5f1ded
Merge branch 'master' into charging_profile_types
jerome-benoit Dec 9, 2024
e8f6259
Merge branch 'master' into charging_profile_types
jerome-benoit Dec 18, 2024
d09fcfd
Update ocpp/v16/call.py
jerome-benoit Dec 18, 2024
f55a501
Update ocpp/v16/call.py
jerome-benoit Dec 18, 2024
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ help:
@echo " release version=<sem. version> bumps the project version to <sem. version>, using poetry;"
@echo " Updates also docs/source/conf.py version;"
@echo " If no version is provided, poetry outputs the current project version"
@echo " test run all the tests and linting"
@echo " tests run all the tests and linting"
@echo " update updates the dependencies in poetry.lock"
@echo ""
@echo "Check the Makefile to know exactly what each target is doing."
Expand Down
9 changes: 6 additions & 3 deletions ocpp/v16/call.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from dataclasses import dataclass, field
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Union

from ocpp.v16.charging_profile import ChargingProfile
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
from ocpp.v16.enums import (
AvailabilityType,
CertificateUse,
Expand Down Expand Up @@ -133,7 +134,8 @@ class InstallCertificate:
class RemoteStartTransaction:
id_tag: str
connector_id: Optional[int] = None
charging_profile: Optional[Dict] = None
# Accept Dict for backwards compatibility
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
charging_profile: Union[ChargingProfile, Dict, None] = None
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved


@dataclass
Expand Down Expand Up @@ -165,7 +167,8 @@ class SendLocalList:
@dataclass
class SetChargingProfile:
connector_id: int
cs_charging_profiles: Dict
# Accept Dict for backwards compatibility
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
cs_charging_profiles: Union[ChargingProfile, Dict]


@dataclass
Expand Down
47 changes: 47 additions & 0 deletions ocpp/v16/charging_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from dataclasses import dataclass
from typing import List, Optional

from ocpp.v16.enums import (
ChargingProfileKindType,
ChargingProfilePurposeType,
ChargingRateUnitType,
RecurrencyKind,
)


@dataclass
class ChargingSchedulePeriod:
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
"""Charging schedule period structure defines a time period
in a charging schedule, as used in: ChargingSchedule."""

start_period: int
limit: float
number_phases: Optional[int] = None


@dataclass
class ChargingSchedule:
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
"""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[float] = None


@dataclass
class ChargingProfile:
jerome-benoit marked this conversation as resolved.
Show resolved Hide resolved
"""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