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

Matching OCPP 2.0.1 payload types to OCPP 2.0.1 json schema (#680) #3

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6be51ec
v201:call,call_result,datatypes: complete and corrected type annotations
malsyned Jan 5, 2024
f9d5fd0
fixing linting errors
ajmirsky Nov 22, 2024
76796d3
Merge branch 'master' into ocpp-2.0.1-payload-correct-types
ajmirsky Nov 22, 2024
68e048b
Add code of conduct, contributing, security and support docs.
ajmirsky Nov 22, 2024
c5057c4
adding unit tests for all the v201 data types to make sure they rehyd…
ajmirsky Nov 26, 2024
ef88e26
adding unit test to the non-nested dataclasses of v2.0.1 so that any …
ajmirsky Nov 26, 2024
9ff2f1f
fixing formatting, import sorting and make sure all imports are being…
ajmirsky Nov 26, 2024
efbf7b1
fixing formatting errors
ajmirsky Nov 26, 2024
ef2907a
even though it's a fake url, flagged as issue by sonarqube
ajmirsky Nov 26, 2024
d855325
fake url is being flagged by sonarqube as insecure
ajmirsky Nov 26, 2024
e53d73c
adding deprecation warnings for enums IdTokenType and UnitOfMeasureTy…
ajmirsky Nov 26, 2024
051aa93
removing files associated with a different pull request
ajmirsky Nov 26, 2024
d0461ff
Merge branch 'v201_datatypes_test' into ocpp-2.0.1-payload-correct-types
ajmirsky Nov 26, 2024
92b9400
Update readme - ocpp 2 edition 3 is supported (#686)
wafa-yah Dec 4, 2024
7bc890a
Merge branch 'master' into ocpp-2.0.1-payload-correct-types
ajmirsky Dec 6, 2024
0dc23fb
Disable threads if messages.ASYNC_VALIDATION = False (#678)
astrand Dec 7, 2024
3264a48
test python 3.13
drc38 Nov 28, 2024
a0b4820
Added inactive issue workflow
jainmohit2001 Oct 16, 2024
6ad8f56
bump to 2.0.0-rc.3 (#691)
mdwcrft Dec 9, 2024
cc0f2be
Bump black from 22.12.0 to 24.3.0 (#621)
dependabot[bot] Dec 9, 2024
db91355
ci: ensure the matching poetry version is used (#693)
jerome-benoit Dec 9, 2024
447ebcb
Finalize hand over to new maintainers. (#687)
OrangeTux Dec 9, 2024
be6cc64
v201:call,call_result,datatypes: complete and corrected type annotations
malsyned Jan 5, 2024
fbe0c49
fixing linting errors
ajmirsky Nov 22, 2024
c3a9638
Add code of conduct, contributing, security and support docs.
ajmirsky Nov 22, 2024
cd0a6a3
adding unit tests for all the v201 data types to make sure they rehyd…
ajmirsky Nov 26, 2024
e0ba5f5
fixing formatting, import sorting and make sure all imports are being…
ajmirsky Nov 26, 2024
75c38cd
even though it's a fake url, flagged as issue by sonarqube
ajmirsky Nov 26, 2024
c8b8f34
adding deprecation warnings for enums IdTokenType and UnitOfMeasureTy…
ajmirsky Nov 26, 2024
b928143
removing files associated with a different pull request
ajmirsky Nov 26, 2024
cf21e48
chore: Add code of conduct, contributing, security and support docs. …
ajmirsky Dec 9, 2024
5bbbf31
correcting class names of Enum Types
ajmirsky Dec 12, 2024
a09f1b6
Merge remote-tracking branch 'upstream/ocpp-2.0.1-payload-correct-typ…
ajmirsky Dec 12, 2024
c27e55a
UnitOfMeasureType can use a value from the standardized list or a cus…
ajmirsky Dec 12, 2024
8cdd774
fixing EnumEnum in datatype, correct formatting errors
ajmirsky Dec 12, 2024
69971ae
enum fixes for : TxCtrlrVariableName, ChargingStationVariableName, Lo…
ajmirsky Dec 12, 2024
9a5e6d3
Merge branch 'master' into ocpp-2.0.1-payload-correct-types
ajmirsky Dec 12, 2024
db335bb
fix formatting issue
ajmirsky Dec 12, 2024
5fa193a
Merge remote-tracking branch 'upstream/ocpp-2.0.1-payload-correct-typ…
ajmirsky Dec 12, 2024
f616705
naming change
ajmirsky Dec 12, 2024
ff1e071
changes based on PR feedback
ajmirsky Dec 13, 2024
635b5e8
removing spaces in ConnectedEVVariableName. and fixing types in SetMo…
ajmirsky 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
5 changes: 2 additions & 3 deletions .github/actions/setup-python-build-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ description: "Install everything needed to build"
runs:
using: "composite"
steps:
- name: Upgrage pip and install poetry
- name: Install poetry
shell: bash
run: |
pip install --upgrade pip
pip install --user "poetry==1.5.1"
pipx install poetry
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### Changes included in this PR

*(Bug fix, feature, docs update, ...)*

### Current behavior

*Link to an open issue here...*

### New behavior

*If this is a feature change, describe the new behavior*

### Impact

*Describe breaking changes, including changes a users might need to make due to this PR*

### Checklist

1. [ ] Does your submission pass the existing tests?
2. [ ] Are there new tests that cover these additions/changes?
3. [ ] Have you linted your code locally before submission?
22 changes: 22 additions & 0 deletions .github/workflows/inactive-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: "0 0 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
run: |
proj_version=$(poetry version -s)
if [ $proj_version != $TAG_VERSION ]; then echo "Version $proj_version, defined in pyproject.toml, does not match TAG $TAG_VERSION of this release"; exit 3; fi
poetry update
poetry publish --build -u __token__ -p $PYPI_TOKEN
env:
TAG_VERSION: ${{ steps.context.outputs.TAG_VERSION }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.version }}
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change log

## 2.0.0-rc.3 (2024-12-09)
- [#665](https://github.com/mobilityhouse/ocpp/pull/665) chore: Updated Python setup action to version v5 by @jainmohit2001
- [#663](https://github.com/mobilityhouse/ocpp/pull/663) bugfix: Changed total_cost type from Optional[int] to Optional[float] by @jainmohit2001
- [#667](https://github.com/mobilityhouse/ocpp/pull/667) feat: Added optional logger param to ChargePoint class by @jainmohit2001
- [#686](https://github.com/mobilityhouse/ocpp/pull/666) bugfix: Handling UnicodeDecodeError in unpack function by @jainmohit2001
- [#668](https://github.com/mobilityhouse/ocpp/pull/668) chore: Update CODEOWNERS by @jainmohit2001
- [#652](https://github.com/mobilityhouse/ocpp/pull/652) add executor to validate_payload by @drc38
- [#629](https://github.com/mobilityhouse/ocpp/pull/629) fix typo for InternalError in exceptions.py by @hhuseyinpay
- [#679](https://github.com/mobilityhouse/ocpp/pull/679) Add issue templates by @mdwcrft
- [#686](https://github.com/mobilityhouse/ocpp/pull/686) Update readme - ocpp 2 edition 3 is supported by @wafa-yah
- [#678](https://github.com/mobilityhouse/ocpp/pull/678) Disable threads if messages.ASYNC_VALIDATION = False by @astrand
- [#685](https://github.com/mobilityhouse/ocpp/pull/685) Test with python 3.13 by @drc38
- [#673](https://github.com/mobilityhouse/ocpp/pull/673) chore: Added inactive issue workflow by @jainmohit2001

## 2.0.0-rc.2 (2024-06-18)

- [#315](https://github.com/mobilityhouse/ocpp/pull/315) Allow to skip schema validation in `ChargePoint.call()`. Thanks [@esiebert](https://github.com/esiebert)!
Expand Down
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at {{ email }}. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

43 changes: 43 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Contributing

[fork]: /fork
[pr]: /compare
[style]: https://standardjs.com/
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.

## Issues and PRs

If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.

We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.

Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.

## Submitting a pull request

1. [Fork][fork] and clone the repository.
2. Create a new branch: `git checkout -b my-branch-name`.
3. Configure and install the dependencies: `poetry install`.
4. Make sure the tests pass on your machine: `make install & make tests`
5. Make your change, add tests, and make sure the tests still pass.
6. Push to your fork and [submit a pull request][pr] and complete the information in the pull request template.

## Linting requirements

using `make install & make tests` will also run the following linters:

- [Black: The uncompromising Python code formatter](https://black.readthedocs.io/en/stable/)
- [isort your imports, so you don't have to](https://pycqa.github.io/isort/)
- [flake8: Your Tool For Style Guide Enforcement](https://flake8.pycqa.org/en/latest/)

using `make format` will run isort and black and apply any formatting suggestions from them

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
4 changes: 2 additions & 2 deletions 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 All @@ -37,7 +37,7 @@ docs: .install-poetry
poetry run sphinx-build -b html docs/source docs/build

format: .install-poetry
poetry run isort ocpp tests && poetry run black ocpp tests
poetry run isort ocpp tests && poetry run black ocpp tests

tests: .install-poetry
poetry run black --check --diff ocpp tests
Expand Down
16 changes: 15 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OCPP
----

Python package implementing the JSON version of the Open Charge Point Protocol
(OCPP). Currently OCPP 1.6 (errata v4), OCPP 2.0.1 (Edition 2 FINAL, 2022-12-15)
(OCPP). Currently OCPP 1.6 (errata v4), OCPP 2.0.1 (Edition 2 FINAL, 2022-12-15 and Edition 3 errata 2024-11)
are supported.

You can find the documentation on `rtd`_.
Expand Down Expand Up @@ -203,6 +203,14 @@ To lower the logs for this package only use the following code:
logging.getLogger('ocpp').setLevel(level=logging.DEBUG)
logging.getLogger('ocpp').addHandler(logging.StreamHandler())

Aknowledgements
---------------

Till the end of 2024, this project has been lead and maintained by `Auke Oosterhoff`_ and
`Jared Newell`_. We thank them for work their work!

Since than, the project is lead by `Chad Meadowcroft`_, `Mohit Jain`_ and `Patrick Roelke`_.

License
-------

Expand All @@ -217,3 +225,9 @@ Attribution-NoDerivatives 4.0 International Public License.
.. _rtd: https://ocpp.readthedocs.io/en/latest/index.html
.. _The Mobility House: https://www.mobilityhouse.com/int_en/
.. _websockets: https://pypi.org/project/websockets/

.. _Auke Oosterhoff: https://github.com/orangetux
.. _Jared Newell: https://github.com/Jared-Newell-Mobility
.. _Chad Meadowcroft: https://github.com/mdwcrft
.. _Mohit Jain: https://github.com/jainmohit2001
.. _Patrick Roelke: https://github.com/proelke
33 changes: 33 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Security Policy

This document outlines security procedures and general policies for this OCPP project.

## Supported Versions

The currently supported versions of this OCPP project are:

| Version | Supported |
|----------|--------------------|
| 2.0.0 | :soon: |
| 1.0.0 | :white_check_mark: |
| < 1.0.0 | :white_check_mark: |

## Reporting a Vulnerability

Please include the requested information listed below (as much as you can provide) to help
us better understand the nature and scope of the possible issue:

- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

## Comments on this Policy

If you have suggestions on how this process could be improved please submit a
pull request. Thanks!
34 changes: 34 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Support

This article explains where to get help with this OCPP project.
Please read through the following guidelines.

> 👉 **Note**: before participating in our community, please read our
> [code of conduct][coc].
> By interacting with this repository, organization, or community you agree to
> abide by its terms.

## Asking quality questions

Questions can go to [GitHub discussions][chat].

Help us help you!
Spend time framing questions and add links and resources.
Spending the extra time up front can help save everyone time in the long run.
Here are some tips:

* Search to find out if a similar question has been asked or a similar issue has been reported
* Check to see if a PR is already in progress for the issue you want to raise
* Try to define what you need help with:
* Is there something in particular you want to do?
* What problem are you encountering and what steps have you taken to try
and fix it?
* Is there a concept you don’t understand?
* Provide sample code, such as a [CodeSandbox][cs] or video, if possible
* Screenshots can help, but if there’s important text such as code or error
messages in them, please also provide those as text
* The more time you put into asking your question, the better we can help you

## Contributions

See [`contributing.md`][contributing] on how to contribute.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "Auke Willem Oosterhoff"

# The full version, including alpha/beta/rc tags
release = "2.0.0-rc.2"
release = "2.0.0-rc.3"


# -- General configuration ---------------------------------------------------
Expand Down
17 changes: 5 additions & 12 deletions ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ async def _handle_call(self, msg):
return

if not handlers.get("_skip_schema_validation", False):
await asyncio.get_event_loop().run_in_executor(
None, validate_payload, msg, self._ocpp_version
)
await validate_payload(msg, self._ocpp_version)

# OCPP uses camelCase for the keys in the payload. It's more pythonic
# to use snake_case for keyword arguments. Therefore the keys must be
# 'translated'. Some examples:
Expand Down Expand Up @@ -344,9 +343,7 @@ async def _handle_call(self, msg):
response = msg.create_call_result(camel_case_payload)

if not handlers.get("_skip_schema_validation", False):
await asyncio.get_event_loop().run_in_executor(
None, validate_payload, response, self._ocpp_version
)
await validate_payload(response, self._ocpp_version)

await self._send(response.to_json())

Expand Down Expand Up @@ -415,9 +412,7 @@ async def call(
)

if not skip_schema_validation:
await asyncio.get_event_loop().run_in_executor(
None, validate_payload, call, self._ocpp_version
)
await validate_payload(call, self._ocpp_version)

# Use a lock to prevent make sure that only 1 message can be send at a
# a time.
Expand All @@ -440,9 +435,7 @@ async def call(
raise response.to_exception()
elif not skip_schema_validation:
response.action = call.action
await asyncio.get_event_loop().run_in_executor(
None, validate_payload, response, self._ocpp_version
)
await validate_payload(response, self._ocpp_version)

snake_case_payload = camel_to_snake_case(response.payload)
# Create the correct Payload instance based on the received payload. If
Expand Down
Loading
Loading