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

Conversation

jerome-benoit
Copy link
Contributor

@jerome-benoit jerome-benoit commented Jun 12, 2024

PR #172 updated with master.

Smart charging algos conception and validation has become a requirement for charging infrastructure. Every single code lines that can help at implementing and testing it worse the effort.

closes #172

Associated unit tests PR: #690

grutts and others added 11 commits January 26, 2021 09:26
In order for remove_nones to work with the charging profile
data structures it needs to be able to remove nones of nested
dictionaries, as well as dictionaries made of lists of dictionaries
(for example, a list of charging schedules represented as dicts).

This commit modifies the logic, and adds tests
For now, dicts are acceptable to maintain backwards compatibility.
Perhaps in v1.0 only the dataclass will be accepted.
* Change Decimal to float
* Move dataclasses to separate charging_profile module
* Add ChargingProfile type to RemoteStartTransaction payload
…drian/add_charging_profile_types

Signed-off-by: Jérôme Benoit <[email protected]>
Signed-off-by: Jérôme Benoit <[email protected]>
@ajmirsky
Copy link
Contributor

@jerome-benoit would you like me to create unit tests similar to #684 so that its clearer to the community that these kind of changes are non-breaking? hopefully, that'll allow the new maintainers confidence in accepting these changes as well as the changes in #680

@jerome-benoit
Copy link
Contributor Author

@jerome-benoit would you like me to create unit tests similar to #684 so that its clearer to the community that these kind of changes are non-breaking? hopefully, that'll allow the new maintainers confidence in accepting these changes as well as the changes in #680

If your time permits, it will be helpful. I think that PR is editable by maintainers.

Copy link
Contributor

@ajmirsky ajmirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the charging profile datatypes that are added in charging_profile.py already exist in ocpp/v16/datatypes.py and shouldn't be duplicated.

ocpp/v16/charging_profile.py Outdated Show resolved Hide resolved
ocpp/v16/charging_profile.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
ocpp/v16/charging_profile.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ajmirsky ajmirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

charging_profile field is optional; typing it as None makes it a required field.

ocpp/v16/call.py Outdated Show resolved Hide resolved
@jerome-benoit jerome-benoit changed the title Add dataclasses for ChargingProfile Use dataclasses for ChargingProfile usage Dec 9, 2024
Copy link
Contributor

@ajmirsky ajmirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@ajmirsky
Copy link
Contributor

@jainmohit2001 any feedback for this PR?

@jainmohit2001
Copy link
Collaborator

Looks good. Just remove the comments. I don't think they would be necessary.

ocpp/v16/call.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
@jainmohit2001
Copy link
Collaborator

LGTM. We can merge this.

@jainmohit2001 jainmohit2001 merged commit 9e40584 into mobilityhouse:master Dec 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants