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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.40.1

- Improve device Name and Model detection for Switch [#248](https://github.com/plugwise/python-plugwise-usb/pull/248)

## v0.40.0

- Make auto-joining work: (@bouwew)
Expand Down
27 changes: 22 additions & 5 deletions plugwise_usb/nodes/node.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -490,11 +490,18 @@ async def update_node_details(
) -> bool:
"""Process new node info and return true if all fields are updated."""
complete = True
if node_type is None:
complete = False
else:
self._node_info.node_type = NodeType(node_type)
self._set_cache(CACHE_NODE_TYPE, self._node_info.node_type.value)

if firmware is None:
complete = False
else:
self._node_info.firmware = firmware
self._set_cache(CACHE_FIRMWARE, firmware)

if hardware is None:
complete = False
else:
Expand All@@ -503,6 +510,18 @@ async def update_node_details(
hardware, model_info = version_to_model(hardware)
model_info = model_info.split(" ")
self._node_info.model = model_info[0]
# Correct model when node_type doesn't match
# Switch reports hardware version of paired Circle (pw_usb_beta #245)
if (
self._node_info.node_type is not None
and (
correct_model := self._node_info.node_type.name.lower().split("_")[0]
) not in self._node_info.model.lower()
):
self._node_info.model = correct_model.capitalize()
# Replace model_info list
model_info = [self._node_info.model]

# Handle + devices
if len(model_info) > 1 and "+" in model_info[1]:
self._node_info.model = model_info[0] + " " + model_info[1]
Expand All@@ -522,21 +541,19 @@ async def update_node_details(
if self._node_info.model is not None:
self._node_info.name = f"{model_info[0]} {self._node_info.mac[-5:]}"
self._set_cache(CACHE_HARDWARE, hardware)

if timestamp is None:
complete = False
else:
self._node_info.timestamp = timestamp
self._set_cache(CACHE_NODE_INFO_TIMESTAMP, timestamp)
if node_type is None:
complete = False
else:
self._node_info.node_type = NodeType(node_type)
self._set_cache(CACHE_NODE_TYPE, self._node_info.node_type.value)

await self.save_cache()
if timestamp is not None and timestamp > datetime.now(tz=UTC) - timedelta(
minutes=5
):
await self._available_update_state(True, timestamp)

return complete

async def is_online(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plugwise_usb"
version = "v0.40.0"
version = "v0.40.1b0"
license = "MIT"
keywords = ["home", "automation", "plugwise", "module", "usb"]
classifiers = [
Expand Down