From ac197390414ee24076053951a825937ca337adbd Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Thu, 2 Nov 2023 14:54:59 +0100 Subject: [PATCH] fix validate hierarchy if evu counter is missing --- packages/control/counter_all.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/control/counter_all.py b/packages/control/counter_all.py index 91c1cec501..8ad176ae38 100644 --- a/packages/control/counter_all.py +++ b/packages/control/counter_all.py @@ -412,7 +412,18 @@ def check_and_add(type_name: ComponentType, data_structure): if break_flag: break else: - self.hierarchy_add_item_below(entry_num, type_name, self.get_evu_counter().num) + try: + self.hierarchy_add_item_below(entry_num, type_name, self.get_evu_counter().num) + except (TypeError, IndexError): + # es gibt noch keinen EVU-Zähler + hierarchy = [{ + "id": entry_num, + "type": ComponentType.COUNTER.value, + "children": data.data.counter_all_data.data.get.hierarchy + }] + Pub().pub("openWB/set/counter/get/hierarchy", hierarchy) + data.data.counter_all_data.data.get.hierarchy = hierarchy + pub_system_message({}, f"{component_type_to_readable_text(type_name)} mit ID {element['id']} wurde" " in der Hierarchie hinzugefügt, da kein Eintrag in der Hierarchie gefunden " "wurde. Bitte prüfe die Anordnung der Komponenten in der Hierarchie.",