Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
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
4 changes: 2 additions & 2 deletions plugwise_usb/network/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,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.1a0"
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