From 985d56c24511d41285a5ea200f1912eb5f66b973 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 16 Aug 2025 11:57:04 +0200 Subject: [PATCH 1/5] Catch TypeError in validate_mac() --- plugwise_usb/helpers/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugwise_usb/helpers/util.py b/plugwise_usb/helpers/util.py index 19f9d1159..0ee794609 100644 --- a/plugwise_usb/helpers/util.py +++ b/plugwise_usb/helpers/util.py @@ -7,14 +7,19 @@ import crcmod from ..constants import HW_MODELS +from ..exceptions import NodeError crc_fun = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000) def validate_mac(mac: str) -> bool: """Validate the supplied string is in a MAC address format.""" - if not re.match("^[A-F0-9]+$", mac): + try: + if not re.match("^[A-F0-9]+$", mac): + return False + except TypeError: return False + try: _ = int(mac, 16) except ValueError: From 8c9a3535088bfeb0c9575859559aa9ed23444d45 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 16 Aug 2025 12:04:46 +0200 Subject: [PATCH 2/5] Start CHANGELOG update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e11edc4f9..01c8a6349 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Ongoing +- PR [](): Catch error from Issue [#312]() - PR [319](https://github.com/plugwise/python-plugwise-usb/pull/319): Replace unclear warning message when a node is not online, also various small improvements suggested by CRAI. - PR [312](https://github.com/plugwise/python-plugwise-usb/pull/312): properly propagate configuration changes and initialize to available on first node wakeup From 5aafcbb3d25cd02e214521cc064e5d8ff8d20041 Mon Sep 17 00:00:00 2001 From: autoruff Date: Sat, 16 Aug 2025 10:05:36 +0000 Subject: [PATCH 3/5] fixup: impr-312 Python code reformatted using Ruff --- plugwise_usb/helpers/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise_usb/helpers/util.py b/plugwise_usb/helpers/util.py index 0ee794609..112fdefd4 100644 --- a/plugwise_usb/helpers/util.py +++ b/plugwise_usb/helpers/util.py @@ -19,7 +19,7 @@ def validate_mac(mac: str) -> bool: return False except TypeError: return False - + try: _ = int(mac, 16) except ValueError: From 75bdd06af6708967cbb440b160b45c44546686c6 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 16 Aug 2025 12:11:42 +0200 Subject: [PATCH 4/5] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c8a6349..f34f0e54d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Ongoing -- PR [](): Catch error from Issue [#312]() +- PR [321](https://github.com/plugwise/python-plugwise-usb/pull/321): Catch error reported in Issue [#312](https://github.com/plugwise/plugwise_usb-beta/issues/312) - PR [319](https://github.com/plugwise/python-plugwise-usb/pull/319): Replace unclear warning message when a node is not online, also various small improvements suggested by CRAI. - PR [312](https://github.com/plugwise/python-plugwise-usb/pull/312): properly propagate configuration changes and initialize to available on first node wakeup From e042352e956d8d0365ac32438d657d4d1fac36b7 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 16 Aug 2025 12:14:40 +0200 Subject: [PATCH 5/5] Clean up unused import --- plugwise_usb/helpers/util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugwise_usb/helpers/util.py b/plugwise_usb/helpers/util.py index 112fdefd4..d2293b965 100644 --- a/plugwise_usb/helpers/util.py +++ b/plugwise_usb/helpers/util.py @@ -7,7 +7,6 @@ import crcmod from ..constants import HW_MODELS -from ..exceptions import NodeError crc_fun = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)