Skip to main content

KOReader telemetry snapshot model and Home Assistant command protocol (parsing, command builders, coalescing command queue).

Project description

pykoreader

CI PyPI

Pure-Python model of the KOReader telemetry snapshot and the Home Assistant command protocol: snapshot parsing, command builders, and a coalescing, capped command queue. No Home Assistant or network dependencies.

Used by the ha-koreader Home Assistant integration, but usable standalone.

Install

pip install pykoreader

Usage

from pykoreader import Snapshot, CommandQueue, parse_payload, commands

# Parse an incoming webhook body (a decoded JSON object) into a typed snapshot.
snap = parse_payload({"battery_level": 80, "reading": True, "book_title": "Foundation"})
print(snap.battery_level, snap.book_title)   # 80 Foundation

# Build and queue commands for the device's next check-in.
queue = CommandQueue()
queue.add(commands.set_frontlight(40))
queue.add(commands.set_frontlight(60))       # idempotent: replaces the previous one
queue.add(commands.show_message("Time to sleep", timeout=10))
print(queue.drain())                         # returns pending commands and clears

API

  • Snapshot / Snapshot.from_payload(mapping) — typed telemetry fields; unknown keys kept in .extra.
  • parse_payload(raw) — validate a decoded body is an object and return a Snapshot (raises ValueError otherwise).
  • commands — builders: set_frontlight, set_warmth, set_frontlight_power, set_wifi, page_turn, goto_page, refresh, sync_now, show_message; plus type constants and COALESCE_TYPES.
  • CommandQueueadd(command), drain(), pending, len(). Coalesces idempotent types (last-write-wins), caps at MAX_QUEUED_COMMANDS.

License

MIT

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

pykoreader-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

pykoreader-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pykoreader-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pykoreader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 95b9a4c57edd588a17317ed9482595cd253dab29efdf9112d7a0a4b02d2bd0d0
MD5 fced6aaf8bd1d8146b6146d2cb820564
BLAKE2b-256 a0c9fddf689b8fba42d70ddfc132eb7829894e8cb5bfffe27e741e71c6d14390

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykoreader-0.1.0.tar.gz:

Publisher: release.yml on hudsonbrendon/pykoreader

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

File details

Details for the file pykoreader-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pykoreader-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pykoreader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee90d0603f54791ba14cee64d1304b7f1d864fd1777b2a1dfc5c48c6486d9bb
MD5 2fe67e955b0cfaffe00f5ade626ddb71
BLAKE2b-256 23154ff7d159815ceb8aeb8f78dcce8c4f3c9ac5f80ddfd4d4abf438b4dcec92

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykoreader-0.1.0-py3-none-any.whl:

Publisher: release.yml on hudsonbrendon/pykoreader

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 Pingdom Monitoring Sentry Error logging StatusPage Status page