Skip to content

Commit 1ffb28c

Browse files
committed
update similar to coderabbit suggestion
1 parent 4571512 commit 1ffb28c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

plugwise_usb/network/cache.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ async def restore_cache(self) -> None:
4545
for mac, node_value in data.items():
4646
node_type: NodeType | None = None
4747
if len(node_value) >= 10:
48-
node_type = NodeType[node_value[9:]]
49-
if node_type is not None:
50-
self._nodetypes[mac] = node_type
48+
try:
49+
node_type = NodeType[node_value[9:]]
50+
except KeyError:
51+
node_type = None
52+
if node_type is None:
53+
_LOGGER.warning("Invalid NodeType in cache: %s", node_value)
54+
continue
55+
self._nodetypes[mac] = node_type
5156
_LOGGER.debug(
5257
"Restore NodeType for mac %s with node type %s",
5358
mac,

0 commit comments

Comments
 (0)