diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index 9cf9496d..905df1fa 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -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( @@ -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 @@ -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: diff --git a/custom_components/ocpp/translations/en.json b/custom_components/ocpp/translations/en.json index e33f4662..4dde8f3c 100644 --- a/custom_components/ocpp/translations/en.json +++ b/custom_components/ocpp/translations/en.json @@ -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" @@ -55,4 +55,4 @@ "single_instance_allowed": "Only a single instance is allowed." } } -} \ No newline at end of file +} diff --git a/custom_components/ocpp/translations/i-default.json b/custom_components/ocpp/translations/i-default.json index e33f4662..4dde8f3c 100644 --- a/custom_components/ocpp/translations/i-default.json +++ b/custom_components/ocpp/translations/i-default.json @@ -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" @@ -55,4 +55,4 @@ "single_instance_allowed": "Only a single instance is allowed." } } -} \ No newline at end of file +} diff --git a/custom_components/ocpp/translations/nl.json b/custom_components/ocpp/translations/nl.json index 9b4498b1..de1050ce 100644 --- a/custom_components/ocpp/translations/nl.json +++ b/custom_components/ocpp/translations/nl.json @@ -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" @@ -54,4 +54,4 @@ "single_instance_allowed": "Slechts een exemplaar toegestaan." } } -} \ No newline at end of file +}