ocpp
ocpp copied to clipboard
Call from central_system to charge_point - AttributeError
I need help please, I was trying to implement a call from central_system to charge_point for reset.req and got this error. *** AttributeError: 'ChargePoint' object has no attribute '_call_result'
This is my function of the reset request
async def reset_req(self):
request = call.ResetPayload(
type= ResetType.hard
)
response = await self.call(request)
if response.status == ResetStatus.accepted:
print("Reset Accepted!!")
else:
print("Reset Rejected!!")
Thank you.
I see nothing wrong there. Two things:
- Provide us your code from starting of the Server/client up to the Reset Call
- Provide us a complete logging message of the error you got please
I see nothing wrong there. Two things:
- Provide us your code from starting of the Server/client up to the Reset Call
- Provide us a complete logging message of the error you got please
Thank you, I got it working. Though I had to make some changes in the charge_point.py code. Now, if you can help me out with this issue,
- How can I send a reset call, from the server according to whenever I want it to be sent?
async def on_connect(websocket, path):
""" For every new charge point that connects, create a ChargePoint
instance and start listening for messages.
"""
try:
requested_protocols = websocket.request_headers[
'Sec-WebSocket-Protocol']
except KeyError:
logging.info("Client hasn't requested any Subprotocol. "
"Closing Connection")
if websocket.subprotocol:
logging.info("Protocols Matched: %s", websocket.subprotocol)
else:
logging.warning('Protocols Mismatched | Expected Subprotocols: %s,'
' but client supports %s | Closing connection',
websocket.available_subprotocols,
requested_protocols)
return await websocket.close()
charge_point_id = path.strip('/')
cp = ChargePoint(charge_point_id, websocket)
try:
asyncio.gather(cp.reset_req())
await asyncio.gather(cp.start())
except websockets.exceptions.ConnectionClosed:
connected.remove(websocket)
print("Charge Point disconnected")
async def main():
server = await websockets.serve(
on_connect,
'0.0.0.0',
port,
subprotocols=['ocpp1.6'],
ping_interval=None,
ping_timeout=None
)
logging.info("WebSocket Server Started")
await server.wait_closed()
if __name__ == '__main__':
asyncio.run(main())
The reset code is mentioned above.
Thank you.
I am trying to do this exact same thing. This could be a really useful tool for basic, local OCPP testing provided there was a way to trigger certain events from the CSMS to the CS. I'd love to know how to do this so I can make better use of this tool!
I had thought of creating a simple UI with a drop down of the requests to send with a button event, but UIs don't play nicely at all with asyncio...
@garima8 Hi, were you able to get some progress in this. I am trying to send a call from central system to charge point but I am stuck. Control is not able to move past this line -
await self.call(request) .
Hi,
Yes, I was able to resolve it. It's working fine for me now.
Regards, Garima Mangla
On Mon, Jul 4, 2022 at 12:15 PM Ashutosh Shisodia @.***> wrote:
@garima8 https://github.com/garima8 Hi, were you able to get some progress in this. I am trying to send a call from central system to charge point but I am stuck. Control is not able to move past this line - await self.call(request) .
— Reply to this email directly, view it on GitHub https://github.com/mobilityhouse/ocpp/issues/211#issuecomment-1173416256, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELVMIVBEOSGU7CMNG4DYTLVSKCBTANCNFSM45T7SJWA . You are receiving this because you were mentioned.Message ID: @.***>