KOReader telemetry snapshot model and Home Assistant command protocol (parsing, command builders, coalescing command queue).
Project description
pykoreader
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 aSnapshot(raisesValueErrorotherwise).commands— builders:set_frontlight,set_warmth,set_frontlight_power,set_wifi,page_turn,goto_page,goto_chapter,toggle_bookmark,set_dark_mode,suspend,restart,refresh,sync_now,show_message; plus type constants andCOALESCE_TYPES.CommandQueue—add(command),drain(),pending,len(). Coalesces idempotent types (last-write-wins), caps atMAX_QUEUED_COMMANDS.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykoreader-0.2.0.tar.gz.
File metadata
- Download URL: pykoreader-0.2.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a54afb128d211673f93e431a5289a6b36fab5d51ebece29180a208c3179b4b8
|
|
| MD5 |
dcffe1e6ce9c6c0e5b83844e620daf36
|
|
| BLAKE2b-256 |
f0a7b176a55ba1f5dbb950b1ce7a99d739ea351fbc55e4428b55e79eb335d7f8
|
Provenance
The following attestation bundles were made for pykoreader-0.2.0.tar.gz:
Publisher:
release.yml on hudsonbrendon/pykoreader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykoreader-0.2.0.tar.gz -
Subject digest:
3a54afb128d211673f93e431a5289a6b36fab5d51ebece29180a208c3179b4b8 - Sigstore transparency entry: 1659218063
- Sigstore integration time:
-
Permalink:
hudsonbrendon/pykoreader@06eab06a127b5930969e41ead6ed4603fd398fc5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hudsonbrendon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@06eab06a127b5930969e41ead6ed4603fd398fc5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pykoreader-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pykoreader-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c34d60e1f92abc795e896ca282721a487bb8f2cd7ea15deeebffedad7b14c6
|
|
| MD5 |
0a39c605c15507fd308ba85c2eb30e58
|
|
| BLAKE2b-256 |
f4dee8236a7f518824010094a779d18b7ce54b42ac0e783790e96431cf7fe021
|
Provenance
The following attestation bundles were made for pykoreader-0.2.0-py3-none-any.whl:
Publisher:
release.yml on hudsonbrendon/pykoreader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykoreader-0.2.0-py3-none-any.whl -
Subject digest:
38c34d60e1f92abc795e896ca282721a487bb8f2cd7ea15deeebffedad7b14c6 - Sigstore transparency entry: 1659218161
- Sigstore integration time:
-
Permalink:
hudsonbrendon/pykoreader@06eab06a127b5930969e41ead6ed4603fd398fc5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hudsonbrendon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@06eab06a127b5930969e41ead6ed4603fd398fc5 -
Trigger Event:
push
-
Statement type: