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
12 changes: 9 additions & 3 deletions custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
self.websocket_close_timeout = entry.data.get(
CONF_WEBSOCKET_CLOSE_TIMEOUT, DEFAULT_WEBSOCKET_CLOSE_TIMEOUT
)
self.WEBSOCKET_PING_TRIES = entry.data.get(
self.websocket_ping_tries = entry.data.get(
CONF_WEBSOCKET_PING_TRIES, DEFAULT_WEBSOCKET_PING_TRIES
)
self.websocket_ping_interval = entry.data.get(
Expand Down Expand Up @@ -846,10 +846,16 @@ async def monitor_connection(self):
self._metrics[cstat.latency_pong.value].value = latency_pong

except asyncio.TimeoutError as timeout_exception:
_LOGGER.debug(
f"Connection latency from '{self.central.csid}' to '{self.id}': ping={latency_ping} ms, pong={latency_pong} ms",
)
self._metrics[cstat.latency_ping.value].value = latency_ping
self._metrics[cstat.latency_pong.value].value = latency_pong
timeout_counter += 1
if timeout_counter > self.central.WEBSOCKET_PING_TRIES:
if timeout_counter > self.central.websocket_ping_tries:
_LOGGER.debug(
f"Connection to '{self.id}' timed out after '{self.central.websocket_ping_tries}' ping tries",
)
raise timeout_exception
else:
continue
Expand All @@ -873,7 +879,7 @@ async def run(self, tasks):
try:
await asyncio.gather(*self.tasks)
except asyncio.TimeoutError:
_LOGGER.debug(f"Timeout in connection '{self.id}'")
pass
except websockets.exceptions.WebSocketException as websocket_exception:
_LOGGER.debug(f"Connection closed to '{self.id}': {websocket_exception}")
except Exception as other_exception:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ocpp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"meter_interval": "Charging sample interval (seconds)",
"idle_interval": "Charger idle sampling interval (seconds)",
"websocket_close_timeout": "Websocket close timeout (seconds)",
"WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing",
"websocket_ping_tries": "Websocket successive times to try connection before closing",
"websocket_ping_interval": "Websocket ping interval (seconds)",
"websocket_ping_timeout": "Websocket ping timeout (seconds)",
"skip_schema_validation": "Skip OCPP schema validation"
Expand Down Expand Up @@ -55,4 +55,4 @@
"single_instance_allowed": "Only a single instance is allowed."
}
}
}
}
4 changes: 2 additions & 2 deletions custom_components/ocpp/translations/i-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"meter_interval": "Charging sample interval (seconds)",
"idle_interval": "Charger idle sampling interval (seconds)",
"websocket_close_timeout": "Websocket close timeout (seconds)",
"WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing",
"websocket_ping_tries": "Websocket successive times to try connection before closing",
"websocket_ping_interval": "Websocket ping interval (seconds)",
"websocket_ping_timeout": "Websocket ping timeout (seconds)",
"skip_schema_validation": "Skip OCPP schema validation"
Expand Down Expand Up @@ -55,4 +55,4 @@
"single_instance_allowed": "Only a single instance is allowed."
}
}
}
}
4 changes: 2 additions & 2 deletions custom_components/ocpp/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cpid": "Charge point identifier",
"meter_interval": "Meetinterval (secondes)",
"websocket_close_timeout": "Websocket close timeout (secondes)",
"WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing",
"websocket_ping_tries": "Websocket successive times to try connection before closing",
"websocket_ping_interval": "Websocket ping interval (secondes)",
"websocket_ping_timeout": "Websocket ping timeout (secondes)",
"skip_schema_validation": "Skip OCPP schema validation"
Expand Down Expand Up @@ -54,4 +54,4 @@
"single_instance_allowed": "Slechts een exemplaar toegestaan."
}
}
}
}