Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions openevsehttp/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async def keepalive(self):
"""Send ping requests to websocket."""
if self._ping and self._pong:
time_delta = self._pong - self._ping
if time_delta < 0:
if time_delta < datetime.timedelta(0):
# Negitive time should indicate no pong reply so consider the
# websocket disconnected.
self._error_reason = ERROR_PING_TIMEOUT
Expand All @@ -156,9 +156,12 @@ async def keepalive(self):
data = {"ping": 1}
_LOGGER.debug("Sending message: %s to websocket.", data)
try:
await self._client.send_json(data)
self._ping = datetime.datetime.now()
_LOGGER.debug("Ping message sent.")
if self._client:
await self._client.send_json(data)
self._ping = datetime.datetime.now()
_LOGGER.debug("Ping message sent.")
else:
_LOGGER.warning("Websocket client not found.")
except TypeError as err:
_LOGGER.error("Attempt to send ping data failed: %s", err)
except ValueError as err:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

PROJECT_DIR = Path(__file__).parent.resolve()
README_FILE = PROJECT_DIR / "README.md"
VERSION = "0.1.88"
VERSION = "0.1.89"

setup(
name="python_openevse_http",
Expand Down