Skip to main content

A library to gather information from ETS project files used for KNX

Project description

(X)KNX Project

Pre-commit Discord codecov

Extracts KNX projects and asynchronously parses the underlying XML.

This project aims to provide a library that can be used to extract and parse KNX project files and read out useful information including the group addresses, devices and their descriptions and possibly more.

Documentation

Currently, xknxproject supports extracting (password protected) ETS5 and ETS6 files and can obtain the following information from your project:

  • Areas, Lines, Devices and their individual address
  • CommunicationObjectInstance references for their devices (GA assignments)
  • Group Addresses and their DPT type if set
  • The application programs communication objects and their respective flags and the DPT Type

Caution: Loading a middle-sized project with this tool takes about 1.5 seconds. For bigger projects this might as well be >3s.

Installation

In order to parse XML and to overcome the performance issues that parsing application programs with over 800k lines of XML has we use lxml. lxml requires libxml2 to be installed in the underlying system. You can read more on their documentation on this topic.

pip install xknxproject

Usage

import asyncio
from xknxproject.models import KNXProject
from xknxproject import KNXProj


async def main():
    """Extract and parse a KNX project file."""
    knxproj: KNXProj = KNXProj("path/to/your/file.knxproj", "optional_password")
    project: KNXProject = await knxproj.parse()

asyncio.run_until_complete(main())

The KNXProject is a typed dictionary and can be used just like a dictionary, or, exported as JSON. You can find an example file (exported JSON) in our test suite under https://github.com/XKNX/xknxproject/tree/main/test/resources/stubs

The full type definition can be found here: https://github.com/XKNX/xknxproject/blob/main/xknxproject/models/knxproject.py

TODOs / Ideas

  • Parse location information (which device is in which room) - caution: not all devices may be mapped to a room
  • Since parsing is rather expensive we could add a callback to inform the user (over the HA websocket) what the current steps are and what is being parsed. Might be cool for UX.
  • Migrate remaining minidom logic to lxml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xknxproject-1.0.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xknxproject-1.0.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file xknxproject-1.0.0.tar.gz.

File metadata

  • Download URL: xknxproject-1.0.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for xknxproject-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b0c528f40a2d3dd2196e98b10973023c962a20d8700183c575ab9638cfe0c0ac
MD5 bb1124a210bba8b1c441fd9182114960
BLAKE2b-256 ec8281fb8b33596f71b4841ef681f243c319528ffbf258cd5223373c48b4305c

See more details on using hashes here.

File details

Details for the file xknxproject-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: xknxproject-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for xknxproject-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88ac91ec509a216ea6c8daa3efa5c2056790ee758dae6c8436c432a767952268
MD5 a10d55932c0d39acfb0e1f9bbb506413
BLAKE2b-256 8dea48b8930224e265bbf5b93b5b396bc95c339a34c93c1e6f869bb7fab4204e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page