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
11 changes: 11 additions & 0 deletions plugwise_usb/constants.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,3 +88,14 @@
"070051": "Switch",
"080029": "Switch",
}

TYPE_MODEL: Final[dict[int, tuple[str]]] = {
0: ("Stick",),
1: ("Circle", "Stealth"),
3: ("Switch",),
5: ("Sense",),
6: ("Scan",),
7: ("Celsius",),
8: ("Celsius",),
9: ("Stealth",),
}
20 changes: 7 additions & 13 deletions plugwise_usb/nodes/node.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
RelayState,
)
from ..connection import StickController
from ..constants import SUPPRESS_INITIALIZATION_WARNINGS, UTF8
from ..constants import SUPPRESS_INITIALIZATION_WARNINGS, TYPE_MODEL, UTF8
from ..exceptions import FeatureError, NodeError
from ..helpers.util import version_to_model
from ..messages.requests import NodeInfoRequest, NodePingRequest
Expand All@@ -38,20 +38,17 @@

_LOGGER = logging.getLogger(__name__)


NODE_FEATURES = (
NodeFeature.AVAILABLE,
NodeFeature.INFO,
NodeFeature.PING,
)


CACHE_FIRMWARE = "firmware"
CACHE_NODE_TYPE = "node_type"
CACHE_HARDWARE = "hardware"
CACHE_NODE_INFO_TIMESTAMP = "node_info_timestamp"


class PlugwiseBaseNode(FeaturePublisher, ABC):
"""Abstract Base Class for a Plugwise node."""

Expand DownExpand Up@@ -512,15 +509,12 @@ async def update_node_details(
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]
if self._node_info.node_type is not None:
allowed_models = TYPE_MODEL.get(self._node_info.node_type.value)
if allowed_models and model_info[0] not in allowed_models:
# Replace model_info list
model_info = [allowed_models[0]] # Not correct for 1 but should not be a problem
self._node_info.model = model_info[0]

# Handle + devices
if len(model_info) > 1 and "+" in model_info[1]:
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.1b0"
version = "v0.40.1b1"
license = "MIT"
keywords = ["home", "automation", "plugwise", "module", "usb"]
classifiers = [
Expand Down