Skip to content

Commit

Permalink
Remove websocket.id (#343)
Browse files Browse the repository at this point in the history
* improve reconnect and trigger boot notification

* cancel tasks on close and reconnect

* improve exception handling

* remove websocket.id from logs

Co-authored-by: lbbrhzn <@lbbrhzn>
  • Loading branch information
lbbrhzn authored Feb 2, 2022
1 parent 44c72a3 commit 602d247
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,14 @@ async def stop(self):
"""Close connection and cancel ongoing tasks."""
self.status = STATE_UNAVAILABLE
if self._connection.open:
_LOGGER.debug(f"Closing websocket: '{self._connection.id}'")
_LOGGER.debug(f"Closing websocket to '{self.id}'")
await self._connection.close()
for task in self.tasks:
task.cancel()

async def reconnect(self, connection: websockets.server.WebSocketServerProtocol):
"""Reconnect charge point."""
_LOGGER.debug(f"Reconnect {connection.id}")
_LOGGER.debug(f"Reconnect websocket to {self.id}")

await self.stop()
self.status = STATE_OK
Expand Down

0 comments on commit 602d247

Please sign in to comment.