Skip to content

Commit 1b571d2

Browse files
committed
Improve _get_module_data()
1 parent 0ce53a9 commit 1b571d2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

plugwise/helper.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,22 +463,23 @@ def _get_module_data(
463463
module = self._modules.find(loc)
464464
if module is not None: # pylint: disable=consider-using-assignment-expr
465465
model_data["contents"] = True
466-
model_data["vendor_name"] = module.find("vendor_name").text
467-
if model_data["vendor_name"] == "Plugwise B.V.":
468-
model_data["vendor_name"] = "Plugwise"
466+
if (vendor_name := module.find("vendor_name").text) is not None:
467+
model_data["vendor_name"] = vendor_name
468+
if "Plugwise" in vendor_name:
469+
model_data["vendor_name"] = vendor_name.split(" ", 1)[0]
469470
model_data["vendor_model"] = module.find("vendor_model").text
470471
model_data["hardware_version"] = module.find("hardware_version").text
471472
model_data["firmware_version"] = module.find("firmware_version").text
472473
# Adam
473-
if found := module.find("./protocols/zig_bee_node"):
474-
model_data["zigbee_mac_address"] = found.find("mac_address").text
475-
model_data["reachable"] = found.find("reachable").text == "true"
474+
if zb_node := module.find("./protocols/zig_bee_node"):
475+
model_data["zigbee_mac_address"] = zb_node.find("mac_address").text
476+
model_data["reachable"] = zb_node.find("reachable").text == "true"
476477
# Stretches
477-
if found := module.find("./protocols/network_router"):
478-
model_data["zigbee_mac_address"] = found.find("mac_address").text
478+
if router := module.find("./protocols/network_router"):
479+
model_data["zigbee_mac_address"] = router.find("mac_address").text
479480
# Also look for the Circle+/Stealth M+
480-
if found := module.find("./protocols/network_coordinator"):
481-
model_data["zigbee_mac_address"] = found.find("mac_address").text
481+
if coord := module.find("./protocols/network_coordinator"):
482+
model_data["zigbee_mac_address"] = coord.find("mac_address").text
482483

483484
return model_data
484485

0 commit comments

Comments
 (0)