Skip to main content

knx-telegram-store

A standalone, host-agnostic Python library for KNX telegram persistence.

Features

  • Canonical Data Model: A unified model for KNX telegrams shared between Home Assistant and SpectrumKNX.
  • Pluggable Backends:
    • In-Memory: Fast, deque-based storage with full filtering support.
    • SQLite: Lightweight persistent storage with SQL-based filtering.
    • PostgreSQL + TimescaleDB: Full-scale time-series storage.
  • Unified Query Model: Powerful declarative filtering including time-delta context windows and pagination.
  • Zero Runtime Dependencies: Core library (model, interface, in-memory) has no dependencies.
  • Automated Schema Management: SQL backends handle their own creation and upgrades.

Installation

pip install knx-telegram-store

For SQL support:

pip install knx-telegram-store[sqlite]
pip install knx-telegram-store[postgres]

Usage

from datetime import datetime
from knx_telegram_store import StoredTelegram, TelegramQuery
from knx_telegram_store.backends.memory import MemoryStore

async def main():
    store = MemoryStore(max_size=1000)
    await store.initialize()

    telegram = StoredTelegram(
        timestamp=datetime.now(),
        source="1.1.1",
        destination="1/1/1",
        telegramtype="GroupValueWrite",
        direction="Incoming",
        value=22.5,
        unit="°C"
    )

    await store.store(telegram)

    query = TelegramQuery(destinations=["1/1/1"])
    result = await store.query(query)
    
    for t in result.telegrams:
        print(f"{t.timestamp}: {t.source} -> {t.destination} | {t.value} {t.unit}")

    await store.close()

Validating a config / connection

Before triggering an expensive operation such as a migration, you can validate that a store is reachable. Both checks return a structured ConnectionCheckResult (ok, kind, message, detail) instead of raising.

from knx_telegram_store import ConnectionErrorKind
from knx_telegram_store.backends.sqlite import SqliteStore
from knx_telegram_store.backends.postgres import PostgresStore

# Static, side-effect-free config validation (before constructing a store):
#  - SQLite: sync — checks the file is writeable or can be created
result = SqliteStore.check_config("/data/telegrams.db")
#  - Postgres: async — actually connects to verify user/password/host/port/database
result = await PostgresStore.check_config("postgresql://user:pw@host:5432/knx")

if not result.ok:
    print(f"[{result.kind}] {result.message}")  # e.g. [auth] Authentication failed ...

# Live probe of an already-constructed store (no migrations, no schema changes):
store = SqliteStore("/data/telegrams.db")
result = await store.check_connection()
if result.kind is ConnectionErrorKind.OK:
    await store.initialize()

License

MIT

Download files

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

Source Distribution

knx_telegram_store-0.6.0.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

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

knx_telegram_store-0.6.0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file knx_telegram_store-0.6.0.tar.gz.

File metadata

  • Download URL: knx_telegram_store-0.6.0.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for knx_telegram_store-0.6.0.tar.gz
Algorithm Hash digest
SHA256 77525de7974d35726bdc87d9b477b8edeee298d40fd2f76bb9ec3c40796beb24
MD5 5e3d8f3834d7f3db26f0da1688a3d392
BLAKE2b-256 ec598fbc82997ae7a072098a0a45517bee9149e74ac6f8971db6ad484d7c31f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for knx_telegram_store-0.6.0.tar.gz:

Publisher: publish.yml on XKNX/knx-telegram-store

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file knx_telegram_store-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for knx_telegram_store-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ece12eacd4119563a1ff6b268ad9fd36f08f3d6d69a35eb352d52f9c96e7564
MD5 8f66097c1a3e9fdc143713843105f720
BLAKE2b-256 b3f396ebda3eee5279db6cb2db9b24ec06a876f975c7c33dec9152bafff7556d

See more details on using hashes here.

Provenance

The following attestation bundles were made for knx_telegram_store-0.6.0-py3-none-any.whl:

Publisher: publish.yml on XKNX/knx-telegram-store

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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