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

Does this code works for anyone ? #1

Open
gyzod opened this issue Jul 30, 2024 · 1 comment
Open

Does this code works for anyone ? #1

gyzod opened this issue Jul 30, 2024 · 1 comment

Comments

@gyzod
Copy link

gyzod commented Jul 30, 2024

I'm trying to build something from this code and I get errors about missing arguments in the lines self.call(payload) like this :

    async def set_charging_profile(self, amps, **kwargs):
        print('set_charging_profile')
        return await self.call(call.SetChargingProfilePayload(
            connector_id=1,
            cs_charging_profiles={
                'charging_profile_id': int(amps),
                'stack_level': 0,
                'charging_profile_purpose': ChargingProfilePurposeType.tx_profile,
                'charging_profile_kind': ChargingProfileKindType.absolute,
                'charging_schedule': {
                    'charging_rate_unit': ChargingRateUnitType.amps,
                    'charging_schedule_period': [{
                        'start_period': 0,
                        'limit': float(amps),
                    }]
                },
                'transaction_id': 112
            }
        ))

errors are :

{'cmd': 'availability', 'values': [{'state': 'Operative'}]}
Changing availability to Operative
INFO:ocpp:EVB-P20261797: send [2,"0a475978-ffdf-4b6d-a30a-8cc620defb01","ChangeAvailability",{"connectorId":1,"type":"Inoperative"}]
INFO:ocpp:EVB-P20261797: receive message [4,"0a475978-ffdf-4b6d-a30a-8cc620defb01"]
ERROR:ocpp:Unable to parse message: '[4,"0a475978-ffdf-4b6d-a30a-8cc620defb01"]', it doesn't seem to be valid OCPP: ProtocolError: Payload for Action is incomplete, {'cause': 'Message is missing elements.'}
Traceback (most recent call last):
  File "/home/pagag186/ocpp/ocpp-mqtt-gateway/venv/lib/python3.10/site-packages/ocpp/messages.py", line 103, in unpack
    return cls(*msg[1:])
TypeError: CallError.__init__() missing 2 required positional arguments: 'error_code' and 'error_description'
@rzylius
Copy link
Owner

rzylius commented Aug 1, 2024

Hi, the code works for me, but I guess it may depend on specific implementation of the protocol in your charger.

e.g. from log it seems that the message you received does not conform to the expected OCPP format. The CallError class expects three arguments: error_code, error_description, and optionally error_details. However, the received message does not provide these elements.

What is the charger? does it implement ocpp v1.6, maybe there are caveats? e.g. my charger Elinta had settings which I had to change in order to be able to send profile commad with max current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants