-
Notifications
You must be signed in to change notification settings - Fork 329
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
feat: Matching OCPP 2.0.1 payload types to OCPP 2.0.1 json schema #680
feat: Matching OCPP 2.0.1 payload types to OCPP 2.0.1 json schema #680
Conversation
Also includes a pull request template. Contributes to mobilityhouse#671
…rate the same as before. the enums and datatypes had an overlapping dataclass, both called UnitOfMeasureType. changed the enum to UnitOfMeasureUnitType.
…changes made to nested dataclasses don't affect functionality
Included same unit test for v2.0.1 datatypes and enums as #684 to make sure that nested model type changes don't alter functionality. |
@on(Action.TransactionEvent)
def on_transaction_event(self, transaction_info: dict, *args, **kwargs):
transaction_id = transaction_info.get("transaction_id", None)
# I can access all the data inside transaction_info using the `.get` method.
meter_value = kwargs.get("meter_value", [])
# I can access meter values using the same .get method. My question is, whether the following will work after the changes in dataclasses? @on(Action.TransactionEvent)
def on_transaction_event(self, transaction_info: TransactionEvent, *args, **kwargs):
transaction_id = transaction_info.get("transaction_id", None)
meter_value = kwargs.get("meter_value", []) |
NVM. The question is resolved. |
@jainmohit2001 yup. the type is just a hint in python; it won't cast the object to a new type. so as long as you interact with the The change you're describing can be made now, without the dataclass changes in this pull request, since TransactionEvent already exists.
Before or after this pull request, a static type checker or IDE should show a warning. With the type hint of |
@jainmohit2001 now that your question has been answered, will this PR be reviewed/approved for inclusion in the next release? |
Also includes a pull request template. Contributes to mobilityhouse#671
…calEnergeStorageVariableName, ConnectedEVVariableName, StandardizedVariableName, InvalidMessageSeq, Bytes
There is a
everything, i believe, matches the json schema; which comes directly from OCPP. so I think we're ok if we just follow the ordering of the schema
changed
changed
changed
added
removed
removed
updated
removed |
@jainmohit2001 thanks for the careful review and double check of things. please let me know if I've missed anything else. |
…es' into ocpp-2.0.1-payload-correct-types
Thanks for updating the PR quickly. I'll be reviewing the whole PR once again soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added my review for enums and datatypes.
Will take up call and call_result next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed review for call and call_result
Hi @ajmirsky, please look at my comments whenever you get the time. I think we are good to go for this PR apart from the comments I have mentioned. |
…nitoringBase and PublishFirmwareResponse
Apologies for the delay. They should now be resolved. |
@jainmohit2001 since we're removing the deprecated enums, should we also be removing the deprecated call and call_result Payloads? Or is that scheduled for a future release? |
A part of that is being done in #694 |
@proelke, have a look at the comments in this PR and share your thoughts. I have gone through the changes thoroughly and we are good for merge. |
My only feedback would be the use of importing the module and not each class. This diverges from how it is done for the 1.6 code. I'm personally more of a fan how it's done in the 1.6 code base vs what this PR introduces but they should be consistent. |
Considering the fact that OCPP 2.0.1 have a large number of datatypes and enums, importing each class instead of the whole module would only bring long import lines. I agree that we should be consistent in imports. We can create a separate PR for that and update the OCPP 1.6 imports if that works. |
This brings @malsyned #562 up-to-date with base branch and fixes linting errors.
Justification
Payload types now match the json schema for OCPP2.0.1 that are also included in this library. allows for static type checking of payloads.
Breaking changes
To verify that there are no breaking changes, the unit test included in #684 is used to prevent regression with the nested model datatypes.
To hydrate with nested datatypes, use json-dataclasses