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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## v0.47.1 - 2025-09-27

- PR [351](https://github.com/plugwise/python-plugwise-usb/pull/351): Avoid unintentional overwrite of nodetype.cache file at start/reload.

## v0.47.0 - 2025-09-26

- PR [345](https://github.com/plugwise/python-plugwise-usb/pull/345): New Feature: schedule clock synchronization every 3600 seconds
- PR [345](https://github.com/plugwise/python-plugwise-usb/pull/345): New Feature: schedule clock synchronization every 3600 seconds.

## v0.46.1 - 2025-09-25

Expand Down
3 changes: 1 addition & 2 deletions plugwise_usb/helpers/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ async def initialize_cache(self, create_root_folder: bool = False) -> None:
cache_dir = self._get_writable_os_dir()
await makedirs(cache_dir, exist_ok=True)
self._cache_path = cache_dir

self._cache_file = os_path_join(self._cache_path, self._file_name)
self._cache_file_exists = await ospath.exists(self._cache_file)
self._initialized = True
_LOGGER.debug("Start using network cache file: %s", self._cache_file)

Expand Down Expand Up @@ -166,6 +164,7 @@ async def read_cache(self) -> dict[str, str]:
_LOGGER.debug("Cache file has no name, return empty cache data")
return current_data

self._cache_file_exists = await ospath.exists(self._cache_file)
if not self._cache_file_exists:
_LOGGER.debug(
"Cache file '%s' does not exist, return empty cache data",
Expand Down
10 changes: 6 additions & 4 deletions plugwise_usb/network/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ async def restore_cache(self) -> None:
node_type = None

if node_type in (None, NodeType.CIRCLE_PLUS):
_LOGGER.warning(
"Invalid NodeType in cache for mac %s: %s", mac, node_value
_LOGGER.info(
"Invalid NodeType %s found in cache for mac %s, ignoring...",
node_value,
mac,
)
continue
self._nodetypes[mac] = node_type
Expand All @@ -69,9 +71,9 @@ async def restore_cache(self) -> None:
str(node_type),
)

async def update_nodetypes(self, mac: str, node_type: NodeType | None) -> None:
async def update_nodetype(self, mac: str, node_type: NodeType | None) -> None:
"""Save node information in cache."""
if node_type is None:
if node_type in (None, NodeType.CIRCLE_PLUS):
return
if (current_node_type := self._nodetypes.get(mac)) is not None:
if current_node_type == node_type:
Expand Down
2 changes: 1 addition & 1 deletion plugwise_usb/network/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async def update_network_nodetype(self, mac: str, node_type: NodeType) -> None:
"""Update NodeType inside registry and cache."""
if self._network_cache is None or mac == "":
return
await self._network_cache.update_nodetypes(mac, node_type)
await self._network_cache.update_nodetype(mac, node_type)

def update_network_registration(self, mac: str) -> bool:
"""Add a mac to the network registration list return True if it was newly added."""
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 = "plugwise_usb"
version = "0.47.0"
version = "0.47.1"
license = "MIT"
keywords = ["home", "automation", "plugwise", "module", "usb"]
classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ async def makedirs(cache_dir: str, exist_ok: bool) -> None:

with patch("aiofiles.threadpool.sync_open", return_value=mock_file_stream):
# await pw_nw_cache.save_cache()
await pw_nw_cache.update_nodetypes(
await pw_nw_cache.update_nodetype(
"1234ABCD4321FEDC", pw_api.NodeType.STEALTH
)
mock_file_stream.writelines.assert_called_with(
Expand Down