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

Serialization of call_result.SetVariables is incorrect when set_variable_result attribute contains more than 1 element #635

Closed
OrangeTux opened this issue May 21, 2024 · 0 comments · Fixed by #637
Assignees
Labels
bug Something isn't working

Comments

@OrangeTux
Copy link
Collaborator

OrangeTux commented May 21, 2024

ocpp.charge_point.serialize_as_dict() wrongly serializes a payload that contains a collection of multiple items.
The following payload contains a collection of 2 SetVariableResultType. But the serializes output contains only a single item.

Thanks @OSkrk for making me aware of this issue.

Consider this payload:

    payload = call_result.SetVariables(
        set_variable_result=[
            datatypes.SetVariableResultType(
                attribute_status=enums.SetVariableStatusType.accepted,
                component={
                    "name": "TemperatureSensor",
                    "instance": "First",
                    "evse": {"id": 1, "connector_id": 1},
                },
                variable={"name": "DisplayUnit", "instance": "Main"},
                attribute_type="Actual",
                attribute_status_info=None,
            ),
            datatypes.SetVariableResultType(
                attribute_status="Accepted",
                component={"name": "TxCtrlr"},
                variable={"name": "TxStopPoint"},
                attribute_type="Actual",
                attribute_status_info=None,
            ),
        ],
        custom_data=None,
    )

It's serialized as this:

           'set_variable_result': [{'attribute_status': 'Accepted',
                                     'attribute_status_info': None,
                                     'attribute_type': 'Actual',
                                     'component': {'name': 'TxCtrlr'},
                                     'variable': {'name': 'TxStopPoint'}}],
@OrangeTux OrangeTux added the bug Something isn't working label May 21, 2024
@OrangeTux OrangeTux self-assigned this May 21, 2024
OrangeTux added a commit that referenced this issue May 21, 2024
…ments (#637)

Serialization of a payload that contains a collection of items fails.
Only the last item of the collection appears in the
serialized output. All other collections are not available.

Fixes #635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant