proflame 0.1.0__tar.gz → 0.2.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.
- {proflame-0.1.0 → proflame-0.2.0}/.github/workflows/ci.yml +5 -5
- {proflame-0.1.0 → proflame-0.2.0}/.github/workflows/release-please.yml +4 -4
- proflame-0.2.0/.release-please-manifest.json +3 -0
- {proflame-0.1.0 → proflame-0.2.0}/CHANGELOG.md +14 -0
- {proflame-0.1.0 → proflame-0.2.0}/PKG-INFO +5 -4
- {proflame-0.1.0 → proflame-0.2.0}/README.md +4 -3
- {proflame-0.1.0 → proflame-0.2.0}/pyproject.toml +1 -1
- {proflame-0.1.0 → proflame-0.2.0}/src/proflame/__init__.py +2 -0
- {proflame-0.1.0 → proflame-0.2.0}/src/proflame/protocol.py +49 -9
- {proflame-0.1.0 → proflame-0.2.0}/tests/test_protocol.py +40 -2
- proflame-0.1.0/.release-please-manifest.json +0 -3
- {proflame-0.1.0 → proflame-0.2.0}/.gitignore +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/.vscode/ltex.dictionary.en-US.txt +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/.vscode/ltex.disabledRules.en-US.txt +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/COPYRIGHT +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/LICENSE-APACHE +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/LICENSE-MIT +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/docs/MAPPING.md +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/docs/PROTOCOL.md +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/release-please-config.json +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/renovate.json +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/src/proflame/py.typed +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/cmd.csv +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/frames/flame_down.timings.json +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/frames/flame_up.timings.json +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/frames/manual_sweeps.frames.jsonl +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/frames/power_on_off.timings.json +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tests/frames/smart_mode.frames.jsonl +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tools/analyze_cmd_csv.py +0 -0
- {proflame-0.1.0 → proflame-0.2.0}/tools/decode_proflame.py +0 -0
|
@@ -16,8 +16,8 @@ jobs:
|
|
|
16
16
|
name: Ruff
|
|
17
17
|
runs-on: ubuntu-24.04
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
20
|
-
- uses: astral-sh/setup-uv@
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
- uses: astral-sh/setup-uv@v10.4.2
|
|
21
21
|
- run: uvx ruff check .
|
|
22
22
|
|
|
23
23
|
test:
|
|
@@ -28,8 +28,8 @@ jobs:
|
|
|
28
28
|
matrix:
|
|
29
29
|
python: ["3.12", "3.13", "3.14"]
|
|
30
30
|
steps:
|
|
31
|
-
- uses: actions/checkout@
|
|
32
|
-
- uses: astral-sh/setup-uv@
|
|
31
|
+
- uses: actions/checkout@v7
|
|
32
|
+
- uses: astral-sh/setup-uv@v10.4.2
|
|
33
33
|
- run: |
|
|
34
34
|
uv sync --python ${{ matrix.python }}
|
|
35
35
|
uv run basedpyright
|
|
@@ -39,5 +39,5 @@ jobs:
|
|
|
39
39
|
name: Validate renovate config
|
|
40
40
|
runs-on: ubuntu-24.04
|
|
41
41
|
steps:
|
|
42
|
-
- uses: actions/checkout@
|
|
42
|
+
- uses: actions/checkout@v7
|
|
43
43
|
- run: npx --yes --package renovate -- renovate-config-validator --strict
|
|
@@ -20,9 +20,9 @@ jobs:
|
|
|
20
20
|
uses: actions/create-github-app-token@v3
|
|
21
21
|
id: generate-token
|
|
22
22
|
with:
|
|
23
|
-
|
|
23
|
+
client-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
|
|
24
24
|
private-key: ${{ secrets.RELEASE_PLZ_PRIVATE_KEY }}
|
|
25
|
-
- uses: googleapis/release-please-action@
|
|
25
|
+
- uses: googleapis/release-please-action@v5
|
|
26
26
|
id: release
|
|
27
27
|
with:
|
|
28
28
|
token: ${{ steps.generate-token.outputs.token }}
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
# PyPI trusted publishing (OIDC): no long-lived token to leak.
|
|
37
37
|
id-token: write
|
|
38
38
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
40
|
-
- uses: astral-sh/setup-uv@
|
|
39
|
+
- uses: actions/checkout@v7
|
|
40
|
+
- uses: astral-sh/setup-uv@v10.4.2
|
|
41
41
|
- run: uv build
|
|
42
42
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0](https://github.com/Aetf/proflame/compare/v0.1.1...v0.2.0) (2026-12-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* decode every frame in a burst that holds several ([3690935](https://github.com/Aetf/proflame/commit/36909358def94126b99f6aa76f3fdda043d9f977))
|
|
9
|
+
|
|
10
|
+
## [0.1.1](https://github.com/Aetf/proflame/compare/v0.1.0...v0.1.1) (2026-09-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* decode frames that end on a trailing space ([500a560](https://github.com/Aetf/proflame/commit/500a560b099d38a3af44f7ce06bb99cb744fab0f))
|
|
16
|
+
|
|
3
17
|
## 0.1.0 (2026-08-20)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: proflame
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: SIT Proflame 2 fireplace remote protocol: OOK frame encoder, decoder, and per-remote checksum derivation
|
|
5
5
|
Project-URL: Homepage, https://github.com/Aetf/proflame
|
|
6
6
|
Project-URL: Repository, https://github.com/Aetf/proflame
|
|
@@ -39,11 +39,12 @@ Home Assistant integration and the
|
|
|
39
39
|
nothing here depends on either.
|
|
40
40
|
|
|
41
41
|
```python
|
|
42
|
-
from proflame import Remote, State, encode_timings,
|
|
42
|
+
from proflame import Remote, State, encode_timings, decode_burst
|
|
43
43
|
|
|
44
44
|
# One captured frame is enough to learn a handset, checksum constants and all.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
# A burst may hold several repeats, however the receiver chose to cut it.
|
|
46
|
+
heard = decode_burst(received_timings)
|
|
47
|
+
remote = heard[0].remote
|
|
47
48
|
|
|
48
49
|
# A frame always carries the complete appliance state, never a delta.
|
|
49
50
|
timings = encode_timings(remote, State(power=True, flame=4, light=2))
|
|
@@ -16,11 +16,12 @@ Home Assistant integration and the
|
|
|
16
16
|
nothing here depends on either.
|
|
17
17
|
|
|
18
18
|
```python
|
|
19
|
-
from proflame import Remote, State, encode_timings,
|
|
19
|
+
from proflame import Remote, State, encode_timings, decode_burst
|
|
20
20
|
|
|
21
21
|
# One captured frame is enough to learn a handset, checksum constants and all.
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
# A burst may hold several repeats, however the receiver chose to cut it.
|
|
23
|
+
heard = decode_burst(received_timings)
|
|
24
|
+
remote = heard[0].remote
|
|
24
25
|
|
|
25
26
|
# A frame always carries the complete appliance state, never a delta.
|
|
26
27
|
timings = encode_timings(remote, State(power=True, flame=4, light=2))
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "proflame"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "SIT Proflame 2 fireplace remote protocol: OOK frame encoder, decoder, and per-remote checksum derivation"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT OR Apache-2.0"
|
|
@@ -13,6 +13,7 @@ from .protocol import (
|
|
|
13
13
|
Remote,
|
|
14
14
|
State,
|
|
15
15
|
checksum,
|
|
16
|
+
decode_burst,
|
|
16
17
|
decode_frame,
|
|
17
18
|
derive_key,
|
|
18
19
|
encode_timings,
|
|
@@ -32,6 +33,7 @@ __all__ = [
|
|
|
32
33
|
"Remote",
|
|
33
34
|
"State",
|
|
34
35
|
"checksum",
|
|
36
|
+
"decode_burst",
|
|
35
37
|
"decode_frame",
|
|
36
38
|
"derive_key",
|
|
37
39
|
"encode_timings",
|
|
@@ -27,6 +27,12 @@ FRAME_BLOCKS = 7
|
|
|
27
27
|
#: Silence between repeats of a frame, as measured from the remote.
|
|
28
28
|
INTER_FRAME_GAP_US = 4150
|
|
29
29
|
|
|
30
|
+
#: The longest space the line code puts inside a frame, in symbols: a 0 bit
|
|
31
|
+
#: opens with a space, and the symbol before it — the second half of a 1 bit,
|
|
32
|
+
#: or the space closing a sync — may be one too. A longer space cannot be part
|
|
33
|
+
#: of a frame, so it is the gap between two.
|
|
34
|
+
_MAX_FRAME_SPACE_SYMBOLS = 2
|
|
35
|
+
|
|
30
36
|
#: Repetitions proven on air. The remote sends five per state change; the
|
|
31
37
|
#: transmission that first ignited the fireplace sent ten.
|
|
32
38
|
DEFAULT_REPEATS = 10
|
|
@@ -219,22 +225,56 @@ class DecodedFrame:
|
|
|
219
225
|
state: State
|
|
220
226
|
|
|
221
227
|
|
|
228
|
+
def _symbol_count(duration_us: int) -> int:
|
|
229
|
+
return max(1, round(abs(duration_us) / SYMBOL_US))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def decode_burst(timings: list[int]) -> list[DecodedFrame]:
|
|
233
|
+
"""Decode every clean frame in a received burst, in air order.
|
|
234
|
+
|
|
235
|
+
How many frames a burst holds is the receiver's doing, not the
|
|
236
|
+
protocol's: a receiver ends a burst after its own idle timeout, and one
|
|
237
|
+
that outlasts the inter-frame gap — ESPHome's remote_receiver defaults to
|
|
238
|
+
10 ms — hands over a whole transmission at once. The burst is cut at every
|
|
239
|
+
space longer than any a frame contains and each piece decoded on its own.
|
|
240
|
+
Such a space would make `decode_frame` reject the frame regardless, so
|
|
241
|
+
cutting there never loses a frame, and the rule needs no gap length: it
|
|
242
|
+
holds for any handset and any receiver timeout.
|
|
243
|
+
|
|
244
|
+
Repeats are reported as heard rather than merged; what to make of them is
|
|
245
|
+
the caller's business.
|
|
246
|
+
"""
|
|
247
|
+
pieces: list[list[int]] = []
|
|
248
|
+
start = 0
|
|
249
|
+
for index, value in enumerate(timings):
|
|
250
|
+
if value < 0 and _symbol_count(value) > _MAX_FRAME_SPACE_SYMBOLS:
|
|
251
|
+
pieces.append(timings[start:index])
|
|
252
|
+
start = index + 1
|
|
253
|
+
pieces.append(timings[start:])
|
|
254
|
+
return [frame for frame in map(decode_frame, pieces) if frame is not None]
|
|
255
|
+
|
|
256
|
+
|
|
222
257
|
def decode_frame(timings: list[int]) -> DecodedFrame | None:
|
|
223
|
-
"""Decode
|
|
258
|
+
"""Decode one frame, or None if it is not a clean frame.
|
|
224
259
|
|
|
225
260
|
Deliberately all-or-nothing: a consumer acting on a frame that failed
|
|
226
261
|
parity would be worse than one ignoring it. Protocol analysis, which
|
|
227
262
|
wants partial results and framing diagnostics, is a different job — see
|
|
228
|
-
`tools/decode_proflame.py`.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
263
|
+
`tools/decode_proflame.py`. A receiver's burst may hold several frames;
|
|
264
|
+
`decode_burst` takes it apart.
|
|
265
|
+
|
|
266
|
+
A frame's final space has no terminating edge on air, so what a receiver
|
|
267
|
+
reports after the last mark is the inter-frame gap, not the frame: some
|
|
268
|
+
end the burst there, others (ESPHome's remote_receiver) append their idle
|
|
269
|
+
timeout as one long space. Either way the tail is discarded and restored
|
|
270
|
+
from the known block length rather than treated as an error.
|
|
233
271
|
"""
|
|
272
|
+
end = len(timings)
|
|
273
|
+
while end and timings[end - 1] <= 0:
|
|
274
|
+
end -= 1
|
|
234
275
|
symbols: list[bool] = []
|
|
235
|
-
for value in timings:
|
|
236
|
-
|
|
237
|
-
symbols += [value > 0] * count
|
|
276
|
+
for value in timings[:end]:
|
|
277
|
+
symbols += [value > 0] * _symbol_count(value)
|
|
238
278
|
while len(symbols) % BLOCK_SYMBOLS:
|
|
239
279
|
symbols.append(False)
|
|
240
280
|
|
|
@@ -18,10 +18,12 @@ import pytest
|
|
|
18
18
|
|
|
19
19
|
from proflame import (
|
|
20
20
|
BLOCK_SYMBOLS,
|
|
21
|
+
INTER_FRAME_GAP_US,
|
|
21
22
|
SYMBOL_US,
|
|
22
23
|
Remote,
|
|
23
24
|
State,
|
|
24
25
|
checksum,
|
|
26
|
+
decode_burst,
|
|
25
27
|
decode_frame,
|
|
26
28
|
derive_key,
|
|
27
29
|
encode_timings,
|
|
@@ -104,8 +106,7 @@ def test_bench_captures_decode_to_the_documented_fields(
|
|
|
104
106
|
assert {d.remote for d in decoded} == {REMOTE}
|
|
105
107
|
|
|
106
108
|
|
|
107
|
-
def
|
|
108
|
-
"""Encode each state ever heard off the air; decoding returns it exactly."""
|
|
109
|
+
def _captured_states() -> list[State]:
|
|
109
110
|
states = {
|
|
110
111
|
d.state
|
|
111
112
|
for name in ("manual_sweeps", "smart_mode")
|
|
@@ -113,6 +114,12 @@ def test_every_captured_state_round_trips() -> None:
|
|
|
113
114
|
if d is not None
|
|
114
115
|
}
|
|
115
116
|
assert len(states) == 31
|
|
117
|
+
return sorted(states, key=State.to_commands)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_every_captured_state_round_trips() -> None:
|
|
121
|
+
"""Encode each state ever heard off the air; decoding returns it exactly."""
|
|
122
|
+
states = _captured_states()
|
|
116
123
|
for state in states:
|
|
117
124
|
decoded = decode_frame(encode_timings(REMOTE, state))
|
|
118
125
|
assert decoded is not None
|
|
@@ -186,6 +193,37 @@ def test_rejects_frames_broken_in_exactly_one_way(
|
|
|
186
193
|
assert decode_frame(corrupt(_to_symbols(good))) is None
|
|
187
194
|
|
|
188
195
|
|
|
196
|
+
@pytest.mark.parametrize("tail", [[-4150], [-3000], [-100000], [-450, -3000]])
|
|
197
|
+
def test_trailing_gap_is_not_part_of_the_frame(tail: list[int]) -> None:
|
|
198
|
+
"""Receivers that report the idle after the last mark still decode.
|
|
199
|
+
|
|
200
|
+
The frame's own final space is unobservable on air, so anything after
|
|
201
|
+
the last mark is the gap, whatever length the receiver put on it.
|
|
202
|
+
"""
|
|
203
|
+
state = State(power=True, flame=4, light=2)
|
|
204
|
+
good = encode_timings(REMOTE, state)
|
|
205
|
+
decoded = decode_frame(good + tail)
|
|
206
|
+
assert decoded is not None
|
|
207
|
+
assert decoded.state == state
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def test_a_burst_holding_many_frames_decodes_each() -> None:
|
|
211
|
+
"""A receiver whose idle outlasts the gap hands over whole transmissions.
|
|
212
|
+
|
|
213
|
+
ESPHome's remote_receiver defaults to a 10 ms idle, so the gaps between
|
|
214
|
+
repeats arrive inside the burst and the idle as one space at its end.
|
|
215
|
+
Every captured state, back to back, so that each one's bit pattern has to
|
|
216
|
+
survive the cutting.
|
|
217
|
+
"""
|
|
218
|
+
states = _captured_states()
|
|
219
|
+
burst: list[int] = []
|
|
220
|
+
for state in states:
|
|
221
|
+
burst += encode_timings(REMOTE, state) + [-INTER_FRAME_GAP_US]
|
|
222
|
+
burst[-1] = -10_000
|
|
223
|
+
|
|
224
|
+
assert [d.state for d in decode_burst(burst)] == states
|
|
225
|
+
|
|
226
|
+
|
|
189
227
|
def test_frame_blocks_layout() -> None:
|
|
190
228
|
"""Seven blocks in air order: identity, commands, per-half checksums."""
|
|
191
229
|
state = State(power=True, flame=4, light=2)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|