Skip to content

Commit

Permalink
Clear ping pong cache on proxy init (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Nov 21, 2023
1 parent 6d6a04e commit 995d795
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 2023.11.3 (2023-11-21)

- Clear ping pong cache on proxy init

# Version 2023.11.2 (2023-11-21)

- Refactor ping pong, remove semaphore
Expand Down
5 changes: 5 additions & 0 deletions hahomematic/caches/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def unknown_pong_count(self) -> int:
"""Return the unknown pong count."""
return len(self._unknown_pongs)

def clear(self) -> None:
"""Clear the cache."""
self._pending_pongs.clear()
self._unknown_pongs.clear()

def handle_send_ping(self, ping_ts: datetime) -> None:
"""Handle send ping timestamp."""
self._pending_pongs.add(ping_ts)
Expand Down
7 changes: 7 additions & 0 deletions hahomematic/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ async def proxy_init(self) -> ProxyInitState:
"""Init the proxy has to tell the CCU / Homegear where to send the events."""
try:
_LOGGER.debug("PROXY_INIT: init('%s', '%s')", self._config.init_url, self.interface_id)
self._clear_ping_pong_cache()
await self._proxy.init(self._config.init_url, self.interface_id)
self._mark_all_devices_forced_availability(
forced_availability=ForcedDeviceAvailability.NOT_SET
Expand All @@ -122,6 +123,12 @@ async def proxy_init(self) -> ProxyInitState:
self.last_updated = datetime.now()
return ProxyInitState.INIT_SUCCESS

def _clear_ping_pong_cache(self) -> None:
"""Clear the ping pong cache."""
self._ping_pong_cache.clear()
self._pending_pong_logged = False
self._unknown_pong_logged = False

async def proxy_de_init(self) -> ProxyInitState:
"""De-init to stop CCU from sending events for this remote."""
if self.last_updated == INIT_DATETIME:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hahomematic"
version = "2023.11.2"
version = "2023.11.3"
license = {text = "MIT License"}
description = "Homematic interface for Home Assistant running on Python 3."
readme = "README.md"
Expand Down

0 comments on commit 995d795

Please sign in to comment.