From e6fb4b214a1967a6cee012ad19799293b6dbfc6f Mon Sep 17 00:00:00 2001 From: farmio Date: Thu, 2 Nov 2023 08:44:47 +0100 Subject: [PATCH] stop iteration when module instance found --- xknxproject/models/models.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xknxproject/models/models.py b/xknxproject/models/models.py index 7614b7e..ea976a6 100644 --- a/xknxproject/models/models.py +++ b/xknxproject/models/models.py @@ -206,13 +206,16 @@ def _add_com_object_instance_numbers(self) -> None: or coir.number is None # only for type safety ): continue - for mi in self.module_instances: - if coir.ref_id.startswith(f"{mi.identifier}_"): - coir.number += next( - int(arg.value) - for arg in mi.arguments - if arg.ref_id == coir.base_number_argument_ref - ) + _module_instance = next( + mi + for mi in self.module_instances + if coir.ref_id.startswith(f"{mi.identifier}_") + ) + coir.number += next( + int(arg.value) + for arg in _module_instance.arguments + if arg.ref_id == coir.base_number_argument_ref + ) def apply_module_instance_arguments(self) -> None: """Apply module instance arguments."""