diff --git a/xknxproject/loader/project_loader.py b/xknxproject/loader/project_loader.py index 36edbdc..bfe22bd 100644 --- a/xknxproject/loader/project_loader.py +++ b/xknxproject/loader/project_loader.py @@ -151,8 +151,11 @@ def _create_device( for sub_node in device_element: if sub_node.tag.endswith("AdditionalAddresses"): for address_node in sub_node: - if _address := address_node.get("Address"): - device.additional_addresses.append(_address) + device.add_additional_address( + device_address=address_node.get("Address"), # type: ignore[arg-type] + description=address_node.get("Description", ""), + name=address_node.get("Name"), + ) if sub_node.tag.endswith("ComObjectInstanceRefs"): for com_object in sub_node: if instance := _TopologyLoader._create_com_object_instance( diff --git a/xknxproject/models/models.py b/xknxproject/models/models.py index ae3fd6d..d0b59d9 100644 --- a/xknxproject/models/models.py +++ b/xknxproject/models/models.py @@ -82,7 +82,6 @@ def __init__( hardware_program_ref: str, line: XMLLine, manufacturer: str, - additional_addresses: list[str] | None = None, com_object_instance_refs: list[ComObjectInstanceRef] | None = None, com_objects: list[ComObject] | None = None, ): @@ -97,7 +96,7 @@ def __init__( self.hardware_program_ref = hardware_program_ref self.line = line self.manufacturer = manufacturer - self.additional_addresses = additional_addresses or [] + self.additional_addresses: list[AdditionalAddress] = [] self.com_object_instance_refs = com_object_instance_refs or [] self.com_objects = com_objects or [] self.application_program_ref: str | None = None @@ -109,10 +108,16 @@ def __init__( self.hardware_name: str = "" self.manufacturer_name: str = "" - def add_additional_address(self, address: str) -> None: + def add_additional_address( + self, device_address: str, description: str, name: str | None + ) -> None: """Add an additional individual address.""" self.additional_addresses.append( - f"{self.line.area.address}/{self.line.address}/{address}" + AdditionalAddress( + address=f"{self.line.area.address}.{self.line.address}.{device_address}", + description=description, + name=name, + ) ) def application_program_xml(self) -> str: @@ -120,6 +125,17 @@ def application_program_xml(self) -> str: return f"{self.manufacturer}/{self.application_program_ref}.xml" +@dataclass +class AdditionalAddress: + """Class that represents an additional address of IP interfaces.""" + + address: str + description: str # default: "" + # TODO: IP Secure interfaces use `BusInterface` to transport name and + # leave this an empty string. I don't know how `AddressIndex` relates. + name: str | None + + @dataclass class ComObjectInstanceRef: """Class that represents a ComObjectInstanceRef instance."""