Skip to content

Commit 9be2c00

Browse files
authored
Correctly parse Schema 14 device links (#534)
* Correctly parse Schema 14 device links * amend comment
1 parent c60a6b6 commit 9be2c00

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

xknxproject/loader/project_loader.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
from xml.etree import ElementTree
77

8+
from xknxproject.const import ETS_5_7_SCHEMA_VERSION
89
from xknxproject.exceptions import UnexpectedDataError
910
from xknxproject.models import (
1011
ChannelNode,
@@ -313,8 +314,8 @@ def _create_device(
313314
)
314315

315316
@staticmethod
316-
def __get_links_from_ets4(com_object: ElementTree.Element) -> list[str]:
317-
# Check if "Connectors" is available. This will always fail for ETS5/6
317+
def __get_links_from_schema_1x(com_object: ElementTree.Element) -> list[str]:
318+
# Check if "Connectors" is available. Schema version <= 14
318319
if (connectors := com_object.find("{*}Connectors")) is None:
319320
return []
320321

@@ -327,8 +328,8 @@ def __get_links_from_ets4(com_object: ElementTree.Element) -> list[str]:
327328
]
328329

329330
@staticmethod
330-
def __get_links_from_ets5(com_object: ElementTree.Element) -> list[str]:
331-
# ETS5/6 uses a space-separated string of GA
331+
def __get_links_from_schema_2x(com_object: ElementTree.Element) -> list[str]:
332+
# ETS 5.7+ / 6 uses a space-separated string of GA
332333
links = com_object.get("Links")
333334

334335
if links is None:
@@ -342,10 +343,10 @@ def _create_com_object_instance(
342343
) -> ComObjectInstanceRef | None:
343344
"""Create ComObjectInstanceRef."""
344345

345-
if self.__knx_proj_contents.is_ets4_project():
346-
links = self.__get_links_from_ets4(com_object)
346+
if self.__knx_proj_contents.schema_version < ETS_5_7_SCHEMA_VERSION:
347+
links = self.__get_links_from_schema_1x(com_object)
347348
else:
348-
links = self.__get_links_from_ets5(com_object)
349+
links = self.__get_links_from_schema_2x(com_object)
349350

350351
if not links:
351352
return None

0 commit comments

Comments
 (0)