py-oepl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ env:
10
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11
+
12
+ jobs:
13
+ lint:
14
+ name: Lint
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v6
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+
22
+ - name: Install dependencies
23
+ run: uv sync --extra dev
24
+
25
+ - name: Run prek
26
+ run: uv run prek run --all-files
@@ -0,0 +1,45 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ env:
10
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11
+
12
+ permissions:
13
+ contents: write
14
+ pull-requests: write
15
+ id-token: write # For PyPI trusted publishing
16
+
17
+ jobs:
18
+ release-please:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: googleapis/release-please-action@v4
22
+ id: release
23
+ with:
24
+ release-type: python
25
+
26
+ # The following steps only run if a release was created
27
+ - name: Checkout code
28
+ if: ${{ steps.release.outputs.release_created }}
29
+ uses: actions/checkout@v6
30
+
31
+ - name: Install uv
32
+ if: ${{ steps.release.outputs.release_created }}
33
+ uses: astral-sh/setup-uv@v5
34
+
35
+ - name: Install dependencies
36
+ if: ${{ steps.release.outputs.release_created }}
37
+ run: uv sync
38
+
39
+ - name: Build package
40
+ if: ${{ steps.release.outputs.release_created }}
41
+ run: uv build
42
+
43
+ - name: Publish to PyPI
44
+ if: ${{ steps.release.outputs.release_created }}
45
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,42 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ env:
10
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11
+
12
+ jobs:
13
+ test:
14
+ name: Test Suite (Python ${{ matrix.python-version }})
15
+ runs-on: ubuntu-latest
16
+ timeout-minutes: 5
17
+ strategy:
18
+ matrix:
19
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v6
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+
27
+ - name: Install dependencies
28
+ run: uv sync --extra dev
29
+
30
+ - name: Run tests
31
+ run: uv run pytest tests/ -v --tb=short
32
+
33
+ - name: Generate coverage report
34
+ if: matrix.python-version == '3.12'
35
+ run: uv run pytest tests/ --cov=src/oepl --cov-report=xml --cov-report=term
36
+
37
+ - name: Upload coverage to Codecov
38
+ if: matrix.python-version == '3.12'
39
+ uses: codecov/codecov-action@v4
40
+ with:
41
+ file: ./coverage.xml
42
+ fail_ci_if_error: false
@@ -0,0 +1,172 @@
1
+ ### Python template
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ .idea/
164
+
165
+ # Image files
166
+ *.png
167
+ *.jpg
168
+ *.jpeg
169
+ *.gif
170
+ *.bmp
171
+ *.svg
172
+
@@ -0,0 +1,18 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: ruff
5
+ name: ruff
6
+ language: system
7
+ entry: uv run ruff check --fix
8
+ types: [python]
9
+ - id: ruff-format
10
+ name: ruff-format
11
+ language: system
12
+ entry: uv run ruff format
13
+ types: [python]
14
+ - id: mypy
15
+ name: mypy
16
+ language: system
17
+ entry: uv run mypy src/
18
+ pass_filenames: false
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-04-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * add tag command ([cc61115](https://github.com/g4bri3lDev/py-oepl/commit/cc61115ae23aef04e27e877a9adf01c46d9fafc6))
9
+ * initial implementation with claude ([d2bdc69](https://github.com/g4bri3lDev/py-oepl/commit/d2bdc69a7006aaab6d18f405f944a65f56494147))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * minor fixes ([41b62e1](https://github.com/g4bri3lDev/py-oepl/commit/41b62e1b6ebc741d8fbb219dc33522924307683f))
15
+ * minor fixes ([a8019ac](https://github.com/g4bri3lDev/py-oepl/commit/a8019ac074500cd0c3ec997459a4ed8ea981072d))
py_oepl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-oepl
3
+ Version: 0.1.0
4
+ Summary: Async Python client for the OpenDisplay AP (OpenEPaperLink)
5
+ License: MIT
6
+ Keywords: async,eink,epaper,iot,oepl,openepaperlink
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Framework :: AsyncIO
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Home Automation
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: aiohttp>=3.9
20
+ Requires-Dist: epaper-dithering>=0.6.4
21
+ Requires-Dist: numpy>=1.20
22
+ Requires-Dist: pillow>=10.0
23
+ Requires-Dist: rich>=14.3.4
24
+ Provides-Extra: dev
25
+ Requires-Dist: aioresponses>=0.7.8; extra == 'dev'
26
+ Requires-Dist: mypy>=1.0; extra == 'dev'
27
+ Requires-Dist: prek>=0.3.4; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=1.3; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
30
+ Requires-Dist: pytest>=9.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # oepl
35
+
36
+ Async Python client for the [OpenEPaperLink](https://github.com/jjwbruijn/OpenEPaperLink) Access Point (AP).
37
+
38
+ - Full async/await API via `aiohttp`
39
+ - Live tag updates over WebSocket
40
+ - Image upload with optional client-side dithering
41
+ - Raw image download and decoding (G5, zlib, bitmap)
42
+ - LED flash control
43
+ - CLI for interactive use
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install py-oepl
49
+ ```
50
+
51
+ With client-side dithering support:
52
+
53
+ ```bash
54
+ pip install py-oepl epaper-dithering
55
+ ```
56
+
57
+ ## Quick start
58
+
59
+ ```python
60
+ import asyncio
61
+ from oepl import OEPLClient
62
+
63
+ async def main():
64
+ async with OEPLClient("192.168.1.100") as client:
65
+ tags = await client.get_tags()
66
+ for tag in tags:
67
+ print(tag.mac, tag.alias, tag.battery_mv, "mV")
68
+
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ ## CLI
73
+
74
+ Set `OEPL_HOST` to avoid passing `--host` every time:
75
+
76
+ ```bash
77
+ export OEPL_HOST=192.168.1.100
78
+ ```
79
+
80
+ ### List tags
81
+
82
+ ```bash
83
+ oepl --host 192.168.1.100 tags
84
+ oepl tags --json # machine-readable JSON
85
+ oepl tags --watch # live stream via WebSocket
86
+ ```
87
+
88
+ ### AP info
89
+
90
+ ```bash
91
+ oepl ap # hardware info + current config
92
+ oepl ap --json
93
+ ```
94
+
95
+ ### Upload an image
96
+
97
+ ```bash
98
+ oepl upload AABBCCDDEEFF image.png
99
+ oepl upload AABBCCDDEEFF image.png --lut fast --rotate 90 --ttl 300
100
+ ```
101
+
102
+ `--lut` choices: `default`, `no-repeat`, `fast-no-reds`, `fast`
103
+ `--rotate` choices: `0`, `90`, `180`, `270`
104
+ `--ttl` is in seconds; `0` lets the AP use the tag's default sleep interval.
105
+
106
+ ### Send a command
107
+
108
+ ```bash
109
+ oepl cmd AABBCCDDEEFF refresh
110
+ oepl cmd AABBCCDDEEFF clear
111
+ oepl cmd AABBCCDDEEFF reboot
112
+ oepl cmd AABBCCDDEEFF scan
113
+ ```
114
+
115
+ ### Flash LEDs
116
+
117
+ ```bash
118
+ oepl led AABBCCDDEEFF --color 255 0 0
119
+ oepl led AABBCCDDEEFF --color 0 255 0 --flash-speed 0.5 --flash-count 3
120
+ oepl led AABBCCDDEEFF --color 0 0 255 --brightness 3 --repeats 4
121
+ ```
122
+
123
+ ### Download and decode the stored image
124
+
125
+ ```bash
126
+ oepl get-image AABBCCDDEEFF # prints decoded JPEG to stdout
127
+ oepl get-image AABBCCDDEEFF -o out.jpg # save to file
128
+ ```
129
+
130
+ Tag type definitions are fetched directly from the AP — no internet access required.
131
+
132
+ ## Python API
133
+
134
+ ### `OEPLClient`
135
+
136
+ ```python
137
+ from oepl import OEPLClient
138
+
139
+ client = OEPLClient(
140
+ host="192.168.1.100",
141
+ session=None, # optional: supply an existing aiohttp.ClientSession
142
+ reconnect_interval=30.0, # seconds between WebSocket reconnect attempts
143
+ )
144
+ ```
145
+
146
+ Use as an async context manager (recommended) or call `connect()` / `disconnect()` manually.
147
+
148
+ #### Tag operations
149
+
150
+ ```python
151
+ # Fetch all tags (paginated); populates internal cache; fires on_tag_update callbacks
152
+ tags: list[Tag] = await client.get_tags()
153
+
154
+ # Upload an image (PIL Image or raw bytes)
155
+ from PIL import Image
156
+ img = Image.open("label.png")
157
+ await client.upload_image(
158
+ "AABBCCDDEEFF",
159
+ img,
160
+ ttl=300, # seconds; 0 = tag default
161
+ rotate=Rotation.R90,
162
+ lut=LUT.FAST,
163
+ )
164
+
165
+ # Set the alias shown in the AP web UI
166
+ await client.set_alias("AABBCCDDEEFF", "my-display")
167
+
168
+ # Send a command
169
+ from oepl import TagCommand
170
+ await client.send_tag_cmd("AABBCCDDEEFF", TagCommand.REFRESH)
171
+
172
+ # Flash LEDs
173
+ from oepl.led import Color, LEDPattern, LEDSegment
174
+ pattern = LEDPattern([LEDSegment(Color(255, 0, 0))], repeats=3)
175
+ await client.set_led("AABBCCDDEEFF", pattern)
176
+
177
+ # Fetch the tag type definition (served by the AP, works offline)
178
+ tag_type = await client.get_tag_type(0x16) # returns TagType | None
179
+
180
+ # Download and decode the stored image for a tag
181
+ from oepl import decode_image
182
+ raw = await client.get_image_raw("AABBCCDDEEFF") # bytes | None
183
+ if raw and tag_type:
184
+ jpeg_bytes = decode_image(raw, tag_type)
185
+ ```
186
+
187
+ #### AP operations
188
+
189
+ ```python
190
+ info = await client.get_sysinfo() # APInfo — hardware/firmware
191
+ config = await client.get_ap_config() # APConfig — current settings
192
+ await client.save_ap_config(config)
193
+ await client.set_time(int(time.time()))
194
+ await client.reboot_ap()
195
+ ```
196
+
197
+ #### Live updates via WebSocket
198
+
199
+ ```python
200
+ async with OEPLClient("192.168.1.100") as client:
201
+ client.on_tag_update(lambda tag: print("updated:", tag.mac))
202
+ client.on_ap_status(lambda s: print("AP free heap:", s.free_heap))
203
+ client.on_connection_change(lambda ok: print("connected:", ok))
204
+ client.on_log(lambda msg: print("AP log:", msg))
205
+
206
+ # Callbacks fire as WebSocket messages arrive.
207
+ # on_tag_update also fires for each tag returned by get_tags().
208
+ tags = await client.get_tags()
209
+ await asyncio.sleep(60)
210
+ ```
211
+
212
+ Each `on_*` method returns an unsubscribe callable:
213
+
214
+ ```python
215
+ unsub = client.on_tag_update(my_callback)
216
+ # later:
217
+ unsub()
218
+ ```
219
+
220
+ ### Models
221
+
222
+ | Class | Key fields |
223
+ |---|---|
224
+ | `Tag` | `mac`, `alias`, `hw_type`, `last_seen`, `battery_mv`, `lqi`, `rssi`, `channel`, `content_mode`, `firmware_version` |
225
+ | `APInfo` | `alias`, `env`, `build_version`, `ap_version`, `psram_size`, `flash_size`, `has_c6`, `has_ble` |
226
+ | `APConfig` | `ap_channel`, `led`, `maxsleep`, `tz`, `preview`, `night_start`, `night_end` |
227
+ | `APStatus` | `ip`, `heap`, `free_heap`, `run_status`, `temp`, `wifi_rssi`, `record_count` |
228
+ | `TagType` | `type_id`, `width`, `height`, `bpp`, `color_table`, `short_lut` |
229
+
230
+ ### Enums
231
+
232
+ ```python
233
+ from oepl import LUT, Rotation, TagCommand
234
+ from oepl.enums import APState, RunStatus
235
+ ```
236
+
237
+ | Enum | Values |
238
+ |---|---|
239
+ | `LUT` | `NO_REPEAT`, `DEFAULT`, `FAST_NO_REDS`, `FAST` |
240
+ | `Rotation` | `NONE`, `R90`, `R180`, `R270` |
241
+ | `TagCommand` | `CLEAR`, `REFRESH`, `REBOOT`, `SCAN` |
242
+ | `APState` | `OFFLINE`, `ONLINE`, `FLASHING`, `WAIT_CHECKIN`, `WAIT_SETTIME`, `IDLE`, `DOWNLOADING`, `NO_RADIO` |
243
+
244
+ ### Exceptions
245
+
246
+ ```python
247
+ from oepl.exceptions import (
248
+ OEPLError, # base
249
+ OEPLConnectionError, # could not reach AP
250
+ OEPLTimeoutError, # request timed out (after retries)
251
+ OEPLNotFoundError, # 404
252
+ OEPLResponseError, # other non-2xx (has .status and .body)
253
+ )
254
+ ```
255
+
256
+ ### Image dithering
257
+
258
+ When `epaper-dithering` is installed, `upload_image` applies Floyd-Steinberg dithering automatically for BWR displays. Override with:
259
+
260
+ ```python
261
+ from oepl import DitherMode, ColorScheme
262
+
263
+ await client.upload_image(
264
+ mac,
265
+ pil_image,
266
+ dither_mode=DitherMode.NONE,
267
+ color_scheme=ColorScheme.BW,
268
+ )
269
+ ```
270
+
271
+ `DitherMode` and `ColorScheme` are `None` when `epaper-dithering` is not installed.
272
+
273
+ ## Development
274
+
275
+ ```bash
276
+ uv sync
277
+ uv run pytest
278
+ ```
279
+
280
+ ## License
281
+
282
+ MIT